Index: Include/basic/command.sbp
===================================================================
--- Include/basic/command.sbp	(revision 123)
+++ Include/basic/command.sbp	(revision 142)
@@ -5,4 +5,6 @@
 #define _INC_COMMAND
 
+#require <windows.sbp>
+#require <Classes/System/Environment.ab>
 
 Const _System_Type_SByte = 1
@@ -33,9 +35,9 @@
 Macro END()
 	_System_Call_Destructor_of_GlobalObject()
-	ExitProcess(0)
-End Macro
-
-Macro EXEC(lpFilePath As *Byte)(lpCmdLine As *Byte)
-	ShellExecute(0,"open",lpFilePath,lpCmdLine,0,SW_SHOWNORMAL)
+	ExitProcess(Environment.ExitCode)
+End Macro
+
+Macro EXEC(filePath As String)(cmdLine As String)
+	ShellExecute(0, "open", ToTCStr(filePath), ToTCStr(cmdLine), 0, SW_SHOWNORMAL)
 End Macro
 
@@ -52,5 +54,4 @@
 Macro WRITE()	'dummy（PRINT_ToFile、PRINT_ToPromptを参照）
 End Macro
-
 
 '----------------
@@ -58,17 +59,24 @@
 '----------------
 
-Macro MSGBOX(hWnd As HWND, lpStr As String)(lpTitle As String, BoxType As DWord, ByRef retAns As DWord)
+Function _System_MessageBox(hw As HWND, s As PCSTR, t As PCSTR, b As DWord) As DWord
+	Return MessageBoxA(hw, s, t, b)
+End Function
+
+Function _System_MessageBox(hw As HWND, s As PCWSTR, t As PCWSTR, b As DWord) As DWord
+	Return MessageBoxW(hw, s, t, b)
+End Function
+
+Macro MSGBOX(hwnd As HWND, str As String)(title As String, boxType As DWord, ByRef retAns As DWord)
 	If VarPtr(retAns) Then
-		retAns=MessageBox(hWnd,lpStr,lpTitle,BoxType)
+		retAns = _System_MessageBox(hwnd, str, title, boxType)
 	Else
-		MessageBox(hWnd,lpStr,lpTitle,BoxType)
+		_System_MessageBox(hwnd, str, title, boxType)
 	End If
 End Macro
 
-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)
-	If VarPtr(hWnd) Then
-		hWnd=CreateWindowEx(dwExStyle,lpClass,lpTitle,dwStyle,x,y,nWidth,nHeight,hOwner,id,GetModuleHandle(0),NULL)
-	Else
-		CreateWindowEx(dwExStyle,lpClass,lpTitle,dwStyle,x,y,nWidth,nHeight,hOwner,id,GetModuleHandle(0),NULL)
+Macro 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)
+	Dim hwnd = CreateWindowEx(dwExStyle, ToTCStr(className), ToTCStr(title), dwStyle, x, y, width, height, hOwner, id, GetModuleHandle(0), 0)
+	If VarPtr(hwndRet) Then
+		hwndRet = hwnd
 	End If
 End Macro
@@ -78,5 +86,5 @@
 End Macro
 
-Macro INSMENU(hMenu As HMENU, PosID As Long, flag As Long)(lpString As String, id As Long, hSubMenu As HMENU, state As Long)
+Macro INSMENU(hMenu As HMENU, PosID As Long, flag As Long)(str As String, id As Long, hSubMenu As HMENU, state As Long)
 	Dim mii As MENUITEMINFO
 	ZeroMemory(VarPtr(mii), Len(mii))
@@ -90,5 +98,5 @@
 			.fType = MFT_STRING
 			.fMask = .fMask or MIIM_STATE or MIIM_ID
-			.dwTypeData = StrPtr(lpString)
+			.dwTypeData = ToTCStr(str)
 			.wID = id
 			If hSubMenu Then
@@ -96,5 +104,5 @@
 				.hSubMenu = hSubMenu
 			End If
-			.fState=state
+			.fState = state
 		End If
 	End With
@@ -108,8 +116,8 @@
 
 Dim _System_hFile(255) As HANDLE
-Macro OPEN(lpFileName As String, AccessFor As Long, FileNumber As Long)
-	Dim dwAccess As Long
-	Dim bAppend = 0 As Long
-	Dim dwCreationDisposition As Long
+Macro OPEN(fileName As String, AccessFor As Long, FileNumber As Long)
+	Dim access As Long
+	Dim bAppend = False As Boolean
+	Dim creationDisposition As Long
 
 	FileNumber--
@@ -117,21 +125,21 @@
 	Select Case AccessFor
 		Case 0
-			dwAccess=GENERIC_READ or GENERIC_WRITE
-			dwCreationDisposition=OPEN_ALWAYS
+			access = GENERIC_READ or GENERIC_WRITE
+			creationDisposition = OPEN_ALWAYS
 		Case 1
-			dwAccess=GENERIC_READ
-			dwCreationDisposition=OPEN_EXISTING
+			access = GENERIC_READ
+			creationDisposition = OPEN_EXISTING
 		Case 2
-			dwAccess=GENERIC_WRITE
-			dwCreationDisposition=CREATE_ALWAYS
+			access = GENERIC_WRITE
+			creationDisposition = CREATE_ALWAYS
 		Case 3
-			dwAccess=GENERIC_WRITE
-			dwCreationDisposition=OPEN_ALWAYS
-			bAppend=1
+			access = GENERIC_WRITE
+			creationDisposition = OPEN_ALWAYS
+			bAppend = True
 	End Select
 
-	_System_hFile(FileNumber)=CreateFile(lpFileName,dwAccess,0,ByVal NULL,dwCreationDisposition,FILE_ATTRIBUTE_NORMAL,NULL)
-
-	If bAppend Then SetFilePointer(_System_hFile(FileNumber),0,NULL,FILE_END)
+	_System_hFile(FileNumber) = CreateFile(ToTCStr(fileName), access, 0, ByVal 0, creationDisposition, FILE_ATTRIBUTE_NORMAL, 0)
+
+	If bAppend Then SetFilePointer(_System_hFile(FileNumber), 0, 0, FILE_END)
 End Macro
 
@@ -151,5 +159,5 @@
 	Dim i As Long ,i2 As Long, i3 As Long
 	Dim buffer As String
-	Dim temp[1] As Char
+	Dim temp[1] As StrChar
 	Dim dwAccessBytes As DWord
 	Dim IsStr As Long
@@ -163,5 +171,5 @@
 		'次のデータをサーチ
 		Do
-			i2=ReadFile(_System_hFile[FileNumber],temp,1,VarPtr(dwAccessBytes),ByVal 0)
+			i2=ReadFile(_System_hFile[FileNumber],temp,SizeOf (StrChar),VarPtr(dwAccessBytes),ByVal 0)
 			If i2=0 or dwAccessBytes=0 Then
 				'error
@@ -177,5 +185,5 @@
 			i3++
 
-			i2=ReadFile(_System_hFile[FileNumber],temp,1,VarPtr(dwAccessBytes),ByVal 0)
+			i2=ReadFile(_System_hFile[FileNumber],temp,SizeOf (StrChar),VarPtr(dwAccessBytes),ByVal 0)
 			If i2=0 or (i3=0 and dwAccessBytes=0) Then
 				'error
@@ -187,5 +195,5 @@
 			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
 				If temp[0]=13 Then
-					ReadFile(_System_hFile[FileNumber],temp,1,VarPtr(dwAccessBytes),ByVal 0)
+					ReadFile(_System_hFile[FileNumber],temp,SizeOf (StrChar),VarPtr(dwAccessBytes),ByVal 0)
 					If Not(dwAccessBytes<>0 And temp[0]=10) Then
 						SetFilePointer(_System_hFile[FileNumber],-1,0,FILE_CURRENT)
@@ -240,5 +248,5 @@
 			pTempStr = arg As *String
 			pTempStr->ReSize(bufLen)
-			memcpy(pTempStr->Chars, buf.Chars, SizeOf (Char) * pTempStr->Length)
+			memcpy(pTempStr->Chars, buf.Chars, SizeOf (StrChar) * pTempStr->Length)
 			pTempStr->Chars[pTempStr->Length] = 0
 	End Select
@@ -249,5 +257,5 @@
 	FileNumber--
 
-	WriteFile(_System_hFile(FileNumber),buf,Len(buf),VarPtr(dwAccessByte),ByVal NULL)
+	WriteFile(_System_hFile(FileNumber), buf, Len(buf), VarPtr(dwAccessByte), ByVal 0)
 End Sub
 
@@ -257,11 +265,11 @@
 Function _System_GetUsingFormat(UsingStr As String) As String
 	Dim i2 As Long, i3 As Long, i4 As Long, i5 As Long, ParmNum As Long
-	Dim temporary[255] As Char
+	Dim temporary[255] As StrChar
 	Dim buffer As String
 
-	buffer=ZeroString(1024)
-
-	ParmNum=0
-	i2=0
+	buffer = ZeroString(1024)
+
+	ParmNum = 0
+	i2 = 0
 	While 1
 		While 1
@@ -277,5 +285,5 @@
 		If UsingStr[i2]=Asc("#") Then
 			Dim dec As Long, sign As Long
-			Dim temp2 As *Char
+			Dim temp2 As *StrChar
 
 			Dim length_num As Long, length_buf As Long
@@ -332,5 +340,5 @@
 
 				If dec > 0 Then
-					memcpy(VarPtr(buffer[i3]), temp2, SizeOf (Char) * length_num)
+					memcpy(VarPtr(buffer[i3]), temp2, SizeOf (StrChar) * length_num)
 				Else
 					buffer[i3] = &H30
@@ -367,5 +375,5 @@
 			'lstrcat(StrPtr(buffer)+i3,_System_UsingStrData[ParmNum])
 			memcpy(VarPtr(buffer[i3 + lstrlen(VarPtr(buffer[i3]))]), _System_UsingStrData[ParmNum], _
-				SizeOf (Char) * lstrlen(_System_UsingStrData[ParmNum]))
+				SizeOf (StrChar) * lstrlen(_System_UsingStrData[ParmNum]))
 			i3 += lstrlen(_System_UsingStrData[ParmNum])
 		ElseIf UsingStr[i2]=Asc("&") Then
@@ -385,5 +393,5 @@
 					_System_FillChar(VarPtr(buffer[i3]), i4, &h20) 'Asc(" ")
 				End If
-				memcpy(VarPtr(buffer[i3]), _System_UsingStrData[ParmNum], SizeOf (Char) * i5)
+				memcpy(VarPtr(buffer[i3]), _System_UsingStrData[ParmNum], SizeOf (StrChar) * i5)
 				i3 += i4
 			Else
@@ -423,9 +431,9 @@
 	RecodeNumber--
 
-	SetFilePointer(_System_hFile(FileNumber),RecodeNumber*_System_FieldSize(FileNumber),NULL,FILE_BEGIN)
-	lpBuffer=ZeroString(_System_FieldSize(FileNumber))
-	ReadFile(_System_hFile(FileNumber),StrPtr(lpBuffer),_System_FieldSize(FileNumber),VarPtr(dwAccessByte),ByVal NULL)
+	SetFilePointer(_System_hFile(FileNumber), SizeOf (StrChar) * RecodeNumber * _System_FieldSize(FileNumber), 0, FILE_BEGIN)
+	lpBuffer = ZeroString(_System_FieldSize(FileNumber))
+	ReadFile(_System_hFile(FileNumber), StrPtr(lpBuffer), SizeOf (StrChar) * _System_FieldSize(FileNumber), VarPtr(dwAccessByte),ByVal 0)
 	If Not dwAccessByte=_System_FieldSize(FileNumber) Then
-		lpBuffer=Left$(lpBuffer,dwAccessByte)
+		lpBuffer = Left$(lpBuffer, dwAccessByte)
 	End If
 End Macro
@@ -436,16 +444,16 @@
 	RecodeNumber--
 
-	SetFilePointer(_System_hFile(FileNumber),RecodeNumber*_System_FieldSize(FileNumber),NULL,FILE_BEGIN)
-	WriteFile(_System_hFile(FileNumber),StrPtr(lpBuffer),_System_FieldSize(FileNumber),VarPtr(dwAccessByte),ByVal NULL)
+	SetFilePointer(_System_hFile(FileNumber), SizeOf (StrChar) * RecodeNumber*_System_FieldSize(FileNumber), 0, FILE_BEGIN)
+	WriteFile(_System_hFile(FileNumber), StrPtr(lpBuffer),SizeOf (StrChar) * _System_FieldSize(FileNumber), VarPtr(dwAccessByte), ByVal 0)
 End Macro
 
 Macro CHDIR(path As String)
-	SetCurrentDirectory(path)
+	SetCurrentDirectory(ToTCStr(path))
 End Macro
 Macro MKDIR(path As String)
-	CreateDirectory(path, 0)
+	CreateDirectory(ToTCStr(path), 0)
 End Macro
 Macro KILL(path As String)
-	DeleteFile(path)
+	DeleteFile(ToTCStr(path))
 End Macro
 
