안녕하세요...
프로세스를 나타내는 델파이 코드인데 C++Builder로 변경을 못하겠네요 ㅠㅠ
도와주세요.
아... 출처는 김영대님의 홈피 팁&트릭에서 가지고 왔습니다.
http://www.howto.pe.kr/
procedure TForm1.Button1Click(Sender: TObject);
type
integer = DWORD;
var
i, pidNeeded: Integer;
PIDList : array[0..1000] of Integer; // 배열 크기는 충분히 크게 잡는다
PIDName : array [0..MAX_PATH - 1] of char;
PH : THandle;
PMC: TProcessMemoryCounters;
begin
ListBox1.Items.Clear;
// 모든 process id를 배열에 저장한다
if not EnumProcesses (@PIDList, 1000, pidNeeded) then begin
ListBox1.Items.Add('Need psapi.dll');
exit;
end;
PMC.cb:=SizeOf(PMC);
// 각각의 프로세스를 연다
for i := 0 to (pidNeeded div sizeof(Integer)-1) do begin
// 프로세스의 핸들을 얻는다
PH := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, PIDList[i]);
if PH <> 0 then begin
if GetModuleBaseName(PH, 0, PIDName, sizeof (PIDName)) > 0 then begin
GetProcessMemoryInfo(PH, @PMC, SizeOf(PMC));
ListBox1.Items.Add(StrPas(PIDName)+'('+IntToStr(PIDList[i])+') : '+IntToStr(PMC.WorkingSetSize div 1024)+'KB');
end;
end;
if PH > 0 then CloseHandle(PH);
end;
end;