Mam tu taki kod co mi nie działa:
procedure TForm1.szukajPamiec;
var item : TlistItem;
Hash : TMD5Digest;
Ikona : TIcon;
PE : TProcessEntry32;
SnapShot : THandle;
temp2 : string;
i : integer;
begin
Ikona := TIcon.Create;
SnapShot := CreateToolHelp32SnapShot(TH32CS_SNAPALL, 0);
PE.dwSize := SizeOf(PE);
if Process32First(SnapShot, PE) then
begin
while Process32Next(SnapShot, PE) do
begin
if not progress then exit;
panel1.Caption :=inttostr(pe.th32ProcessID) + ':' + PE.szExeFile;
inc(spraw);
lbspraw.Caption := inttostr(spraw);
exe.Max := spraw;
inc(SprawExe);
exe.Position := SprawExe;
lbSprawExe.Caption := inttostr(SprawExe);
try
Hash := MD5File(PE.szExeFile);
except on exception do raportuj('Błąd: Nie można odczytać pliku. Plik jest albo uszkodzony albo używany przez inny proces',PE.szExeFile);
end;
temp2 := MD5DigestToStr(hash);
for i := 0 to Filtry.Count -1 do
begin
if compareStrWithMask(temp2, filtry[i]) then
begin
item := listview1.Items.Add;
item.Checked := true;
item.Caption := ExtractFileName(PE.szExeFile);
item.SubItems.Add(nazwa[i]);
item.SubItems.Add(ExtractFilePath(PE.szExeFile));
inc(dousun);
lbusun.Caption := inttostr(dousun);
delexe.Max := SprawExe;
delexe.Position := dousun;
Ikona.Handle := ExtractIcon(hInstance, PE.szExeFile,0);
imagelist1.AddIcon(ikona);
item.ImageIndex := imagelist1.Count -1;
item.StateIndex := 1;
break;
end;
end;
end;
CloseHandle(SnapShot);
ikona.Free;
end;
end;
Kiedy odpalam procedure pokazuje mi się błąd: Access vioalation at...
Mam Windows XP i delphi 2005 PE