[轉貼]如何測知目前使用OS名稱

有關Delphi 的語法, 程式, 等
回覆文章
頭像
tim
文章: 1380
註冊時間: 2008年 11月 26日, 00:49

[轉貼]如何測知目前使用OS名稱

文章 tim »

http://delphi.ktop.com.tw/topic.asp?TOPIC_ID=37142

代碼: 選擇全部

     
    procedure Tform1.formCreate(Sender: TObject); 
    Var 
     
    s:string; 
    osvi:TOSVERSIONINFO ; 
     
     
    begin 
     
     
     
     
       osvi.dwOSVersionInfoSize := sizeof(OSVERSIONINFO); 
     
       if  GetVersionEx(osvi)=FALSE then 
       begin 
            exit; 
       end; 
     
     
       if osvi.dwPlatformId=VER_PLATform_WIN32_NT then 
       begin 
         if ( osvi.dwMajorVersion = 5) AND (osvi.dwMinorVersion = 2 ) then 
                s:='Microsoft Windows Server 2003 family,' 
         else 
         if ( osvi.dwMajorVersion = 5) AND (osvi.dwMinorVersion = 1 ) then 
                s:='Microsoft Windows XP ' 
         else 
         if ( osvi.dwMajorVersion = 5) AND (osvi.dwMinorVersion = 0 ) then 
                s:='Microsoft Windows 2000 ' 
         else 
         if  osvi.dwMajorVersion <= 4 then 
                s:='Microsoft Windows NT '; 
     
       end 
       else 
       if osvi.dwPlatformId=VER_PLATform_WIN32_WINDOWS then 
       begin 
            if (osvi.dwMajorVersion = 4) and (osvi.dwMinorVersion = 0) then 
             begin 
                 s:='Microsoft Windows 95 '; 
                 if ( osvi.szCSDVersion[1] = 'C') or (osvi.szCSDVersion[1] = 'B' ) then 
                    s:=s+' OSR2 '; 
             end 
             else 
             if (osvi.dwMajorVersion = 4) and ( osvi.dwMinorVersion = 10) then 
             begin 
                 s:='Microsoft Windows 98  '; 
                 if  osvi.szCSDVersion[1] = 'A' then 
                    s:=s+'SE '; 
             end 
             else 
             if (osvi.dwMajorVersion = 4) and (osvi.dwMinorVersion = 90) then 
                 s:=s+'Microsoft Windows Millennium Edition'; 
     
     
       end 
       else 
       if osvi.dwPlatformId=VER_PLATform_WIN32s then 
       begin 
          s:= 'Microsoft Win32s'; 
       end; 
     
     
       Showmessage(s); 
     
     
    end; 
多多留言, 整理文章, 把經驗累積下來.....
回覆文章