source: Include/Classes/System/OperatingSystem.ab@ 164

Last change on this file since 164 was 142, checked in by イグトランス (egtra), 18 years ago

Environment, OperatingSystem, Versionの追加、Unicode対応修正ほか

File size: 2.0 KB
RevLine 
[142]1' System/OperatingSystem.ab
2
3#require <Classes/System/Version.ab>
4
5Class OperatingSystem
6 ' Inherits ICloneable', ISerializable
7Public
8 ' Constractor
9 Sub OperatingSystem(platform As PlatformID, version As Version)
10 pf = platform
11 ver = version
12 sp = ""
13 End Sub
14
15 Sub OperatingSystem(vi As OSVERSIONINFOA) As OperatingSystem
16 pf = vi.dwPlatformId As PlatformID,
17 ver = New Version(vi.dwMajorVersion, vi.MinorVersion, vi.BuildNumber)
18 sp = vi.szCSDVersion
19 End Sub
20
21 Sub OperatingSystem(vi As OSVERSIONINFOW) As OperatingSystem
22 pf = vi.dwPlatformId As PlatformID,
23 ver = New Version(vi.dwMajorVersion, vi.MinorVersion, vi.BuildNumber)
24 sp = vi.szCSDVersion
25 End Sub
26
27 ' Properties
28 Const Function Platform() As PlatformID
29 Return pf
30 End Function
31
32 Const Function Version() As Version
33 Return ver
34 End Function
35
36 Const Function ServicePack() As String
37 Return sp
38 End Function
39
40 Const Function VersionString() As String
41 Select Case pf
42 Case PlatformID.Win32S
43 VersionString = "Microsoft Win32S "
44 Case PlatformID.Win32Windows
45 VersionString = "Microsoft Windows "
46 Case PlatformID.Win32NT
47 VersionString = "Microsoft Windows NT "
48 Case PlatformID.WinCE
49 VersionString = "Microsoft Windows CE "
50 Case PlatformID.Unix
51 VersionString = "<unknown> "
52 End Select
53 VersionString = VersionString + ver.ToString
54 If String.IsNullOrEmpty(sp) <> False Then
55 VersionString = VersionString + " " + sp
56 End If
57 End Function
58
59 ' Methods
60 Override Function ToString() As String
61 Return VersionString
62 End Function
63
64 Override Function GetHashCode() As Long
65 Return pf.GetHashCode Xor ver.GetHashCode Xor sp.GetHashCode
66 End Function
67
68Private
69 pf As PlatformID
70 ver As Version
71 sp As String
72End Class
73
74Enum PlatformID
75 Win32S = VER_PLATFORM_WIN32s '0
76 Win32Windows = VER_PLATFORM_WIN32_WINDOWS '1
77 Win32NT = VER_PLATFORM_WIN32_NT '2
78 WinCE = VER_PLATFORM_WIN32_CE '3
79 Unix = 4
80End Enum
Note: See TracBrowser for help on using the repository browser.