Ignore:
Timestamp:
Mar 28, 2008, 5:43:34 PM (16 years ago)
Author:
イグトランス (egtra)
Message:

インクルードガードとその他不要な前処理定義などの削除

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Include/Classes/System/Environment.ab

    r427 r497  
    2020    Static Function CommandLine() As String
    2121        If Object.ReferenceEquals(cmdLine, Nothing) Then
    22 #ifdef __STRING_IS_NOT_UNICODE
     22#ifdef UNICODE
     23            cmdLine = New String(GetCommandLineW())
     24#else
    2325            cmdLine = New String(GetCommandLineA())
    24 #else
    25             cmdLine = New String(GetCommandLineW())
    2626#endif
    2727        End If
     
    120120Public
    121121    'NTでしか使用できない仕様
    122     Static Function WorkingSet() As Int64
     122    Static Function WorkingSet() As SIZE_T
    123123        Dim hmodPSAPI = LoadLibrary("PSAPI.DLL")
    124124        If hmodPSAPI = 0 Then Return 0
     
    141141
    142142    Static Function ExpandEnvironmentVariables(s As String) As String
     143        If ActiveBasic.IsNothing(s) Then
     144            Throw New ArgumentNullException("s")
     145        End If
    143146        Dim src = ToTCStr(s)
    144147        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
    148153    End Function
    149154
     
    155160
    156161    Static Function GetEnvironmentVariable(variable As String) As String
     162        If ActiveBasic.IsNothing(variable) Then
     163            Throw New ArgumentNullException("variable")
     164        End If
    157165        Dim tcsVariable = ToTCStr(variable)
    158166        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
    162171    End Function
    163172
     
    176185
    177186    Static Sub SetEnvironmentVariable(variable As String, value As String)
     187        If ActiveBasic.IsNothing(variable) Then
     188            Throw New ArgumentNullException("variable")
     189        End If
    178190        _System_SetEnvironmentVariable(ToTCStr(variable), ToTCStr(value))
    179191    End Sub
Note: See TracChangeset for help on using the changeset viewer.