Kyle
Kyle

Reputation: 17677

Unmanaged C++ Get the current process id? (Console Application)

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?

Upvotes: 0

Views: 4938

Answers (2)

Alex
Alex

Reputation: 6933

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.)

Upvotes: 1

Kim Gr&#228;sman
Kim Gr&#228;sman

Reputation: 7586

Have you tried GetCurrentProcessId?

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

Upvotes: 6

Related Questions