Hi, i would like to know which function should I use if I want to know the exe file of a running process, i haven't found anything useful in the API documentation yet. I'm using EnumWindows to get the handles of all the windows, then i'm using GetWindowTextA to show the window title, but i want to show the exe name as well. thanx.
Posted on 2001-05-05 16:49:00 by sombrax
You can use the GetModuleFileName API. DWORD GetModuleFileName( HMODULE hModule, // handle to module LPTSTR lpFilename, // file name of module DWORD nSize // size of buffer ); For more information, you can check the GetModuleFileName function at MSDN too. Happy coding. Readiosys aka Youpa. This message was edited by Readiosys, on 5/5/2001 5:05:18 PM
Posted on 2001-05-05 17:04:00 by Readiosys
Hi, I think you might be able to make use of the Tool Help functions for this. Depending on the Win32 API reference you have these API's may or may not be documented, but you can find the information on the Web. There are several in this family: CreateToolhelp32Snapshot Heap32First Heap32ListFirst Heap32ListNext Heap32Next Module32First Module32Next Process32First Process32Next Thread32First Thread32Next Toolhelp32ReadProcessMemory From the usages I've seen you seem to start with CreateToolhelp32Snapshot - takes a snapshot of the processes and the heaps, modules, and threads used by the processes. The return value is a handle to the snapshot which is used by the other tool help functions to provide their results. Then you can move on to Process32First and Process32Next ----------------------------- Process32First retrieves information about the first process encountered in a system snapshot. BOOL WINAPI Process32First( HANDLE hSnapshot, LPPROCESSENTRY32 lppe Parameters hSnapshot Handle to the snapshot returned from a previous call to the CreateToolhelp32Snapshot function. lppe Pointer to a PROCESSENTRY32 structure. ----------------------------- Process32Next is similar but retrieves information about the next process recorded in a system snapshot. Within the PROCESSENTRY32 structure is where you can retrieve szExeFile, the Path and filename of the executable file for the process. You can also use th32ProcessID, the Identifier of the process in a direct comparison with GetCurrentProcessId. -------------------------------- PROCESSENTRY32 Describes an entry from a list that enumerates the processes residing in the system address space when a snapshot was taken. typedef struct tagPROCESSENTRY32 { DWORD dwSize; DWORD cntUsage; DWORD th32ProcessID; ULONG_PTR th32DefaultHeapID; DWORD th32ModuleID; DWORD cntThreads; DWORD th32ParentProcessID; LONG pcPriClassBase; DWORD dwFlags; TCHAR szExeFile; } PROCESSENTRY32; typedef PROCESSENTRY32 *PPROCESSENTRY32; ---------------------------------------- Hope this helps, Kayaker
Posted on 2001-05-06 01:16:00 by Kayaker