Why do you need to know which OS you are running on at runtime? Your going to need two different executables anyway, so might as well do it differently in each, by means of a #ifdef or similar.
Why do you need to know which OS you are running on at runtime? Your going to need two different executables anyway, so might as well do it differently in each, by means of a #ifdef or similar.
Arktos (9th November 2009)
Thanks to both of you. Of course you are right I have to build for each OS separately, so I can use the Qt-Macros and #IF -Statements anyway.
But the second part of my question is still interesting for me. Why? I will give you a short background of what i want to do:
I write a statistic program for a game. This game writes logfiles while playing this game.
Now it is interesting for my program to know wheter the game is running and when it is running to live-refresh the statistics by reading the logfile.
The Game runs on Win32 and MacOS, so i ask for a way to determine platform independant that the game ( a process) is running at this moment when my statistic program is running as well.
Thank you very much for reading
and have a nice day![]()
You mean you want to do inter process communication? Or you could just use a mutex to detect whether or not the first program is running (If its running, trying to acquire the mutex will fail as its already been obtained by the first program).
Or, you could just do it the way Unix programs have done it for years: Open a file when the first program runs. Write the process id to that file (or something else, for example, the date and time if you don't care about talking to it), and delete that file when the first program quits. The second program (the statistic program) will simply check if that file exists, and if so, will assume the first program is running (and perhaps check the contents to make sure the file isn't stale)
Bookmarks