<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    天空是藍色的

    做好軟件為中國 #gcc -c helloworld.c -o helloworld.o //編譯目標文件 #gcc helloworld.o -o helloworld //編譯成可執行exe #helloworld //運行exe
    數據加載中……
    C語言取得windows操作系統信息

    #include <windows.h>
    #include <stdio.h>

    #define BUFSIZE 80

    BOOL GetOSVer(char *szOSName);

    int main()
    {
     char szname[MAX_PATH];
     memset(szname,0,MAX_PATH);

     BOOL bRet = GetOSVer(szname);

     printf("Your Os version is %s\n ",szname);

     return 0;
    }

    BOOL GetOSVer(char *szname)
    {
       OSVERSIONINFOEX osvi;
       BOOL bOsVersionInfoEx;

       // Try calling GetVersionEx using the OSVERSIONINFOEX structure.
       // If that fails, try using the OSVERSIONINFO structure.

       ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
       osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

       if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
       {
          osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
          if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
             return FALSE;
       }

       switch (osvi.dwPlatformId)
       {
          // Test for the Windows NT product family.
          case VER_PLATFORM_WIN32_NT:

             // Test for the specific product family.
             if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
                strcpy(szname,"Microsoft Windows Server 2003 family, ");
      

             if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
                strcpy(szname,"Microsoft Windows XP ");

             if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
                strcpy(szname,"Microsoft Windows 2000 ");

             if ( osvi.dwMajorVersion <= 4 )
                strcpy(szname,"Microsoft Windows NT ");

             // Test for specific product on Windows NT 4.0 SP6 and later.
             if( bOsVersionInfoEx )
             {
                // Test for the workstation type.
                if ( osvi.wProductType == VER_NT_WORKSTATION )
                {
                   if( osvi.dwMajorVersion == 4 )
                      strcat(szname, "Workstation 4.0 " );
                   else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
                      strcat(szname, "Home Edition " );
                   else
                      strcat(szname,  "Professional " );
                }
               
                // Test for the server type.
                else if ( osvi.wProductType == VER_NT_SERVER )
                {
                   if( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
                   {
                      if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
                         strcat(szname, "Datacenter Edition " );
                      else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                         strcat(szname, "Enterprise Edition " );
                      else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
                         strcat(szname, "Web Edition " );
                      else
                         strcat(szname, "Standard Edition " );
                   }

                   else if( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
                   {
                      if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
                         strcat(szname, "Datacenter Server " );
                      else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                         strcat(szname, "Advanced Server " );
                      else
                         strcat(szname, "Server " );
                   }

                   else  // Windows NT 4.0
                   {
                      if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                         strcat(szname,"Server 4.0, Enterprise Edition " );
                      else
                         strcat(szname, "Server 4.0 " );
                   }
                }
             }
             else  // Test for specific product on Windows NT 4.0 SP5 and earlier
             {
                HKEY hKey;
                char szProductType[BUFSIZE];
                DWORD dwBufLen=BUFSIZE;
                LONG lRet;

                lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
                   "SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
                   0, KEY_QUERY_VALUE, &hKey );
                if( lRet != ERROR_SUCCESS )
                   return FALSE;

                lRet = RegQueryValueEx( hKey, "ProductType", NULL, NULL,
                   (LPBYTE) szProductType, &dwBufLen);
                if( (lRet != ERROR_SUCCESS) || (dwBufLen > BUFSIZE) )
                   return FALSE;

                RegCloseKey( hKey );

                if ( lstrcmpi( "WINNT", szProductType) == 0 )
                   strcat(szname, "Workstation " );
                if ( lstrcmpi( "LANMANNT", szProductType) == 0 )
                   strcat(szname, "Server " );
                if ( lstrcmpi( "SERVERNT", szProductType) == 0 )
                   strcat(szname,"Advanced Server " );

                printf( "%d.%d ", osvi.dwMajorVersion, osvi.dwMinorVersion );
             }

          // Display service pack (if any) and build number.

             if( osvi.dwMajorVersion == 4 &&
                 lstrcmpi( osvi.szCSDVersion, "Service Pack 6" ) == 0 )
             {
                HKEY hKey;
                LONG lRet;

                // Test for SP6 versus SP6a.
                lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
                   "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
                   0, KEY_QUERY_VALUE, &hKey );
                if( lRet == ERROR_SUCCESS )
                   printf( "Service Pack 6a (Build %d)\n", osvi.dwBuildNumber & 0xFFFF );        
                else // Windows NT 4.0 prior to SP6a
                {
                   printf( "%s (Build %d)\n",
                      osvi.szCSDVersion,
                      osvi.dwBuildNumber & 0xFFFF);
                }

                RegCloseKey( hKey );
             }
             else // Windows NT 3.51 and earlier or Windows 2000 and later
             {
                printf( "%s (Build %d)\n",
                   osvi.szCSDVersion,
                   osvi.dwBuildNumber & 0xFFFF);
             }


             break;

          // Test for the Windows 95 product family.
          case VER_PLATFORM_WIN32_WINDOWS:

             if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
             {
                 strcpy(szname,"Microsoft Windows 95 ");
                 if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' )
                    strcat(szname,"OSR2 " );
             }

             if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
             {
                 strcpy(szname,"Microsoft Windows 98 ");
                 if ( osvi.szCSDVersion[1] == 'A' )
                    strcat(szname,"SE " );
             }

             if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
             {
                 strcpy(szname,"Microsoft Windows Millennium Edition\n");
             }
             break;

          case VER_PLATFORM_WIN32s:

             printf ("Microsoft Win32s\n");
             break;
       }
      // getchar();
       return TRUE;
    }


     

    posted on 2006-02-14 14:53 bluesky 閱讀(2713) 評論(0)  編輯  收藏 所屬分類: C/C++

    主站蜘蛛池模板: 亚洲高清在线视频| 免费的一级片网站| 精品亚洲永久免费精品| 亚洲人成综合在线播放| 天天影院成人免费观看| 日木av无码专区亚洲av毛片| 亚洲精品免费观看| 亚洲人成在线观看| 亚洲精品免费在线视频| 亚洲最大中文字幕| 91视频国产免费| 免费一级毛片在线播放| 亚洲精品无码国产| 国产在线观看xxxx免费| 亚洲av日韩av无码| 午夜不卡久久精品无码免费| 亚洲精品线在线观看| 18女人水真多免费高清毛片| 亚洲人成在线中文字幕| 日韩免费a级在线观看| 亚洲精品宾馆在线精品酒店| 亚洲成aⅴ人片久青草影院| 一个人晚上在线观看的免费视频| 亚洲欭美日韩颜射在线二| 特级无码毛片免费视频尤物| 亚洲国色天香视频| 国产精品极品美女免费观看| 特黄特色的大片观看免费视频| 亚洲国产另类久久久精品黑人| 四虎成人精品永久免费AV| 亚洲日韩一区二区三区| 日韩吃奶摸下AA片免费观看| 成人毛片免费播放| 午夜一区二区免费视频| 国产亚洲精品自在线观看| 久久亚洲综合色一区二区三区| 亚洲中文字幕久久精品无码APP| 亚洲国产精品成人午夜在线观看 | 亚洲精品无码久久久| 热99RE久久精品这里都是精品免费| 亚洲精品福利网站|