Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Os Detection (http://www.programmingforums.org/showthread.php?t=1132)

Ooble Nov 14th, 2004 8:02 AM

Is there any way to find out what OS someone's using (Windows, Linux, FreeBSD, Mac OS etc.), and which version?

Mjordan2nd Nov 14th, 2004 10:26 AM

You'd probably have to look up OS fingerprinting, but I have no idea how it works, so I can't help you there. Sorry.

Ooble Nov 14th, 2004 3:37 PM

I meant the local OS - the OS the app is being run from. As far as I know, fingerprinting is finding out what OS is running on a remote computer by determining characteristics.

kurifu Nov 14th, 2004 6:11 PM

OS fingerprinting attempts to find a user's OS remotely (or even over a local network, or computer) by probing open TCP ports and determining characteristics on the ports available and not available as well as the data the available ports return pertaining to specific operating systems.

What your looking for you would think to be easier, however the problem stands that every operating system really has their own way of recording that information. Where do you plan on attempting to epxtrapolate this information? Trying to detmine an OS from a browser with Javascript is much more different than doing so from a command line.

Infinite Recursion Nov 14th, 2004 11:15 PM

This is a one-liner in PHP. Any reason you are using C++?:

Berto Nov 15th, 2004 3:02 AM

it could be a desktoip application? make sure whoever is running the program is using the correct operating system to run it with? as i make it so you dont run a win xp appication on a win 98 system as the libraries are different?

Ooble Nov 15th, 2004 10:01 AM

Bingo. I also want to use function pointers or virtual functions (not sure which) to sort out which function should be used for each OS, effectively making it cross-compatible. Isn't there a #define I can test? I think there's one called _WIN32, but I have no idea about Linux. I know I can call system("ver > file") and then read the file - can I do that on Unix too?

tempest Nov 15th, 2004 3:16 PM

As far as linux/windows goes you pretty much know where it is being ran from (unless wine is involed, or something of the sort) by what you compiled it with. As for windows i would say check the registry under HKEY_CURRENT_VER (i am NOT a windows programmer, so please forgive me if i am talking out of my ass) or something like that and look up registry values with the functions defined in #include <windows.h>, as for linux... hmm... good question.

Ooble Nov 15th, 2004 4:31 PM

I'll probably use ver on Windows - much simpler. I just want to know how to detect whether I'm using Linux so I can sort out which #includes to... include, I suppose.

tempest Nov 15th, 2004 5:16 PM

#includes are done at compile! And compilation isnt cross-platform. That means that you cant decide just which includes you want to execute, because they are simply code thats added to your program when it is "made".


All times are GMT -5. The time now is 4:20 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC