user2652995
user2652995

Reputation: 57

Get pid of started process c++

I try to get PID of process which i started by my app.

 DWORD dwPid = GetProcessId(pi.hProcess);

Somewhere on this forum is this solution but i dont have func "GetProcessId"

To start process i'm using:

BOOL bSuccess = FALSE;
LPTSTR pszCmd = NULL;
PROCESS_INFORMATION pi;// = {0};
STARTUPINFO si = {0};
si.cb = sizeof(si);

pszCmd = ""; /* assign something useful */
bSuccess = CreateProcess("D:\\program\\program.exe",NULL, NULL, NULL, TRUE, 0, NULL, "D:\\program", &si, &pi);
if (bSuccess)
{

}
  1. It is possible to run my code in this started program without dll ?

Upvotes: 0

Views: 2144

Answers (1)

user4815162342
user4815162342

Reputation: 154846

According to the documentation on PROCESS_INFORMATION, you can access the process id directly from the PROCESS_INFORMATION struct by accessing the dwProcessId member:

DWORD dwPid = pi.dwProcessId;

Upvotes: 1

Related Questions