Home > OS >  CreateProcess doubt
CreateProcess doubt

Time:10-08

I use process CreateProcess process B, then create A thread to run the program for process B C process handle
Process A:
CreateProcess (NULL, lpCommandLine, NULL, NULL, NULL, NULL, NULL, NULL, & amp; Si, & amp; LpProcessInformation);

TCHAR szbuff [50].
Wsprintf (szbuff, TEXT (" % d, % d, % d, % d "),
LpProcessInformation hProcess,
LpProcessInformation hThread,
LpProcessInformation dwProcessId,
LpProcessInformation. DwThreadId);
MessageBox (szbuff, NULL, NULL);
Process C:
//TODO: add the control notification handler code
DWORD dwPID=4352;//in the above dwProcessId value
DWORD dwTID=5796;//in the above dwThreadId value
HANDLE hProcess, hTrocess;
HProcess=OpenProcess (PROCESS_ALL_ACCESS, FALSE, dwPID);
HTrocess=OpenThread (PROCESS_ALL_ACCESS, FALSE, dwTID);
Wsprintf (szbuff, TEXT (" % d, % d "), hProcess, hTrocess);
MessageBox (szbuff, NULL, NULL);
Finally obtains two output value process C with process A contrary (process is A process of hProcess is equal to C hTrocess), and what's the matter? And each time the press process C button repeatedly, it is concluded that the hProcess, hTrocess plus four, in turn?

CodePudding user response:

Handle hProcess is process, this is really false, do not have uniqueness system, it can only be used in this process, or quilt process with inheritance, it is similar to local variables rather than the system within the scope of the global variables (metaphor),

CodePudding user response:

Thank you, this book has been finished,
  • Related