Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2002.08.15;
Скачать: [xml.tar.bz2];

Вниз

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

 
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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.007 c
1-48190
Олеся
2002-08-02 15:54
2002.08.15
Как работать с indy?


1-48191
Sedunov Vitaly
2002-08-02 18:41
2002.08.15
OnActivate


4-48377
Вовчик
2002-06-08 16:58
2002.08.15
Клик мыши


1-48127
BlackSun
2002-07-31 17:10
2002.08.15
exe+dll->exe


4-48373
tararasyk
2002-06-08 12:01
2002.08.15
Робота з файлами





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский