0

I am launching a java application (testApp.exe) using CreateProcess() win32 API. PROCESS_INFORMATION structure is returning me a process id that does not exist in the list of PIDs in taskmanager or EnumProcesses() API. I can see there is one javaw.exe is launched having some different process id. this javaw.exe process id is different from PID returned by PROCESS_INFORMATION structure.

How can I get the correct PID.

I want to launch this java application, and sometime later I want to kill this java application using PID.

Anil8753
  • 2,663
  • 4
  • 29
  • 40
  • possible duplicate of http://stackoverflow.com/questions/5284139/how-do-i-find-the-process-id-pid-of-a-process-started-in-java – xpa1492 Oct 14 '14 at 08:56

1 Answers1

0

It should be physically impossible for CreateProcess() to report a PID that TaskManager does not see (unless there is a low-level Trojan/rootkit that is hiding the PID). Until the process ends AND you close the handles that CreateProcess() returns, the process exists and its PID cannot disappear.

What is most likely happening is that you close the handles from CreateProcess(), and the new process in question is exiting, before you have a chance to look in TaskManager or enumerate the running processes in code.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770