Changeset 650 for trunk


Ignore:
Timestamp:
2008/10/29 03:50:24 (4 years ago)
Author:
NoWest
Message:

EnvironmentクラスにGetLogicalDrivesメソッドを追加しました。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/Classes/System/Environment.ab

    r603 r650  
    178178    End Function 
    179179 
    180     ' GetLogicalDrives 
     180    /*! 
     181    @brief  コンピュータの論理ドライブの名前を格納している文字列の配列を取得 
     182    @author NoWest 
     183    @date   2008/10/29 
     184    */ 
     185    Static Function GetLogicalDrives() As System.Collections.Generic.IList<String> 
     186        Dim ret = New System.Collections.Generic.List<String> 
     187 
     188        Dim buf As *Char 
     189        buf = GC_malloc( 256*SizeOf(Char) ) 
     190        Dim length = GetLogicalDriveStrings( 256, buf ) 
     191        If length > 256 Then  
     192            buf = realloc(buf, length * SizeOf(Char) ) 
     193            length = GetLogicalDriveStrings( length, buf ) 
     194        ElseIf length = 0 Then 
     195            Return ret 
     196        End If 
     197#ifdef UNICODE 
     198        Dim strbuf = New System.String( buf As PCWSTR, length As Long ) 
     199#else 
     200        Dim strbuf = New System.String( buf As PCSTR, length As Long ) 
     201#endif 
     202        Dim startpos = 0 As Long 
     203        length = 3 
     204        While True 
     205            ret.Add( strbuf.Substring(startpos,length) ) 
     206            startpos += (length+1) 
     207            If startpos > strbuf.Length()-1 Then Return ret 
     208        Wend 
     209    End Function 
    181210 
    182211    Static Sub SetEnvironmentVariable(variable As String, value As String) 
Note: See TracChangeset for help on using the changeset viewer.