???? ID: 307394 - ????? ???????: 29 ??????? 2010 - ??????: 2.0

????? C++ ?? ????? ?? Windows ?? ??????? ?? ???????? ???? ????

?????? ??????This article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.

?? ????? ??

??? ?? ??????? ???? | ??? ?? ??????? ????

??????

?? ???? ????????? ???? ?? ?? ??? ?? ???????? ?????? ?? ????? ??? ?? ?????? ?? ???? ???? ????????? ?? ??? ?? ?? ???????? ???? ????? ?? Windows 95, Windows 98, Windows Millennium Edition, Windows NT 3.51, Windows NT 4.0, Windows 2000 ?? Windows XP ?? ??? differentiates ???

??????????

?? ???? ????? ?? ?? ???? ??? ?? ??????? ???? ?? ????? C++ ???????????? ???

Windows ??????? ????

???????? ?????? ?? ???? ??? ?? ?????? ?? ?? ??? ?? ?? ???????? ????, ????? ???? ?????? ??:

?? ?????? ?? ??????? ?????? ?????? ?? ??????? ????
Windows 95Windows 98Windows MEWindows NT 4Windows 2000:Windows XP
PlatformID111222
????? ???????444455
?? ???????01090001

???::?????? ?? ???? ??? ??? 32-??? Windows ?? ??? ????????? ?? ??? ???? ???? ??, ? ? Visual Studio .NET ?? .NET Framework ?? ??????? ?? Windows 95 ?? Windows NT 3.51?

???????? ?????? ??????? ??????? ????

???? ?? OperatingSystem ???? ?? ??? ???? ?? ????? ?? ??? ???? ?? ??? ??????? ???????? ?????? ??????? ?? ????? ??:
System::OperatingSystem *osInfo = System::Environment::OSVersion;
				

??????????? ID ?? ????????

???? ??? ?? ???????? ?????? ??????? ??????? ????????? ??? ????????? ???? ?? ??? ???-?? ?????????? ?? ??? ????? ?? ???, ???? ????? ?? ?? ??? ??? ??? ?? ?? ????? ???? ??? ?? ??? ??PlatformID.PlatformID??? ?? ??OperatingSystem????? ?? enumerated ??? "Win32Windows" ?? ???? ???????? ?????? ?? Windows 9x?????? ???????? ?? ??? "WinNT" Windows NT ?????? ?? ??? ???????? ?????? ?? ????? ???? ???
switch(osInfo->Platform)
    {
        case System::PlatformID::Win32Windows:         
            {
             //code to determine specific Windows 9x version
            }

       case System::PlatformID::Win32NT:
           {
              //code to determine specific Windows NT version
           }
       
     }
				

??????? Windows 9 ????????? ????x???????

??? Windows 9 ???? ?? ??? ??????????? ????????? ???? ??? ??x, ???? ?? ??? ??????? ?? ???? ?? ???????? ??????? ??????? ?? ???????? ???? ?? ??? ?? ??? ??? ????? ??? ????????? ???? ?? ???
//platform is win9x
case System::PlatformID::Win32Windows:
     
switch (osInfo->Version->Minor)
    {
        case 0:
            Console::WriteLine ("Windows 95");
            break;
        case 10:
            if(osInfo->Version->Revision.ToString()=="2222A")
                Console::WriteLine("Windows 98 Second Edition");
            else
                 Console::WriteLine("Windows 98");
                 break;
        case  90:
                 Console::WriteLine("Windows ME");
                 break;
     }break;
     

				

??????? Windows NT ??????? ?? ????????

??? Windows NT ???? ?? ??? ??????????? ?? ???? ???, ???? ?? ??? ??????? ??????? ??????? ?? ???????? ???? ?? ??? ???????? ???? ?? ?? ???? ???:
//platform is NT
case System::PlatformID::Win32NT:

switch(osInfo->Version->Major)
    {
        case 3:
            Console::WriteLine("Windows NT 3.51");
            break;
        case 4:
            Console::WriteLine("Windows NT 4.0");
            break;
        case 5:
            if (osInfo->Version->Minor==0) 
                Console::WriteLine("Windows 2000");
            else
                Console::WriteLine("Windows XP");
                break;
     }break;
				

?????? ??? ??? ??

????? ????? ?? ???? ?????? ?? ?? ?? ?? ??????????? demonstrate ???? ?? ??? ??? ??????? ???????? ??? ?? ???? ????
  1. Visual Studio .NET, ??? ?? ??? C++ ???????? ????????? ??? ?????determine0S. ?? ??? ?????? "hello ?????" ????????? ????? ??? ???? ?????? Explorer ????? ??? ???-????? ???? ??? ?????? ??? DetermineOS.cpp ??????
  2. ??? DetermineOS.cpp ??? ??? ?? ??????
  3. ????? ??? ???????:
    #include "stdafx.h"
    
    #using <mscorlib.dll>
    
    using namespace System;
    
    // This is the entry point for this application
    #ifdef _UNICODE
    int wmain(void)
    #else
    int main(void)
    #endif
    {
       //get OperatingSystem info from the system namespace
       System::OperatingSystem *osInfo = System::Environment::OSVersion;
    
       //is the platform win9x or NT
       switch(osInfo->Platform)
       {
          //platform is win9x
          case System::PlatformID::Win32Windows:
        
             switch (osInfo->Version->Minor)
             {
                  case 0:
                     Console::WriteLine ("Windows 95");
                  break;
                  case 10:
                  if(osInfo->Version->Revision.ToString() == "2222A")
                     Console::WriteLine("Windows 98 Second Edition");
                  else
                     Console::WriteLine("Windows 98");
                  break;
                  case  90:
                     Console::WriteLine("Windows ME");
                  break;
             }
             break;
    			
             //platform is NT
             case System::PlatformID::Win32NT:
    
                switch(osInfo->Version->Major)
                {
                   case 3:
                      Console::WriteLine("Windows NT 3.51");
                   break;
                   case 4:
                      Console::WriteLine("Windows NT 4.0");
                   break;
                   case 5:
                   if (osInfo->Version->Minor==0) 
                      Console::WriteLine("Windows 2000");
                   else
                      Console::WriteLine("Windows XP");
                   break;
                }break;
       }
    
       Console::ReadLine();
       return 0;
    }
    					
  4. ????????? ?? ????? ?? ??? CTRL + F5 ?????? ??? ???? ?? Windows ?? ??????? ?????? ????? ??? ????????? ???? ???? ???

??????

????? C++ .NET ?? ???? ??? ???? ??????? ??????? ?? ??? ????? Microsoft Usenet ?????? ???? ?? Microsoft ??? ???? ?? ????:
Microsoft.public.dotnet.languages.VC (http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?query=Microsoft.public.dotnet.languages.vc+&dg=&cat=en_US_d02fc761-3f6b-402c-82f6-ba1a8875c1a7&lang=en&cr=&pt=&catlist=&dglist=&ptlist=&exp=&sloc=en-us)

????? C++ .NET (2002) ?????? ?????? (http://support.microsoft.com/default.aspx?xmlid=fh%3BEN-US%3Bvcnet)

???? ???? ???? ??:
  • Microsoft Visual C++ .NET 2002 Standard Edition
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft Visual C++ 2005 Express Edition
??????: 
kbhowtomaster kbnewsgrouplink kbmt KB307394 KbMthi
???? ?????? ???????????? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:307394  (http://support.microsoft.com/kb/307394/en-us/ )