Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.08.15;
Скачать: CL | DM;

Вниз

Как определить размер проги   Найти похожие ветки 

 
Aydar ©   (2002-08-05 03:12) [0]

Я делаю что-то типа Process View и в списке процессов
хочу добавить его размер
я делал так:
сканирую процесс на наличие модулей и модули у которых
Global Usage = 1 включаю в размер
но что-то слишком мало получается...
вообщем помогите


 
Ученик ©   (2002-08-05 10:21) [1]

Как узнать размер процесса на Windows 95/98 не знаю, на Windows XP работает это:

type
TNtQuerySystemInformation = function (InfoType : LongInt;
SystemInformation : Pointer;
SystemInformationLength : DWord;
var ReturnLength : DWord) : Bool; stdcall;

TSystemProcessInformation = packed record
NextEntryOffset : ULONG;
NumberOfThreads : ULONG;

SpareLi1 : LARGE_INTEGER;
SpareLi2 : LARGE_INTEGER;
SpareLi3 : LARGE_INTEGER;
CreateTime : FILETIME;
UserTime : FILETIME;
KernelTime : FILETIME;
dwUnk14 : DWord;
ImageName : PWChar;
BasePriority : ULONG;
UniqueProcessId : THandle;
InheritedFromUniqueProcessId : THandle;
HandleCount : ULONG;
SpareUl2 : ULONG;
SpareUl3 : ULONG;
PeakVirtualSize : ULONG ;
VirtualSize : ULONG ;
PageFaultCount : ULONG;
PeakWorkingSetSize : ULONG;
WorkingSetSize : ULONG;
QuotaPeakPagedPoolUsage : ULONG;
QuotaPagedPoolUsage : ULONG;
QuotaPeakNonPagedPoolUsage : ULONG;
QuotaNonPagedPoolUsage : ULONG;
PagefileUsage : ULONG;
PeakPagefileUsage : ULONG;
PrivatePageCount : ULONG;
ThreadInfos : array[0..0] of Byte;
end;
PSystemProcessInformarion = ^TSystemProcessInformation;

procedure TForm1.Button1Click(Sender: TObject);
var
hNTDll : THandle;
NtQuerySystemInformation : TNtQuerySystemInformation;
SystemInformation, CurrentInformation : PSystemProcessInformarion;
dwReturnLength : DWord;
sInfo : string;
begin
hNTDll := LoadLibrary("NTDLL.DLL");
if hNTDll <> 0 then try
@NtQuerySystemInformation := GetProcAddress(hNTDll, "NtQuerySystemInformation");
if @NtQuerySystemInformation <> nil then begin
GetMem(SystemInformation, 32000);
if SystemInformation <> nil then try
FillChar(SystemInformation^, 32000, 0);
NtQuerySystemInformation(5, SystemInformation, 32000, dwReturnLength);
CurrentInformation := SystemInformation;
if dwReturnLength > 0 then repeat
with CurrentInformation^ do begin
sInfo := "ProcessID: " + IntToStr(UniqueProcessID) +
", ImageName: " + ImageName + ", WorkingSetSize: " +
IntToStr(WorkingSetSize div 1024) + " К";
ListBox1.Items.Add(sInfo);
if CurrentInformation.NextEntryOffset <> 0 then begin
Inc(PChar(CurrentInformation), CurrentInformation.NextEntryOffset)
end else
Break
end
until False
finally
FreeMem(SystemInformation)
end
end
finally
FreeLibrary(hNTDll)
end
end;


 
Ученик ©   (2002-08-05 10:37) [2]

Решение попроще:

uses
PsApi;

procedure TForm1.Button1Click(Sender: TObject);
var
hProcess : THandle;
Counters : TPROCESSMEMORYCOUNTERS;
begin
hProcess := OpenProcess(PROCESS_QUERY_INFORMATION, False, GetCurrentProcessID);
if hProcess <> 0 then try
if GetProcessMemoryInfo(hProcess, @Counters, SizeOf(Counters)) then
ShowMessage(IntToStr(Counters.WorkingSetSize div 1024))
finally
CloseHandle(hProcess)
end
end;




Страницы: 1 вся ветка

Текущий архив: 2002.08.15;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.013 c
7-48340
Megadeth
2002-06-03 19:01
2002.08.15
S.M.A.R.T


14-48280
Vicos1
2002-07-21 17:12
2002.08.15
Вопрос по матери на i810


3-47924
Rustik
2002-07-25 10:33
2002.08.15
Мастера подскажите где можно посмотреть как создать адресный


14-48277
Alexsey
2002-07-21 15:08
2002.08.15
Очень нужна помощь от вас........


3-47918
Sapersky_
2002-07-22 04:57
2002.08.15
Хранение файлов