How do you define windows version for compiling? & run from VS?

How do I say what version of Windows I want to use when I make a build Is it possible to have it work for multiple versions (98SE, 2000, ME, xp)

Secondly, how do I launch an executable from within the VS IDE

Thanks!


Answer this question

How do you define windows version for compiling? & run from VS?

  • Airex

    If you want to be doubly sure though, in the defines section, or before you include windows.h, define the macro WINVER=0x0410 and _WIN32_WINDOWS=0x0410. This will make sure it will work on all versions of windows from windows 98 onwards. But as Ayman said, be careful with what API you are using because the available functions differ through windows versions.

  • Rahul_hk1

    Code built with VS2005 should work on all the versions of windows you mentioned unless you are using a specific Windows API (in your code) that exists in one version but not the other.

    As for launching an executable through the IDE, just press F5.

    Thanks,
    Ayman Shoukry
    VC++ Team


  • elias_adum

    One more note: Visual C++ 2005 selects the UNICODE variants of the windows APIs by default (eg. MessageBoxW, CreateWindowExW, CreateFileW). These UNICODE APIs aren't available in Win9x, so your app won't work with them.

    If you want to make your VC2005 app work in Win9x, you should make use of the Microsoft Layer for Unicode (see the topic in MSDN).

    1. http://msdn.microsoft.com/library/default.asp url=/library/en-us/mslu/winprog/microsoft_layer_for_unicode_on_windows_95_98_me_systems.asp
    2. http://www.microsoft.com/globaldev/handson/dev/mslu_announce.mspx
    3. http://en.wikipedia.org/wiki/Microsoft_Layer_for_Unicode
    4. http://blogs.msdn.com/michkap/archive/category/7995.aspx



  • dinsdale

    1. Someone else is defining it It might already be defined already in stdafx.h (or the project properties), or it's being defined in windows.h. In the first case, look inside stdafx.h, In the second case, make sure you define WINVER before #including windows.

    arooni wrote:
    If I use api calls like createwindowex (not createwindoexexw),

    I'm assuming this was a spelling mistake, and what you meant was this:

    arooni wrote:
    If I use API calls like CreateWindowExA (not CreateWindowExW),

    As long as you get the spelling correct, then yes, they will be compatible. But now, in order to avoid those unicode variants, you must now properly spell out the API, including the A at the end (createwindowex is wrong spelling and won't compile. CreateWindowEx gives CreateWindowExW now. CreateWindowExA is correct spelling and will give you CreateWindowExA).

    But if you link to unicows.dll (as described in the links), you get the best of both worlds. You can make use of unicode AND still work with Win9x.



  • J. Ho

    So couple questions/comments:

    1) #define WINVER 0x0410 // resulted in a warning that I redefined it...., however, I never defined it in any of my header files... why is this

    2) If I use api calls like createwindowex (not createwindoexexw), will those be backward compatible to earlier versions of windows (like 98SE, ME, etc...) In other words, if I avoid those unicode variants, am I aOK without having to do anything else

    Thanks!

  • How do you define windows version for compiling? & run from VS?