Changeset 258 for Include/Classes/System


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

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

Location:
Include/Classes/System
Files:
3 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
  • Include/Classes/System/OperatingSystem.ab

    r257 r258  
    66#require <Classes/System/Version.ab>
    77
     8Namespace System
     9
    810Class OperatingSystem
    911    ' Inherits ICloneable', ISerializable
    1012Public
    1113    ' Constractor
    12     Sub OperatingSystem(platform As PlatformID, version As System.Version)
     14    Sub OperatingSystem(platform As PlatformID, version As Version)
    1315        pf = platform
    1416        ver = version
     
    1820    Sub OperatingSystem(vi As OSVERSIONINFOA)
    1921        pf = vi.dwPlatformId As PlatformID
    20         ver = New System.Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber)
     22        ver = New Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber)
    2123        sp = New String(vi.szCSDVersion As PCSTR)
    2224    End Sub
     
    2426    Sub OperatingSystem(vi As OSVERSIONINFOW)
    2527        pf = vi.dwPlatformId As PlatformID
    26         ver = New System.Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber)
     28        ver = New Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber)
    2729        sp = New String(vi.szCSDVersion As PCSTR)
    2830    End Sub
     
    3335    End Function
    3436
    35     Const Function Version() As System.Version
     37    Const Function Version() As Version
    3638        Return ver
    3739    End Function
     
    7173Private
    7274    pf As PlatformID
    73     ver As System.Version
     75    ver As Version
    7476    sp As String
    7577End Class
     
    8385End Enum
    8486
     87End Namespace
     88
    8589#endif '__SYSYTEM_OPERATINGSYSTEM_AB__
  • Include/Classes/System/Threading/WaitHandle.ab

    r237 r258  
    33#ifndef __SYSTEM_THREADING_WAITHANDLE_AB__
    44#define __SYSTEM_THREADING_WAITHANDLE_AB__
     5
     6'Namespace System
     7'Namespace Threading
     8
     9Namespace Detail
     10    TypeDef PFNSignalObjectAndWait = *Function(hObjectToSignal As HANDLE, hObjectToWaitOn As HANDLE, dwMilliseconds As DWord, bAlertable As DWord) As DWord
     11End Namespace
    512
    613Class WaitHandle
     
    6269    End Function
    6370
     71Public
    6472    Static Function SignalAndWait(ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle, millisecondsTimeout As Long, exitContext As BOOL) As BOOL
    65         TypeDef PFNSignalObjectAndWait = *Function(hObjectToSignal As HANDLE, hObjectToWaitOn As HANDLE, dwMilliseconds As DWord, bAlertable As DWord) As DWord
    66         Dim pSignalObjectAndWait = GetProcAddress(GetModuleHandle("Kernel32.dll"), "SignalObjectAndWait") As PFNSignalObjectAndWait
     73        Dim pSignalObjectAndWait = GetProcAddress(GetModuleHandle("Kernel32.dll"), "SignalObjectAndWait") As Detail.PFNSignalObjectAndWait
    6774        If pSignalObjectAndWait = 0 Then
    6875            ' PlatformNotSupportedException
     
    105112End Class
    106113
     114'End Namespace 'Threading
     115'End Namespace 'System
     116
    107117#endif '__SYSTEM_THREADING_WAITHANDLE_AB__
Note: See TracChangeset for help on using the changeset viewer.