Ignore:
Timestamp:
Mar 9, 2007, 10:15:34 PM (17 years ago)
Author:
イグトランス (egtra)
Message:

Environment, OperatingSystem, Versionの追加、Unicode対応修正ほか

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Include/basic/command.sbp

    r123 r142  
    55#define _INC_COMMAND
    66
     7#require <windows.sbp>
     8#require <Classes/System/Environment.ab>
    79
    810Const _System_Type_SByte = 1
     
    3335Macro END()
    3436    _System_Call_Destructor_of_GlobalObject()
    35     ExitProcess(0)
    36 End Macro
    37 
    38 Macro EXEC(lpFilePath As *Byte)(lpCmdLine As *Byte)
    39     ShellExecute(0,"open",lpFilePath,lpCmdLine,0,SW_SHOWNORMAL)
     37    ExitProcess(Environment.ExitCode)
     38End Macro
     39
     40Macro EXEC(filePath As String)(cmdLine As String)
     41    ShellExecute(0, "open", ToTCStr(filePath), ToTCStr(cmdLine), 0, SW_SHOWNORMAL)
    4042End Macro
    4143
     
    5254Macro WRITE()   'dummy(PRINT_ToFile、PRINT_ToPromptを参照)
    5355End Macro
    54 
    5556
    5657'----------------
     
    5859'----------------
    5960
    60 Macro MSGBOX(hWnd As HWND, lpStr As String)(lpTitle As String, BoxType As DWord, ByRef retAns As DWord)
     61Function _System_MessageBox(hw As HWND, s As PCSTR, t As PCSTR, b As DWord) As DWord
     62    Return MessageBoxA(hw, s, t, b)
     63End Function
     64
     65Function _System_MessageBox(hw As HWND, s As PCWSTR, t As PCWSTR, b As DWord) As DWord
     66    Return MessageBoxW(hw, s, t, b)
     67End Function
     68
     69Macro MSGBOX(hwnd As HWND, str As String)(title As String, boxType As DWord, ByRef retAns As DWord)
    6170    If VarPtr(retAns) Then
    62         retAns=MessageBox(hWnd,lpStr,lpTitle,BoxType)
     71        retAns = _System_MessageBox(hwnd, str, title, boxType)
    6372    Else
    64         MessageBox(hWnd,lpStr,lpTitle,BoxType)
     73        _System_MessageBox(hwnd, str, title, boxType)
    6574    End If
    6675End Macro
    6776
    68 Macro WINDOW(ByRef hWnd As HWND, hOwner As HWND, x As Long, y As Long, nWidth As Long, nHeight As Long, lpTitle As String, dwStyle As DWord)(lpClass As String, id As HMENU, lpFunc As DWord, dwExStyle As DWord)
    69     If VarPtr(hWnd) Then
    70         hWnd=CreateWindowEx(dwExStyle,lpClass,lpTitle,dwStyle,x,y,nWidth,nHeight,hOwner,id,GetModuleHandle(0),NULL)
    71     Else
    72         CreateWindowEx(dwExStyle,lpClass,lpTitle,dwStyle,x,y,nWidth,nHeight,hOwner,id,GetModuleHandle(0),NULL)
     77Macro WINDOW(ByRef hwndRet As HWND, hOwner As HWND, x As Long, y As Long, width As Long, height As Long, title As String, dwStyle As DWord)(className As String, id As HMENU, lpFunc As DWord, dwExStyle As DWord)
     78    Dim hwnd = CreateWindowEx(dwExStyle, ToTCStr(className), ToTCStr(title), dwStyle, x, y, width, height, hOwner, id, GetModuleHandle(0), 0)
     79    If VarPtr(hwndRet) Then
     80        hwndRet = hwnd
    7381    End If
    7482End Macro
     
    7886End Macro
    7987
    80 Macro INSMENU(hMenu As HMENU, PosID As Long, flag As Long)(lpString As String, id As Long, hSubMenu As HMENU, state As Long)
     88Macro INSMENU(hMenu As HMENU, PosID As Long, flag As Long)(str As String, id As Long, hSubMenu As HMENU, state As Long)
    8189    Dim mii As MENUITEMINFO
    8290    ZeroMemory(VarPtr(mii), Len(mii))
     
    9098            .fType = MFT_STRING
    9199            .fMask = .fMask or MIIM_STATE or MIIM_ID
    92             .dwTypeData = StrPtr(lpString)
     100            .dwTypeData = ToTCStr(str)
    93101            .wID = id
    94102            If hSubMenu Then
     
    96104                .hSubMenu = hSubMenu
    97105            End If
    98             .fState=state
     106            .fState = state
    99107        End If
    100108    End With
     
    108116
    109117Dim _System_hFile(255) As HANDLE
    110 Macro OPEN(lpFileName As String, AccessFor As Long, FileNumber As Long)
    111     Dim dwAccess As Long
    112     Dim bAppend = 0 As Long
    113     Dim dwCreationDisposition As Long
     118Macro OPEN(fileName As String, AccessFor As Long, FileNumber As Long)
     119    Dim access As Long
     120    Dim bAppend = False As Boolean
     121    Dim creationDisposition As Long
    114122
    115123    FileNumber--
     
    117125    Select Case AccessFor
    118126        Case 0
    119             dwAccess=GENERIC_READ or GENERIC_WRITE
    120             dwCreationDisposition=OPEN_ALWAYS
     127            access = GENERIC_READ or GENERIC_WRITE
     128            creationDisposition = OPEN_ALWAYS
    121129        Case 1
    122             dwAccess=GENERIC_READ
    123             dwCreationDisposition=OPEN_EXISTING
     130            access = GENERIC_READ
     131            creationDisposition = OPEN_EXISTING
    124132        Case 2
    125             dwAccess=GENERIC_WRITE
    126             dwCreationDisposition=CREATE_ALWAYS
     133            access = GENERIC_WRITE
     134            creationDisposition = CREATE_ALWAYS
    127135        Case 3
    128             dwAccess=GENERIC_WRITE
    129             dwCreationDisposition=OPEN_ALWAYS
    130             bAppend=1
     136            access = GENERIC_WRITE
     137            creationDisposition = OPEN_ALWAYS
     138            bAppend = True
    131139    End Select
    132140
    133     _System_hFile(FileNumber)=CreateFile(lpFileName,dwAccess,0,ByVal NULL,dwCreationDisposition,FILE_ATTRIBUTE_NORMAL,NULL)
    134 
    135     If bAppend Then SetFilePointer(_System_hFile(FileNumber),0,NULL,FILE_END)
     141    _System_hFile(FileNumber) = CreateFile(ToTCStr(fileName), access, 0, ByVal 0, creationDisposition, FILE_ATTRIBUTE_NORMAL, 0)
     142
     143    If bAppend Then SetFilePointer(_System_hFile(FileNumber), 0, 0, FILE_END)
    136144End Macro
    137145
     
    151159    Dim i As Long ,i2 As Long, i3 As Long
    152160    Dim buffer As String
    153     Dim temp[1] As Char
     161    Dim temp[1] As StrChar
    154162    Dim dwAccessBytes As DWord
    155163    Dim IsStr As Long
     
    163171        '次のデータをサーチ
    164172        Do
    165             i2=ReadFile(_System_hFile[FileNumber],temp,1,VarPtr(dwAccessBytes),ByVal 0)
     173            i2=ReadFile(_System_hFile[FileNumber],temp,SizeOf (StrChar),VarPtr(dwAccessBytes),ByVal 0)
    166174            If i2=0 or dwAccessBytes=0 Then
    167175                'error
     
    177185            i3++
    178186
    179             i2=ReadFile(_System_hFile[FileNumber],temp,1,VarPtr(dwAccessBytes),ByVal 0)
     187            i2=ReadFile(_System_hFile[FileNumber],temp,SizeOf (StrChar),VarPtr(dwAccessBytes),ByVal 0)
    180188            If i2=0 or (i3=0 and dwAccessBytes=0) Then
    181189                'error
     
    187195            If dwAccessBytes=0 or temp[0]=0 or temp[0]=13 or temp[0]=10 or (IsStr=0 and temp[0]=Asc(",")) or (IsStr=0 and (temp[0]=32 or temp[0]=9) and _System_InputDataType[i]<>_System_Type_String) Then
    188196                If temp[0]=13 Then
    189                     ReadFile(_System_hFile[FileNumber],temp,1,VarPtr(dwAccessBytes),ByVal 0)
     197                    ReadFile(_System_hFile[FileNumber],temp,SizeOf (StrChar),VarPtr(dwAccessBytes),ByVal 0)
    190198                    If Not(dwAccessBytes<>0 And temp[0]=10) Then
    191199                        SetFilePointer(_System_hFile[FileNumber],-1,0,FILE_CURRENT)
     
    240248            pTempStr = arg As *String
    241249            pTempStr->ReSize(bufLen)
    242             memcpy(pTempStr->Chars, buf.Chars, SizeOf (Char) * pTempStr->Length)
     250            memcpy(pTempStr->Chars, buf.Chars, SizeOf (StrChar) * pTempStr->Length)
    243251            pTempStr->Chars[pTempStr->Length] = 0
    244252    End Select
     
    249257    FileNumber--
    250258
    251     WriteFile(_System_hFile(FileNumber),buf,Len(buf),VarPtr(dwAccessByte),ByVal NULL)
     259    WriteFile(_System_hFile(FileNumber), buf, Len(buf), VarPtr(dwAccessByte), ByVal 0)
    252260End Sub
    253261
     
    257265Function _System_GetUsingFormat(UsingStr As String) As String
    258266    Dim i2 As Long, i3 As Long, i4 As Long, i5 As Long, ParmNum As Long
    259     Dim temporary[255] As Char
     267    Dim temporary[255] As StrChar
    260268    Dim buffer As String
    261269
    262     buffer=ZeroString(1024)
    263 
    264     ParmNum=0
    265     i2=0
     270    buffer = ZeroString(1024)
     271
     272    ParmNum = 0
     273    i2 = 0
    266274    While 1
    267275        While 1
     
    277285        If UsingStr[i2]=Asc("#") Then
    278286            Dim dec As Long, sign As Long
    279             Dim temp2 As *Char
     287            Dim temp2 As *StrChar
    280288
    281289            Dim length_num As Long, length_buf As Long
     
    332340
    333341                If dec > 0 Then
    334                     memcpy(VarPtr(buffer[i3]), temp2, SizeOf (Char) * length_num)
     342                    memcpy(VarPtr(buffer[i3]), temp2, SizeOf (StrChar) * length_num)
    335343                Else
    336344                    buffer[i3] = &H30
     
    367375            'lstrcat(StrPtr(buffer)+i3,_System_UsingStrData[ParmNum])
    368376            memcpy(VarPtr(buffer[i3 + lstrlen(VarPtr(buffer[i3]))]), _System_UsingStrData[ParmNum], _
    369                 SizeOf (Char) * lstrlen(_System_UsingStrData[ParmNum]))
     377                SizeOf (StrChar) * lstrlen(_System_UsingStrData[ParmNum]))
    370378            i3 += lstrlen(_System_UsingStrData[ParmNum])
    371379        ElseIf UsingStr[i2]=Asc("&") Then
     
    385393                    _System_FillChar(VarPtr(buffer[i3]), i4, &h20) 'Asc(" ")
    386394                End If
    387                 memcpy(VarPtr(buffer[i3]), _System_UsingStrData[ParmNum], SizeOf (Char) * i5)
     395                memcpy(VarPtr(buffer[i3]), _System_UsingStrData[ParmNum], SizeOf (StrChar) * i5)
    388396                i3 += i4
    389397            Else
     
    423431    RecodeNumber--
    424432
    425     SetFilePointer(_System_hFile(FileNumber),RecodeNumber*_System_FieldSize(FileNumber),NULL,FILE_BEGIN)
    426     lpBuffer=ZeroString(_System_FieldSize(FileNumber))
    427     ReadFile(_System_hFile(FileNumber),StrPtr(lpBuffer),_System_FieldSize(FileNumber),VarPtr(dwAccessByte),ByVal NULL)
     433    SetFilePointer(_System_hFile(FileNumber), SizeOf (StrChar) * RecodeNumber * _System_FieldSize(FileNumber), 0, FILE_BEGIN)
     434    lpBuffer = ZeroString(_System_FieldSize(FileNumber))
     435    ReadFile(_System_hFile(FileNumber), StrPtr(lpBuffer), SizeOf (StrChar) * _System_FieldSize(FileNumber), VarPtr(dwAccessByte),ByVal 0)
    428436    If Not dwAccessByte=_System_FieldSize(FileNumber) Then
    429         lpBuffer=Left$(lpBuffer,dwAccessByte)
     437        lpBuffer = Left$(lpBuffer, dwAccessByte)
    430438    End If
    431439End Macro
     
    436444    RecodeNumber--
    437445
    438     SetFilePointer(_System_hFile(FileNumber),RecodeNumber*_System_FieldSize(FileNumber),NULL,FILE_BEGIN)
    439     WriteFile(_System_hFile(FileNumber),StrPtr(lpBuffer),_System_FieldSize(FileNumber),VarPtr(dwAccessByte),ByVal NULL)
     446    SetFilePointer(_System_hFile(FileNumber), SizeOf (StrChar) * RecodeNumber*_System_FieldSize(FileNumber), 0, FILE_BEGIN)
     447    WriteFile(_System_hFile(FileNumber), StrPtr(lpBuffer),SizeOf (StrChar) * _System_FieldSize(FileNumber), VarPtr(dwAccessByte), ByVal 0)
    440448End Macro
    441449
    442450Macro CHDIR(path As String)
    443     SetCurrentDirectory(path)
     451    SetCurrentDirectory(ToTCStr(path))
    444452End Macro
    445453Macro MKDIR(path As String)
    446     CreateDirectory(path, 0)
     454    CreateDirectory(ToTCStr(path), 0)
    447455End Macro
    448456Macro KILL(path As String)
    449     DeleteFile(path)
     457    DeleteFile(ToTCStr(path))
    450458End Macro
    451459
Note: See TracChangeset for help on using the changeset viewer.