Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PROCESS

Status
Not open for further replies.

gagou

Programmer
Jul 11, 2001
1
FR
how do I get the PID from the name of the process under NT4 ?
 
use EnumProcesses John Fill
1c.bmp


ivfmd@mail.md
 
Suppose you have PID from EnumProcesses or other function called ProcessID:

char szProcessName[MAX_PATH] = "unknown";
char szTemp[80]; // Get a handle to the passed-in process ID
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID );//Get the process handle
if(hProcess)
{
HMODULE hMod;
DWORD cbNeeded;
if(EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded))
{
GetModuleBaseName(hProcess, hMod, szProcessName,
sizeof(szProcessName));
}
}

Hope this helps, s-)

Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top