0

How can I get the current process id from an unmanaged C++ console application? I see that

GetWindowThreadProcessId

Works when you have an HWND, but what can I do for a console application?

Kim Gräsman
  • 7,438
  • 1
  • 28
  • 41
Kyle
  • 17,317
  • 32
  • 140
  • 246

2 Answers2

6

Have you tried GetCurrentProcessId?

http://msdn.microsoft.com/en-us/library/ms683180(VS.85).aspx

Kim Gräsman
  • 7,438
  • 1
  • 28
  • 41
1

GetCurrentProcessId

Exact same question? Windows

In unix you can go:

#include <sys/types.h>
#include <unistd.h>

pid_t getpid(void);
pid_t getppid(void);

DESCRIPTION getpid() returns the process ID of the current process. (This is often used by routines that generate unique temporary filenames.)

Community
  • 1
  • 1
Alex
  • 6,843
  • 10
  • 52
  • 71