Q&A

  • 현재 사용중인 OS명 알아내기~
내 컴퓨터에 마우스 오른쪽 버튼을 누르고 등록정보를 열면

오른쪽 위에                             시스템:
                                             Microsoft Windows 2000
                                             5.00.2195  이하 쭉~~~~
이라고 뜨는데

버젼과 빌드는 구하는 예가 많아서 알겠는데,
현재 OS가 Microsoft Windows 2000이라는 이름은 어떻게 알 수 있습니까?

너무너무 급합니다.. 자세히 알려주세요~ ^^&
                
2  COMMENTS
  • Profile
    홍성락 2002.04.04 03:17

    hsr//////////////////////////////////////////////////////////////
    unit Unit1;

    interface

    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;
    type
      TOSVersion = (osUnknown, os95, os95OSR2, os98, os98SE, osNT3, osNT4, os2K, osME, osXP);
    type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;
      function GetOS :TOSVersion;
    implementation

    {$R *.DFM}
    function GetOS;
    var
      OS :TOSVersionInfo;
    begin
      ZeroMemory(@OS,SizeOf(OS));
      OS.dwOSVersionInfoSize:=SizeOf(OS);
      GetVersionEx(OS);
      Result:=osUnknown;
      if OS.dwPlatformId=VER_PLATFORM_WIN32_NT then begin
        case OS.dwMajorVersion of
          3: Result:=osNT3;
          4: Result:=osNT4;
          5: Result:=os2K;
        end;
        if (OS.dwMajorVersion=5) and (OS.dwMinorVersion=1) then
          Result:=osXP;
      end else begin
        if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=0) then begin
          Result:=os95;
          if (Trim(OS.szCSDVersion)='B') then
            Result:=os95OSR2;
        end else
          if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=10) then begin
            Result:=os98;
            if (Trim(OS.szCSDVersion)='A') then
              Result:=os98SE;
          end else
            if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=90) then
              Result:=osME;
      end;
    end;

    procedure TForm1.Button1Click(Sender: TObject);
    var
        OSVersion :string;
    begin
      case GetOS of
        os95, os95OSR2 : OSVersion:='Windows 95';
        os98, os98SE   : OSVersion:='Windows 98';
        osME           : OSVersion:='Windows Millenium Edition';
        osNT3, osNT4   : OSVersion:='Windows NT';
        os2K           : OSVersion:='Windows 2000';
        osXP           : OSVersion:='Windows XP';
      end;
      showmessage(OSVersion);
    end;

    end.
  • Profile
    우영범 2002.04.04 02:56
    msdn에 있는  샘플입니다.
    델파이로 변환해서 사용하십시오.

    BOOL DisplaySystemVersion()
    {
       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)) )
       {
          // If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.
          osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
          if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
             return FALSE;
       }

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

          // Test for the product.

             if ( osvi.dwMajorVersion <= 4 )
                printf("Microsoft Windows NT ");

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


             if( bOsVersionInfoEx )  // Use information from GetVersionEx.
             {
             // Test for the workstation type.
                if ( osvi.wProductType == VER_NT_WORKSTATION )
                {
                   if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
                      printf ("Microsoft Windows XP ");

                   if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
                      printf ( "Home Edition " );
                   else
                      printf ( "Professional " );
                }

             // Test for the server type.
                else if ( osvi.wProductType == VER_NT_SERVER )
                {
                   if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
                      printf ("Microsoft Windows .NET ");

                   if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
                      printf ( "DataCenter Server " );
                   else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                      if( osvi.dwMajorVersion == 4 )
                         printf ("Advanced Server " );
                      else
                         printf ( "Enterprise Server " );
                   else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
                      printf ( "Web Server " );
                   else
                      printf ( "Server " );
                }
             }
             else   // Use the registry on early versions of Windows NT.
             {
                HKEY hKey;
                char szProductType[80];
                DWORD dwBufLen;

                RegOpenKeyEx( HKEY_LOCAL_MACHINE,
                   "SYSTEM\CurrentControlSet\Control\ProductOptions",
                   0, KEY_QUERY_VALUE, &hKey );
                RegQueryValueEx( hKey, "ProductType", NULL, NULL,
                   (LPBYTE) szProductType, &dwBufLen);
                RegCloseKey( hKey );
                if ( lstrcmpi( "WINNT", szProductType) == 0 )
                   printf( "Professional " );
                if ( lstrcmpi( "LANMANNT", szProductType) == 0 )
                   printf( "Server " );
                if ( lstrcmpi( "SERVERNT", szProductType) == 0 )
                   printf( "Advanced Server " );
             }

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

             if ( osvi.dwMajorVersion <= 4 )
             {
                printf ("version %d.%d %s (Build %d)n",
                   osvi.dwMajorVersion,
                   osvi.dwMinorVersion,
                   osvi.szCSDVersion,
                   osvi.dwBuildNumber & 0xFFFF);
             }
             else
             {
                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)
             {
                 printf ("Microsoft Windows 95 ");
                 if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' )
                    printf("OSR2 " );
             }

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

             if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
             {
                 printf ("Microsoft Windows Millennium Edition ");
             }
             break;
       }
       return TRUE;
    }