source: trunk/Include/Classes/System/OperatingSystem.ab@ 476

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

Prompt.sbp内を名前空間に入れた。EnvironmentのMachineName, UserName, GetFolderPathを実装。

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