Changeset 258 for Include/Classes/System/Environment.ab
- Timestamp:
- May 21, 2007, 1:03:21 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/Environment.ab
r237 r258 3 3 #require <api_psapi.sbp> 4 4 #require <Classes/System/OperatingSystem.ab> 5 6 Namespace System 7 8 Namespace Detail 9 TypeDef PFNGetProcessMemoryInfo = *Function(Process As HANDLE, ByRef mc As PROCESS_MEMORY_COUNTERS, cb As DWord) As BOOL 10 End Namespace 5 11 6 12 Class Environment … … 45 51 End Function 46 52 47 ' MachineName 53 Static Function MachineName() As String 54 If Object.ReferenceEquals(machineName, Nothing) Then 55 Dim buf[MAX_COMPUTERNAME_LENGTH] As TCHAR 56 Dim len = (MAX_COMPUTERNAME_LENGTH + 1) As DWord 57 GetComputerName(buf, len) 58 machineName = New String(buf, len As Long) 59 End If 60 Return machineName 61 End Function 48 62 49 63 Static Function NewLine() As String … … 90 104 ' UserInteractive 91 105 92 ' UserName 106 Static Function UserName() As String 107 If Object.ReferenceEquals(userName, Nothing) Then 108 Dim buf[UNLEN] As TCHAR 109 Dim len = (UNLEN + 1) As DWord 110 GetUserName(buf, len) 111 userName = New String(buf, len As Long) 112 End If 113 Return userName 114 End Function 93 115 94 116 ' Version 95 117 118 Public 119 'NTでしか使用できない仕様 96 120 Static Function WorkingSet() As Int64 97 TypeDef PFNGetProcessMemoryInfo = *Function(Process As HANDLE, ByRef mc As PROCESS_MEMORY_COUNTERS, cb As DWord) As BOOL98 Dim pGetProcessMemoryInfo As PFNGetProcessMemoryInfo99 121 Dim hmodPSAPI = LoadLibrary("PSAPI.DLL") 100 122 If hmodPSAPI = 0 Then Return 0 101 pGetProcessMemoryInfo = GetProcAddress(hmodPSAPI, ToMBStr("GetProcessMemoryInfo")) AsPFNGetProcessMemoryInfo123 Dim pGetProcessMemoryInfo = GetProcAddress(hmodPSAPI, ToMBStr("GetProcessMemoryInfo")) As Detail.PFNGetProcessMemoryInfo 102 124 If pGetProcessMemoryInfo <> 0 Then 103 125 Dim mc As PROCESS_MEMORY_COUNTERS … … 136 158 ' GetEnvironmentVariables 137 159 160 Static Function GetFolderPath(f As Environment_SpecialFolder) As String 161 ' If ... Then 162 ' Throw New ArgumentException 163 ' End If 164 Dim x As Long 165 x = f 166 Return ActiveBasic.Windows.GetFolderPath(x) 167 End Function 168 138 169 ' GetLogicalDrives 139 170 … … 143 174 Static cmdLine = Nothing As String 144 175 Static exitCode = 0 As Long 176 Static machineName = Nothing As String 145 177 Static osVer = Nothing As OperatingSystem 146 178 Static processorCount = 0 As Long 147 179 Static sysDir = Nothing As String 180 Static userName = Nothing As String 148 181 End Class 182 183 Enum Environment_SpecialFolder 184 Desktop = CSIDL_DESKTOP 185 Programs = CSIDL_PROGRAMS 186 Personal = CSIDL_PERSONAL 187 MyDocuments = CSIDL_PERSONAL 188 Favorites = CSIDL_FAVORITES 189 Startup = CSIDL_STARTUP 190 Recent = CSIDL_RECENT 191 SendTo = CSIDL_SENDTO 192 StartMenu = CSIDL_STARTMENU 193 MyMusic = CSIDL_MYMUSIC 194 DesktopDirectory = CSIDL_DESKTOPDIRECTORY 195 MyComputer = CSIDL_DRIVES 196 Templates = CSIDL_TEMPLATES 197 ApplicationData = CSIDL_APPDATA '4.71 198 LocalApplicationData = CSIDL_LOCAL_APPDATA 199 InternetCache = CSIDL_INTERNET_CACHE 200 Cookies = CSIDL_COOKIES 201 History = CSIDL_HISTORY 202 CommonApplicationData = CSIDL_COMMON_APPDATA '5.0 203 System = CSIDL_SYSTEM 204 CommonProgramFiles = CSIDL_PROGRAM_FILES 205 ProgramFiles = CSIDL_PROGRAM_FILES 206 MyPictures = CSIDL_MYPICTURES 207 End Enum 208 209 210 End Namespace 'System
Note:
See TracChangeset
for help on using the changeset viewer.