Thread: Detecting if OS is Windows???

  1. #1
    Registered User Ktulu's Avatar
    Join Date
    Oct 2006

    Question Detecting if OS is Windows???

    This may sound stupid but I do want to ask it to be sure.
    If you have a cross platform application which can run under a Windows OS and Mac OS, in example,
    is there a way to detect if that OS is a Windows OS and if it actually is a Windows OS, are you then able to use Windows code?
    This parameter is reserved

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Hi, this post may answer your question.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    You probably want some #if type stuff around the OS specific parts of your code.

    If you do it carefully, you should have
    win.cpp - all the windows specific code
    mac.cpp - all the mac specific code
    Both these files provide the same interface to
    main.cpp - all the independent code
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program works on Windows XP and 2000, not on 98 or ME
    By MidnightlyCoder in forum C++ Programming
    Replies: 7
    Last Post: 03-10-2006, 03:36 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Windows 98/2000 programming in Windows XP
    By Bill83 in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:16 PM
  4. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM