Link to home
Start Free TrialLog in
Avatar of SonicM3
SonicM3

asked on

How can i pull date from process to delphi

Hi, I can pull the process image names from taskmanger into delphi but I want to also pull in the description of each file.

                                           images name      username     cpu   memory     description
for example i can pull in:     sonicT.exe      
but i want to pull in:             sonicT.exe                                                         1.1.0

If you check your own process window you will see descripton at the far raght, well I need to pull that into delphi.
This is my code to pull in image names:


procedure TForm1.Button1Click(Sender: TObject);
var
MyHandle: THandle;
Struct: TProcessEntry32;
begin
try
MyHandle:=CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
Struct.dwSize:=Sizeof(TProcessEntry32);
if Process32First(MyHandle, Struct) then
ListBox1.Items.Add(Struct.szExeFile);
while Process32Next(MyHandle, Struct) do
ListBox1.Items.Add(Struct.szExeFile);
except on exception do
ShowMessage('Error showing process list');
end
end;

Open in new window

Avatar of SonicM3
SonicM3

ASKER

i am stuck on this people, sorry i am not patient but i am so far behind i am trying to catch up tonight, all night.  
Avatar of Geert G
what is this for ?

that's not the description, that's the file version !



function GetFileVersion(const FileName: TFileName): string;
var
  Major, Minor, Release, Build: word;
  size, len: longword;
  handle: THandle;
  buffer: pchar;
  pinfo: ^VS_FIXEDFILEINFO;
begin
    Major := 0;
    Minor := 0;
    Release := 0;
    Build := 0;
    size := GetFileVersionInfoSize(Pointer(FileName), handle);
    if size > 0 then
    begin
      GetMem(buffer, size);
      if GetFileVersionInfo(Pointer(FileName), 0, size, buffer)
      then
        if VerQueryValue(buffer, '\', pointer(pinfo), len) then
        begin
          Major   := HiWord(pinfo.dwFileVersionMS);
          Minor   := LoWord(pinfo.dwFileVersionMS);
          Release := HiWord(pinfo.dwFileVersionLS);
          Build   := LoWord(pinfo.dwFileVersionLS);
        end;
      FreeMem(buffer);
    end;
    result := Format('%d.%d.%d.%d',[Major, Minor, Release, Build]);
end;

Open in new window

Avatar of SonicM3

ASKER

yer i know i said i want the file description.
ignore the 1.1.0 my program shows the version inside description that was just example.
Avatar of SonicM3

ASKER

just going to check the code now buddy
Avatar of SonicM3

ASKER

when i paste this code in its just a blank screen    any ideas?
Avatar of SonicM3

ASKER

i need to know how to oupput results pls into a listbox via a button.
do you have anything else working in your "project"
besides this listing of running programs ?
Avatar of SonicM3

ASKER

my project is massive..but i want to get this working in a blank project first so it outputs into a listbox when button1 is pressed.
Avatar of SonicM3

ASKER

uses TLHelp32

procedure TForm1.Button1Click(Sender: TObject);
var
MyHandle: THandle;
Struct: TProcessEntry32;
begin
try
MyHandle:=CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
Struct.dwSize:=Sizeof(TProcessEntry32);
if Process32First(MyHandle, Struct) then
ListBox1.Items.Add(Struct.szExeFile);
while Process32Next(MyHandle, Struct) do
ListBox1.Items.Add(Struct.szExeFile);
except on exception do
ShowMessage('Error showing process list');
end
end;



this is the code im using VB, it works tho. Can that code be fitted into this code to see fileversion. ?
Avatar of SonicM3

ASKER

im not using vb, i mean its VB code but works perfect in delphi too.
ASKER CERTIFIED SOLUTION
Avatar of dougaug
dougaug
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SonicM3

ASKER

great