Changeset 497 for trunk/Include/Classes/System/Environment.ab
- Timestamp:
- Mar 28, 2008, 5:43:34 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/System/Environment.ab
r427 r497 20 20 Static Function CommandLine() As String 21 21 If Object.ReferenceEquals(cmdLine, Nothing) Then 22 #ifdef __STRING_IS_NOT_UNICODE 22 #ifdef UNICODE 23 cmdLine = New String(GetCommandLineW()) 24 #else 23 25 cmdLine = New String(GetCommandLineA()) 24 #else25 cmdLine = New String(GetCommandLineW())26 26 #endif 27 27 End If … … 120 120 Public 121 121 'NTでしか使用できない仕様 122 Static Function WorkingSet() As Int64122 Static Function WorkingSet() As SIZE_T 123 123 Dim hmodPSAPI = LoadLibrary("PSAPI.DLL") 124 124 If hmodPSAPI = 0 Then Return 0 … … 141 141 142 142 Static Function ExpandEnvironmentVariables(s As String) As String 143 If ActiveBasic.IsNothing(s) Then 144 Throw New ArgumentNullException("s") 145 End If 143 146 Dim src = ToTCStr(s) 144 147 Dim size = ExpandEnvironmentStrings(src, 0, 0) 145 Dim dst = GC_malloc_atomic(SizeOf (TCHAR) * size) As PTSTR 146 ExpandEnvironmentStrings(src, dst, size) 147 ExpandEnvironmentVariables = New String(dst, size - 1) 148 Dim dst = New Text.StringBuilder 149 dst.Length = size As Long 150 ExpandEnvironmentStrings(src, StrPtr(dst), size) 151 dst.Length = (size - 1) As Long 152 ExpandEnvironmentVariables = dst.ToString 148 153 End Function 149 154 … … 155 160 156 161 Static Function GetEnvironmentVariable(variable As String) As String 162 If ActiveBasic.IsNothing(variable) Then 163 Throw New ArgumentNullException("variable") 164 End If 157 165 Dim tcsVariable = ToTCStr(variable) 158 166 Dim size = _System_GetEnvironmentVariable(tcsVariable, 0, 0) 159 Dim p = GC_malloc_atomic(SizeOf (TCHAR) * size) As PTSTR 160 Dim len = _System_GetEnvironmentVariable(tcsVariable, p, size) 161 GetEnvironmentVariable = New String(p, len As Long) 167 Dim buf = New Text.StringBuilder 168 buf.Length = size As Long 169 buf.Length = _System_GetEnvironmentVariable(tcsVariable, StrPtr(buf), size) 170 GetEnvironmentVariable = buf.ToString 162 171 End Function 163 172 … … 176 185 177 186 Static Sub SetEnvironmentVariable(variable As String, value As String) 187 If ActiveBasic.IsNothing(variable) Then 188 Throw New ArgumentNullException("variable") 189 End If 178 190 _System_SetEnvironmentVariable(ToTCStr(variable), ToTCStr(value)) 179 191 End Sub
Note:
See TracChangeset
for help on using the changeset viewer.