OSバージョン取得 <TOP>
GetVersionEx OSのバージョンを取得
各OS上での実行結果
'================================================================ '= OSのバージョンを取得 '= (GetVersionEx2.bas)
'= ※Windows 8 まで '================================================================ #include "Windows.bi" Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 End Type #define VER_PLATFORM_WIN32_WINDOWS 1 'Windows9x #define VER_PLATFORM_WIN32_NT 2 'WindowsNT、2000、XP、Vista、7 ' オペレーティングシステムの種類やバージョンに関する情報を取得 Declare Function Api_GetVersionEx& Lib "kernel32" Alias "GetVersionExA" ( lpVersionInformation As OSVERSIONINFO ) Var Shared Text1 As Object Var Shared Button1 As Object Text1.Attach GetDlgItem("Text1") : Text1.SetFontSize 14 Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14 '================================================================ '= '================================================================ Declare Function GetWinPlatform() As String Function GetWinPlatform() As String Var strPlatForm As String Var osvi As OSVERSIONINFO Var Ret As Long osvi.dwOSVersionInfoSize = Len(osvi) Ret = Api_GetVersionEx(osvi) strPlatForm = "未知のオペレーティングシステム" If osvi.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then If osvi.dwMinorVersion = 0 Then strPlatForm = "Windows 95" If osvi.szCSDVersion = "B" Then strPlatForm = strPlatForm & " OSR2" Else strPlatForm = strPlatForm & Left$(osvi.szCSDVersion, 2) End If Else If osvi.dwMinorVersion = 10 Then strPlatForm = "Windows 98" If osvi.szCSDVersion = "A" Then strPlatForm = strPlatForm & " SE" End If Else If osvi.dwMinorVersion = 90 Then strPlatForm = "Windows ME" Else strPlatForm = "Win 32s" End If Else If osvi.dwPlatformId = VER_PLATFORM_WIN32_NT Then If osvi.dwMajorVersion = 4 Then strPlatForm = "Windows NT" Else If osvi.dwMajorVersion = 5 Then If osvi.dwMinorVersion = 0 Then strPlatForm = "Windows 2000" Else If osvi.dwMinorVersion = 1 Then strPlatForm = "Windows XP" Else If osvi.dwMinorVersion = 2 Then strPlatForm = "Windows 2003" End If Else If osvi.dwMajorVersion = 6 Then If osvi.dwMinorVersion = 0 Then strPlatForm = "Windows Vista" Else If osvi.dwMinorVersion = 1 Then strPlatForm = "Windows 7" Else If osvi.dwMinorVersion = 2 Then strPlatForm = "Windows 8" ' Else If osvi.dwMinorVersion = 3 Then ' strPlatForm = "Windows 8.1" End If End If End If GetWinPlatform = strPlatForm End Function '================================================================ '= '================================================================ Declare Sub Button1_on edecl () Sub Button1_on() Text1.SetWindowText GetWinPlatform End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End