🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10935

Re: how to get the running process in the system

#10935
From: Ed Mulroy [TeamB]
Date: Fri, 05 Mar 2004 22:53
51 lines
2269 bytes
As I remember it when you do a do a snapshot and then cycle through the
processes you are given the name of the executable file associated with each
process. .

It might go something like this but I've done it from memory so beware of
typos:

  --------------------
  #define STRICT
  #include <windows.h>
  #include <tlhelp32.h>

  HANDLE snap_hand =
    CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

  if ((int) snap_hand != -1)
      {
      PROCESSENTRY32 pe32;

      pe32.dwSize = sizeof(pe32);

      if (Process32First(snap_hand, &pe32))
          {
          do
              {
   // ==>> here pe32.szExeFile has the file name <<==
              } while (Process32Next(snap_hand, &pe32));
          }
      }
  --------------------

.  Ed

> davichu wrote in message
> news:4048ef9c@newsgroups.borland.com...
>
> I need to know how to get the names of the process
> running in the system, for example : winword.exe,
> explorer.exe and so on.
>
>
> There is an example named 'Procview' witch shows
> the running window's caption, the follow functions are
> used:
>
>   EnumWindows((WNDENUMPROC)EnumProc, lp);
>      GetWindowThreadProcessId(hWnd, pPid);
>         GetWindowText (hWnd, titlewindow, 110)
>
>
> But I don't  nedd the captions, I need the name of the process .
Technical Details
Message-ID: <404904e7$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!news.linkpendium.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4048ef9c@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,b9338c4feb94156f
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-03-05 14:55:48 PST
From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4048ef9c@newsgroups.borland.com>
Subject: Re: how to get the running process in the system
Date: Fri, 5 Mar 2004 17:53:25 -0500
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 24.74.175.102
Message-ID: <404904e7$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1078527207 24.74.175.102 (5 Mar 2004 14:53:27 -0800)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!news.linkpendium.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail