Ignore:
Timestamp:
May 21, 2007, 1:03:21 AM (17 years ago)
Author:
イグトランス (egtra)
Message:

Prompt.sbp内を名前空間に入れた。EnvironmentのMachineName, UserName, GetFolderPathを実装。

File:
1 edited

Legend:

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

    r237 r258  
    33#require <api_psapi.sbp>
    44#require <Classes/System/OperatingSystem.ab>
     5
     6Namespace System
     7
     8Namespace Detail
     9    TypeDef PFNGetProcessMemoryInfo = *Function(Process As HANDLE, ByRef mc As PROCESS_MEMORY_COUNTERS, cb As DWord) As BOOL
     10End Namespace
    511
    612Class Environment
     
    4551    End Function
    4652
    47     ' MachineName
     53    Static Function MachineName() As String
     54        If Object.ReferenceEquals(machineName, Nothing) Then
     55            Dim buf[MAX_COMPUTERNAME_LENGTH] As TCHAR
     56            Dim len = (MAX_COMPUTERNAME_LENGTH + 1) As DWord
     57            GetComputerName(buf, len)
     58            machineName = New String(buf, len As Long)
     59        End If
     60        Return machineName
     61    End Function           
    4862
    4963    Static Function NewLine() As String
     
    90104    ' UserInteractive
    91105
    92     ' UserName
     106    Static Function UserName() As String
     107        If Object.ReferenceEquals(userName, Nothing) Then
     108            Dim buf[UNLEN] As TCHAR
     109            Dim len = (UNLEN + 1) As DWord
     110            GetUserName(buf, len)
     111            userName = New String(buf, len As Long)
     112        End If
     113        Return userName
     114    End Function           
    93115
    94116    ' Version
    95117
     118Public
     119    'NTでしか使用できない仕様
    96120    Static Function WorkingSet() As Int64
    97         TypeDef PFNGetProcessMemoryInfo = *Function(Process As HANDLE, ByRef mc As PROCESS_MEMORY_COUNTERS, cb As DWord) As BOOL
    98         Dim pGetProcessMemoryInfo As PFNGetProcessMemoryInfo
    99121        Dim hmodPSAPI = LoadLibrary("PSAPI.DLL")
    100122        If hmodPSAPI = 0 Then Return 0
    101         pGetProcessMemoryInfo = GetProcAddress(hmodPSAPI, ToMBStr("GetProcessMemoryInfo")) As PFNGetProcessMemoryInfo
     123        Dim pGetProcessMemoryInfo = GetProcAddress(hmodPSAPI, ToMBStr("GetProcessMemoryInfo")) As Detail.PFNGetProcessMemoryInfo
    102124        If pGetProcessMemoryInfo <> 0 Then
    103125            Dim mc As PROCESS_MEMORY_COUNTERS
     
    136158    ' GetEnvironmentVariables
    137159
     160    Static Function GetFolderPath(f As Environment_SpecialFolder) As String
     161'       If ... Then
     162'           Throw New ArgumentException
     163'       End If
     164        Dim x As Long
     165        x = f
     166        Return ActiveBasic.Windows.GetFolderPath(x)
     167    End Function
     168
    138169    ' GetLogicalDrives
    139170
     
    143174    Static cmdLine = Nothing As String
    144175    Static exitCode = 0 As Long
     176    Static machineName = Nothing As String
    145177    Static osVer = Nothing As OperatingSystem
    146178    Static processorCount = 0 As Long
    147179    Static sysDir = Nothing As String
     180    Static userName = Nothing As String
    148181End Class
     182
     183Enum Environment_SpecialFolder
     184    Desktop = CSIDL_DESKTOP
     185    Programs = CSIDL_PROGRAMS
     186    Personal = CSIDL_PERSONAL
     187    MyDocuments = CSIDL_PERSONAL
     188    Favorites = CSIDL_FAVORITES
     189    Startup = CSIDL_STARTUP
     190    Recent = CSIDL_RECENT
     191    SendTo = CSIDL_SENDTO
     192    StartMenu = CSIDL_STARTMENU
     193    MyMusic = CSIDL_MYMUSIC
     194    DesktopDirectory = CSIDL_DESKTOPDIRECTORY
     195    MyComputer = CSIDL_DRIVES
     196    Templates = CSIDL_TEMPLATES
     197    ApplicationData = CSIDL_APPDATA '4.71
     198    LocalApplicationData = CSIDL_LOCAL_APPDATA
     199    InternetCache = CSIDL_INTERNET_CACHE
     200    Cookies = CSIDL_COOKIES
     201    History = CSIDL_HISTORY
     202    CommonApplicationData = CSIDL_COMMON_APPDATA '5.0
     203    System = CSIDL_SYSTEM
     204    CommonProgramFiles = CSIDL_PROGRAM_FILES
     205    ProgramFiles = CSIDL_PROGRAM_FILES
     206    MyPictures = CSIDL_MYPICTURES
     207End Enum
     208
     209
     210End Namespace 'System
Note: See TracChangeset for help on using the changeset viewer.