Changeset 237 for Include/Classes/System/Environment.ab
- Timestamp:
- May 7, 2007, 4:22:52 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/Environment.ab
r233 r237 1 1 ' System/Environment.ab 2 2 3 #require <api_psapi.sbp> 3 4 #require <Classes/System/OperatingSystem.ab> 4 5 … … 8 9 9 10 Static Function CommandLine() As String 10 If cmdLine = NothingThen11 If Object.ReferenceEquals(cmdLine, Nothing) Then 11 12 #ifdef __STRING_IS_NOT_UNICODE 12 13 cmdLine = New String(GetCommandLineA()) … … 51 52 52 53 Static Function OSVersion() As OperatingSystem 53 If osVer = NothingThen54 If Object.ReferenceEquals(osVer, Nothing) Then 54 55 Dim vi As OSVERSIONINFO 55 56 GetVersionEx(vi) … … 71 72 72 73 Static Function SystemDirectory() As String 73 If sysDir = NothingThen74 If Object.ReferenceEquals(sysDir, Nothing) Then 74 75 Dim size = GetSystemDirectory(0, 0) 75 Dim p = _System_malloc(SizeOf (TCHAR) * size) 76 Dim len = GetSystemDirectory( size, p)76 Dim p = _System_malloc(SizeOf (TCHAR) * size) As PTSTR 77 Dim len = GetSystemDirectory(p, size) 77 78 sysDir = New String(p, len As Long) 78 79 _System_free(p) … … 94 95 95 96 Static Function WorkingSet() As Int64 96 Dim pGetProcessMemoryInfo As *Function(Process As HANDLE, ByRef mc As PPROCESS_MEMORY_COUNTERS, cb As DWord) As BOOL 97 TypeDef PFNGetProcessMemoryInfo = *Function(Process As HANDLE, ByRef mc As PROCESS_MEMORY_COUNTERS, cb As DWord) As BOOL 98 Dim pGetProcessMemoryInfo As PFNGetProcessMemoryInfo 97 99 Dim hmodPSAPI = LoadLibrary("PSAPI.DLL") 98 100 If hmodPSAPI = 0 Then Return 0 99 pGetProcessMemoryInfo = GetProcAddress(hmodPSAPI, ToMBStr("GetProcessMemoryInfo")) 101 pGetProcessMemoryInfo = GetProcAddress(hmodPSAPI, ToMBStr("GetProcessMemoryInfo")) As PFNGetProcessMemoryInfo 100 102 If pGetProcessMemoryInfo <> 0 Then 101 Dim mc As P PROCESS_MEMORY_COUNTERS103 Dim mc As PROCESS_MEMORY_COUNTERS 102 104 If pGetProcessMemoryInfo(GetCurrentProcess(), mc, Len (mc)) <> FALSE Then 103 105 WorkingSet = mc.WorkingSetSize 106 104 107 End If 105 108 End If … … 117 120 Dim src = ToTCStr(s) 118 121 Dim size = ExpandEnvironmentStrings(src, 0, 0) 119 Dim dst = _System_malloc(SizeOf (TCHAR) * size) 122 Dim dst = _System_malloc(SizeOf (TCHAR) * size) As PTSTR 120 123 ExpandEnvironmentStrings(src, dst, size) 121 124 ExpandEnvironmentVariables = New String(dst, size - 1)
Note:
See TracChangeset
for help on using the changeset viewer.