Reputation:
In python I can use os.getpid() and os.name() to get information about the Process ID and OS name. Is there something similar in C++? I tried GetProcessId() but was told that this is undeclared... I am using Cygwin under windows.
Thank you
Upvotes: 0
Views: 1343
Reputation: 27583
To use GetProcessId you need to include Windows.h and link to Kernel32.lib. See Process and Thread Functions for more information.
I use MSYS/mingw instead of cygwin. So, you may need the w32api package installed.
Upvotes: 1
Reputation:
I recommend Hart's book "Win32 System Programming". Great discussion about how to manage processes, memory, files etc in Kernel32, if you're just starting to look at Windows programming. You can also get a free version of Visual Studio (http://www.microsoft.com/express/).
Upvotes: 0
Reputation:
Standard C++ has no such functionality. You need to use OS specific features to get this. In your case, you need to look up POSIX/UNIX functions such as getpid().
Note that if you actually do want to call the Windows functions to get process ID etc, you should be using a C++ environment like MinGW, which allows you to build native Windows applications, rather than Cygwin, which is more aimed at porting POSIX apps to Windows.
Upvotes: 3