tags:

views:

176

answers:

3

Hi

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

+3  A: 

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.

anon
Thanks for your information gents. And how can I get information about the Operating System, is there also some function?
uname() - see http://www.opengroup.org/onlinepubs/009695399/functions/uname.html
anon
mingw or VC++ Express: http://www.microsoft.com/express/vc/
Judge Maygarden
+1  A: 

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.

Judge Maygarden
cygwin is basically a posix environment, not a windows one
anon
I use MSYS and link to Win32 libs. Can you not do so with cygwin?
Judge Maygarden
See: http://cygwin.com/packages/w32api/
Judge Maygarden
MSYS and cygwin are completely different animals
anon
A: 

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