Changeset 268 for Include/Classes/System/Environment.ab
- Timestamp:
- Jun 2, 2007, 7:04:19 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/Environment.ab
r258 r268 3 3 #require <api_psapi.sbp> 4 4 #require <Classes/System/OperatingSystem.ab> 5 #require <Classes/ActiveBasic/Windows/index.ab> 6 7 Declare Function _System_SetEnvironmentVariable Lib "kernel32" Alias _FuncName_SetEnvironmentVariable (lpName As LPCTSTR, lpValue As LPTSTR) As BOOL 8 Declare Function _System_GetEnvironmentVariable Lib "kernel32" Alias _FuncName_GetEnvironmentVariable (lpName As PCTSTR, lpBuffer As PTSTR, nSize As DWord) As DWord 5 9 6 10 Namespace System … … 8 12 Namespace Detail 9 13 TypeDef PFNGetProcessMemoryInfo = *Function(Process As HANDLE, ByRef mc As PROCESS_MEMORY_COUNTERS, cb As DWord) As BOOL 14 15 Dim hasShutdownStarted As Boolean 10 16 End Namespace 11 17 … … 48 54 49 55 Static Function HasShutdownStarted() As Boolean 50 Return False56 Return Detail.hasShutdownStarted 51 57 End Function 52 58 … … 59 65 End If 60 66 Return machineName 61 End Function 67 End Function 62 68 63 69 Static Function NewLine() As String … … 92 98 sysDir = New String(p, len As Long) 93 99 _System_free(p) 94 End I F100 End If 95 101 Return sysDir 96 102 End Function … … 112 118 End If 113 119 Return userName 114 End Function 120 End Function 115 121 116 122 ' Version … … 126 132 If pGetProcessMemoryInfo(GetCurrentProcess(), mc, Len (mc)) <> FALSE Then 127 133 WorkingSet = mc.WorkingSetSize 128 129 134 End If 130 135 End If … … 154 159 ' GetCommandLineArgs 155 160 156 ' GetEnvironmentVariable 161 Static Function GetEnvironmentVariable(variable As String) As String 162 Dim tcsVariable = ToTCStr(variable) 163 Dim size = _System_GetEnvironmentVariable(tcsVariable, 0, 0) 164 Dim p = _System_malloc(SizeOf (TCHAR) * size) As PTSTR 165 Dim len = _System_GetEnvironmentVariable(tcsVariable, p, size) 166 GetEnvironmentVariable = New String(p, len As Long) 167 _System_free(p) 168 End Function 157 169 158 170 ' GetEnvironmentVariables … … 169 181 ' GetLogicalDrives 170 182 171 ' SetEnvironmentVariable 183 Static Sub SetEnvironmentVariable(variable As String, value As String) 184 _System_SetEnvironmentVariable(ToTCStr(variable), ToTCStr(value)) 185 End Sub 172 186 173 187 Private … … 207 221 End Enum 208 222 209 210 223 End Namespace 'System
Note:
See TracChangeset
for help on using the changeset viewer.