How to detect Windows XP, 98, 2000, me by pre-compiled directives or some ways

Please tell me ways to detect Windows XP or 98 or 2000 or Me in C# code, like this:
#if defined('WINDOWS_XP')
//...
#endif

Thanks for your response.



Answer this question

How to detect Windows XP, 98, 2000, me by pre-compiled directives or some ways

  • GrayMatter Software

    If you use precompiled directives, the output will be resulted by your own OS, not the target OS. I don't think you wan't to use that. If you do, just define the operating system in the beginning of the source file.

    But if you like the program to react on the users OS version, you can use the Environment.OSVersion to determine the current operating system.

  • How to detect Windows XP, 98, 2000, me by pre-compiled directives or some ways