Index: Include/api_system.sbp
===================================================================
--- Include/api_system.sbp	(revision 142)
+++ Include/api_system.sbp	(revision 160)
@@ -18,8 +18,10 @@
 Const _FuncName_CreateProcess = "CreateProcessW"
 Const _FuncName_DeleteFile = "DeleteFileW"
+Const _FuncName_ExpandEnvironmentStrings = "ExpandEnvironmentStringsW"
 Const _FuncName_FatalAppExit = "FatalAppExitW"
 Const _FuncName_FindFirstChangeNotification = "FindFirstChangeNotificationW"
 Const _FuncName_FindFirstFile = "FindFirstFileW"
 Const _FuncName_FindNextFile = "FindNextFileW"
+Const _FuncName_FindResource = "FindResourceW"
 Const _FuncName_FormatMessage = "FormatMessageW"
 Const _FuncName_FreeEnvironmentStrings = "FreeEnvironmentStringsW"
@@ -37,4 +39,5 @@
 Const _FuncName_GetFullPathName = "GetFullPathNameW"
 Const _FuncName_GetLogicalDriveStrings = "GetLogicalDriveStringsW"
+Const _FuncName_GetLongPathName = "GetLongPathNameW"
 Const _FuncName_GetModuleFileName = "GetModuleFileNameW"
 Const _FuncName_GetModuleHandle = "GetModuleHandleW"
@@ -51,8 +54,10 @@
 Const _FuncName_LoadLibrary = "LoadLibraryW"
 Const _FuncName_LoadLibraryEx = "LoadLibraryExW"
+Const _FuncName_LookupPrivilegeValue = "LookupPrivilegeValueW"
 Const _FuncName_lstrcat = "lstrcatW"
 Const _FuncName_lstrcmp = "lstrcmpW"
 Const _FuncName_lstrcmpi = "lstrcmpiW"
 Const _FuncName_lstrcpy = "lstrcpyW"
+Const _FuncName_lstrcpyn = "lstrcpynW"
 Const _FuncName_MoveFile = "MoveFileW"
 Const _FuncName_OpenEvent = "OpenEventW"
@@ -80,8 +85,10 @@
 Const _FuncName_CreateProcess = "CreateProcessA"
 Const _FuncName_DeleteFile = "DeleteFileA"
+Const _FuncName_ExpandEnvironmentStrings = "ExpandEnvironmentStringsA"
 Const _FuncName_FatalAppExit = "FatalAppExitA"
 Const _FuncName_FindFirstChangeNotification = "FindFirstChangeNotificationA"
 Const _FuncName_FindFirstFile = "FindFirstFileA"
 Const _FuncName_FindNextFile = "FindNextFileA"
+Const _FuncName_FindResource = "FindResourceA"
 Const _FuncName_FormatMessage = "FormatMessageA"
 Const _FuncName_FreeEnvironmentStrings = "FreeEnvironmentStringsA"
@@ -99,4 +106,5 @@
 Const _FuncName_GetFullPathName = "GetFullPathNameA"
 Const _FuncName_GetLogicalDriveStrings = "GetLogicalDriveStringsA"
+Const _FuncName_GetLongPathName = "GetLongPathNameA"
 Const _FuncName_GetModuleFileName = "GetModuleFileNameA"
 Const _FuncName_GetModuleHandle = "GetModuleHandleA"
@@ -113,8 +121,10 @@
 Const _FuncName_LoadLibrary = "LoadLibraryA"
 Const _FuncName_LoadLibraryEx = "LoadLibraryExA"
+Const _FuncName_LookupPrivilegeValue = "LookupPrivilegeValueA"
 Const _FuncName_lstrcat = "lstrcatA"
 Const _FuncName_lstrcmp = "lstrcmpA"
 Const _FuncName_lstrcmpi = "lstrcmpiA"
 Const _FuncName_lstrcpy = "lstrcpyA"
+Const _FuncName_lstrcpyn = "lstrcpynA"
 Const _FuncName_MoveFile = "MoveFileA"
 Const _FuncName_OpenEvent = "OpenEventA"
@@ -483,4 +493,9 @@
 Declare Function CreateEvent Lib "kernel32" Alias _FuncName_CreateEvent (pEventAttributes As *SECURITY_ATTRIBUTES, bManualReset As BOOL, bInitialState As BOOL, pName As PCTSTR) As HANDLE
 Declare Function CreateMutex Lib "kernel32" Alias _FuncName_CreateMutex (lpMutexAttributes As *SECURITY_ATTRIBUTES, bInitialOwner As BOOL, lpName As PCTSTR) As HANDLE
+Declare Function CreatePipe Lib "Kernel32" (
+    ByRef hReadPipe As HANDLE,
+    ByRef hWritePipe As HANDLE,
+    ByVal pPipeAttributes As *SECURITY_ATTRIBUTES,
+    ByVal nSize As DWORD) As Long
 Declare Function CreateSemaphore Lib "kernel32" Alias _FuncName_CreateSemaphore (pSemaphoreAttributes As *SECURITY_ATTRIBUTES, lInitialCount As Long, lMaximumCount As Long, pName As PCTSTR) As HANDLE
 
@@ -646,5 +661,5 @@
 ) As Long
 Declare Function DisableThreadLibraryCalls Lib "kernel32" (hLibModule As HINSTANCE) As BOOL
-Declare Function DosDateTimeToFileTime Lib "kernel32" (wFatDate As Word, wFatTime As Word, ByRef lpFileTime As FILETIME) As BOOL
+Declare Function DosDateTimeToFileTime Lib "kernel32" (wFatDate As Word, wFatTime As Word, ByRef FileTime As FILETIME) As BOOL
 
 Const DUPLICATE_CLOSE_SOURCE = 1
@@ -788,4 +803,5 @@
 Declare Function GetLogicalDrives Lib "kernel32" () As DWord
 Declare Function GetLogicalDriveStrings Lib "kernel32" Alias _FuncName_GetLogicalDriveStrings (nBufferLength As DWord, pBuffer As PTSTR) As DWord
+Declare Function GetLongPathName Lib "kernel32" Alias _FuncName_GetLongPathName (lpszShortPath As LPCTSTR, lpszLongPath As LPTSTR, cchBuffer As DWord) As DWord
 Declare Function GetModuleFileName Lib "kernel32" Alias _FuncName_GetModuleFileName (hModule As HINSTANCE, lpFileName As PTSTR, nSize As DWord) As DWord
 Declare Function GetModuleHandle Lib "kernel32" Alias _FuncName_GetModuleHandle (lpModuleName As PTSTR) As HINSTANCE
@@ -796,4 +812,13 @@
 	bWait As BOOL
 ) As BOOL
+Type SYSTEM_POWER_STATUS
+	ACLineStatus As Byte
+	BatteryFlag As Byte
+	BatteryLifePercent As Byte
+	Reserved1 As Byte
+	BatteryLifeTime As Long
+	BatteryFullLifeTime As Long
+End Type
+Declare Function GetSystemPowerStatus Lib "kernel32" (ByRef SystemPowerStatus As SYSTEM_POWER_STATUS) As Long
 Declare Function GetPriorityClass Lib "kernel32" (hProcess As HANDLE) As DWord
 Declare Function GetProcAddress Lib "kernel32" (hModule As HINSTANCE, pProcName As PCSTR) As DWord
@@ -868,5 +893,4 @@
 Const TIME_FORCE24HOURFORMAT   = &H00000008
 Declare Function GetTimeFormat Lib "kernel32" Alias _FuncName_GetTimeFormat (Locale As LCID, dwFlags As DWord, ByRef Time As SYSTEMTIME, lpFormat As PCTSTR, lpTimeStr As PTSTR, cchTime As DWord) As BOOL
-
 Declare Function GetUserDefaultLCID Lib "kernel32" () As LCID
 Declare Function GetUserName Lib "advapi32" Alias _FuncName_GetUserName (pBuffer As PTSTR, ByRef nSize As DWord) As BOOL
@@ -967,18 +991,19 @@
 Declare Function LoadLibraryEx Lib "kernel32" Alias _FuncName_LoadLibraryEx (pLibFileName As PCTSTR, hFile As HANDLE, dwFlags As DWord) As HINSTANCE
 
-Declare Function lstrcat Lib "kernel32" Alias _FuncName_lstrcat (pString1 As PTSTR, pString2 As PCTSTR) As PSTR
-Declare Function lstrcmp Lib "kernel32" Alias _FuncName_lstrcmp (pString1 As PCTSTR, pString2 As PCTSTR) As Long
-Declare Function lstrcmpi Lib "kernel32" Alias _FuncName_lstrcmpi (pString1 As PCTSTR, pString2 As PCTSTR) As Long
-Declare Function lstrcpy Lib "kernel32" Alias _FuncName_lstrcpy (pString1 As PTSTR, pString2 As PCTSTR) As PSTR
-Declare Function lstrlenA Lib "kernel32" (pString As PCSTR) As Long
-Declare Function lstrlenW Lib "kernel32" (pString As PCWSTR) As Long
+Declare Function lstrcat Lib "kernel32" Alias _FuncName_lstrcat (lpString1 As LPTSTR, lpString2 As LPCTSTR) As LPTSTR
+Declare Function lstrcmp Lib "kernel32" Alias _FuncName_lstrcmp (lpString1 As LPCTSTR, lpString2 As LPCTSTR) As Long
+Declare Function lstrcmpi Lib "kernel32" Alias _FuncName_lstrcmpi (lpString1 As LPCTSTR, lpString2 As LPCTSTR) As Long
+Declare Function lstrcpy Lib "kernel32" Alias _FuncName_lstrcpy (lpString1 As LPTSTR, lpString2 As LPCTSTR) As LPTSTR
+Declare Function lstrcpyn Lib "kernel32" Alias _FuncName_lstrcpyn (lpString1 As LPTSTR,ByVal lpString2 As LPCTSTR,ByVal iMaxLength As Long) As LPTSTR
+Declare Function lstrlenA Lib "kernel32" (lpString As LPCSTR) As Long
+Declare Function lstrlenW Lib "kernel32" (lpString As LPCWSTR) As Long
 #ifdef UNICODE
-Declare Function lstrlen Lib "kernel32" Alias "lstrlenW" (pString As PCWSTR) As Long
+Declare Function lstrlen Lib "kernel32" Alias "lstrlenW" (lpString As LPCWSTR) As Long
 #else
-Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (pString As PCSTR) As Long
+Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (lpString As LPCSTR) As Long
 #endif
 Declare Sub memcpy Lib "kernel32" Alias "RtlMoveMemory" (pDest As VoidPtr, pSrc As VoidPtr, length As SIZE_T)
 Declare Function MoveFile Lib "kernel32" Alias _FuncName_MoveFile (lpExistingFileName As LPCTSTR, lpNewFileName As LPCTSTR) As BOOL
-Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As VoidPtr, pSrc As VoidPtr, length As SIZE_T)
+Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As PVOID, pSrc As VoidPtr, length As SIZE_T)
 
 Declare Function MulDiv Lib "kernel32" (
@@ -1030,4 +1055,5 @@
 	pArguments As *ULONG_PTR)
 Declare Function ReadFile Lib "kernel32" (hFile As HANDLE, lpBuffer As VoidPtr, nNumberOfBytesToRead As DWord, lpNumberOfBytesRead As DWordPtr, ByRef lpOverlapped As OVERLAPPED) As BOOL
+Declare Function ReadProcessMemory Lib "Kernel32"  (hProcess As HANDLE, lpBaseAddress As VoidPtr, lpBuffer As VoidPtr, nSize As SIZE_T, lpNumberOfBytesRead As *SIZE_T) As BOOL
 Declare Function ReleaseMutex Lib "kernel32" (hMutex As HANDLE) As BOOL
 Declare Function ReleaseSemaphore Lib "kernel32" (hSemaphore As HANDLE, lReleaseCount As Long, ByRef lpPreviousCount As Long) As BOOL
@@ -1066,5 +1092,5 @@
 ) As BOOL
 
-Const EXCEPTION_MAXIMUM_PARAMETERS = ELM(15)
+Const EXCEPTION_MAXIMUM_PARAMETERS = 15
 
 Type EXCEPTION_RECORD
@@ -1074,5 +1100,5 @@
 	ExceptionAddress As VoidPtr
 	NumberParameters As DWord
-	ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS] As ULONG_PTR
+	ExceptionInformation[ELM(EXCEPTION_MAXIMUM_PARAMETERS)] As ULONG_PTR
 End Type
 
@@ -1416,3 +1442,73 @@
 Const WAIT_IO_COMPLETION = &h000000C0 'STATUS_USER_APC
 
+Declare Function FindResource Lib "kernel32" Alias _FuncName_FindResource (hInstance As HINSTANCE, lpName As LPCTSTR, lpType As LPCTSTR) As HRSRC
+Declare Function LoadResource Lib "kernel32" (hModule As HMODULE, hResInfo As HRSRC) As HGLOBAL
+Declare Function FreeResource Lib "kernel32" (hResData As HGLOBAL) As BOOL
+Declare Function LockResource Lib "kernel32" (hResData As HGLOBAL) As VoidPtr
+Declare Function SizeofResource Lib "kernel32" (hModule As HANDLE, hResInfo As HRSRC) As DWord
+
+Declare Function ExpandEnvironmentStrings Lib "kernel32" Alias _FuncName_ExpandEnvironmentStrings (lpSrc As LPCTSTR, lpDst As LPTSTR, nSize As DWord) As DWord
+
+Type DCB
+	DCBlength As DWord
+	BaudRate As DWord
+	fBitFields As DWord
+	wReserved As Word
+	XonLim As Word
+	XoffLim As Word
+	ByteSize As Byte
+	Parity As Byte
+	StopBits As Byte
+	XonChar As CHAR
+	XoffChar As CHAR
+	ErrorChar As CHAR
+	EofChar As CHAR
+	EvtChar As CHAR
+	wReserved1 As Word
+End Type
+
+Type COMMTIMEOUTS
+	ReadIntervalTimeout As DWord
+	ReadTotalTimeoutMultiplier As DWord
+	ReadTotalTimeoutConstant As DWord
+	WriteTotalTimeoutMultiplier As DWord
+	WriteTotalTimeoutConstant As DWord
+End Type
+Type COMSTAT
+ fCoBitFlds As Long 'See Comment in Win32API.Txt
+ cbInQue As DWord
+ cbOutQue As DWord
+End Type
+Declare Function SetCommState Lib "kernel32" (hCommDev As HANDLE, ByRef dcb As DCB) As BOOL
+Declare Function SetCommTimeouts Lib "kernel32" (hFile As HANDLE ,ByRef pCommTimeouts As COMMTIMEOUTS) As BOOL
+Declare Function ClearCommError Lib "kernel32" (hCommDevs As HANDLE, ByRef Errors As DWord, ByRef Stat As COMSTAT) As BOOL
+Declare Function EscapeCommFunction Lib "kernel32" (nCid As HANDLE, ByVal nFunc As DWord) As BOOL
+Declare Function GetCommModemStatus Lib "kernel32" (hFile As HANDLE, ByRef ModemStat As DWord) As BOOL
+Declare Function SetCommMask Lib "kernel32" (hFile As HANDLE, dwEvtMask As DWord) As BOOL
+Declare Function WaitCommEvent Lib "kernel32" (hFile As HANDLE, ByRef EvtMask As DWord, lpOverlapped As *OVERLAPPED)  As BOOL
+
+Const ANYSIZE_ARRAY = 1
+Type LUID
+	LowPart As DWord
+	HighPart As Long
+End Type
+Type LUID_AND_ATTRIBUTES
+	Luid As LUID
+	Attributes As DWord
+End Type
+TypeDef PLUID_AND_ATTRIBUTES = *LUID_AND_ATTRIBUTES
+'TypeDef LUID_AND_ATTRIBUTES_ARRAY = LUID_AND_ATTRIBUTES[ANYSIZE_ARRAY]
+'TypeDef PLUID_AND_ATTRIBUTES_ARRAY = *LUID_AND_ATTRIBUTES_ARRAY
+
+Type TOKEN_PRIVILEGES
+	PrivilegeCount As DWord
+	Privileges[ELM(ANYSIZE_ARRAY)] As LUID_AND_ATTRIBUTES
+End Type
+
+Declare Function OpenProcessToken Lib "advapi32" (ProcessHandle As HANDLE, DesiredAccess As DWord, ByRef TokenHandle As HANDLE) As BOOL
+Declare Function LookupPrivilegeValue Lib "advapi32" Alias _FuncName_LookupPrivilegeValue (lpSystemName As LPCTSTR, lpName As LPCTSTR, ByRef Luid As LUID) As Long
+Declare Function AdjustTokenPrivileges Lib "advapi32" (TokenHandle As Long, DisableAllPrivileges As Long,_
+	ByRef NewState As TOKEN_PRIVILEGES, BufferLength As Long,
+	ByRef PreviousState As TOKEN_PRIVILEGES, ByRef ReturnLength As Long) As Long
+
 #endif '_INC_SYSTEM
