*********************************************
作者: 秋水长天 (精品源于毅杨)
********************************************
最近在维护一个10年前的系统,是vb6.0做的。里面要用到了很多Win32的API。
与之关联的各种常量非常多,手头没有Windows.h之类的头文件,要查它们可是不容易。
为此,自己稍微整理了一下,以缓解遇到这种情况的各位兄弟姐妹的燃眉之急。
常用的几乎都涉及到了哦。
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
■■■■Win32API 结构体声明■■■■
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Type RECTL
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Type POINTAPI
X As Long
Y As Long
End Type
Type POINTL
X As Long
Y As Long
End Type
Type Size
cx As Long
cy As Long
End Type
Type POINTS
X As Integer
Y As Integer
End Type
Type msg
hwnd As Long
message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Type SID_IDENTIFIER_AUTHORITY
Value(6) As Byte
End Type
Type SID_AND_ATTRIBUTES
Sid As Long
Attributes As Long
End Type
Type OVERLAPPED
Internal As Long
InternalHigh As Long
offset As Long
OffsetHigh As Long
hEvent As Long
End Type
Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Type SystemTime
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Type COMMPROP
wPacketLength As Integer
wPacketVersion As Integer
dwServiceMask As Long
dwReserved1 As Long
dwMaxTxQueue As Long
dwMaxRxQueue As Long
dwMaxBaud As Long
dwProvSubType As Long
dwProvCapabilities As Long
dwSettableParams As Long
dwSettableBaud As Long
wSettableData As Integer
wSettableStopParity As Integer
dwCurrentTxQueue As Long
dwCurrentRxQueue As Long
dwProvSpec1 As Long
dwProvSpec2 As Long
wcProvChar(1) As Integer
End Type
Type COMSTAT
fBitFields As Long
cbInQue As Long
cbOutQue As Long
End Type
Type DCB
DCBlength As Long
BaudRate As Long
fBitFields As Long
wReserved As Integer
XonLim As Integer
XoffLim As Integer
ByteSize As Byte
Parity As Byte
StopBits As Byte
XonChar As Byte
XoffChar As Byte
ErrorChar As Byte
EofChar As Byte
EvtChar As Byte
wReserved1 As Integer
End Type
Type COMMTIMEOUTS
ReadIntervalTimeout As Long
ReadTotalTimeoutMultiplier As Long
ReadTotalTimeoutConstant As Long
WriteTotalTimeoutMultiplier As Long
WriteTotalTimeoutConstant As Long
End Type
Type SYSTEM_INFO
dwOemID As Long
dwPageSize As Long
lpMinimumApplicationAddress As Long
lpMaximumApplicationAddress As Long
dwActiveProcessorMask As Long
dwNumberOrfProcessors As Long
dwProcessorType As Long
dwAllocationGranularity As Long
dwReserved As Long
End Type
Type MEMORYSTATUS
dwLength As Long
dwMemoryLoad As Long
dwTotalPhys As Long
dwAvailPhys As Long
dwTotalPageFile As Long
dwAvailPageFile As Long
dwTotalVirtual As Long
dwAvailVirtual As Long
End Type
Type GENERIC_MAPPING
GenericRead As Long
GenericWrite As Long
GenericExecute As Long
GenericAll As Long
End Type
Type Luid
lowpart As Long
highpart As Long
End Type
Type LUID_AND_ATTRIBUTES
pLuid As Luid
Attributes As Long
End Type
Type ACL
AclRevision As Byte
Sbz1 As Byte
AclSize As Integer
AceCount As Integer
Sbz2 As Integer
End Type
Type ACE_HEADER
AceType As Byte
AceFlags As Byte
AceSize As Long
End Type
Type ACCESS_ALLOWED_ACE
Header As ACE_HEADER
Mask As Long
SidStart As Long
End Type
Type ACCESS_DENIED_ACE
Header As ACE_HEADER
Mask As Long
SidStart As Long
End Type
Type SYSTEM_AUDIT_ACE
Header As ACE_HEADER
Mask As Long
SidStart As Long
End Type
Type SYSTEM_ALARM_ACE
Header As ACE_HEADER
Mask As Long
SidStart As Long
End Type
Type ACL_REVISION_INFORMATION
AclRevision As Long
End Type
Type ACL_SIZE_INFORMATION
AceCount As Long
AclBytesInUse As Long
AclBytesFree As Long
End Type
Type SECURITY_DESCRIPTOR
Revision As Byte
Sbz1 As Byte
Control As Long
Owner As Long
Group As Long
Sacl As ACL
Dacl As ACL
End Type
Type PRIVILEGE_SET
PrivilegeCount As Long
Control As Long
Privilege(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES
End Type
Type EXCEPTION_RECORD
ExceptionCode As Long
ExceptionFlags As Long
pExceptionRecord As Long
ExceptionAddress As Long
NumberParameters As Long
ExceptionInformation(EXCEPTION_MAXIMUM_PARAMETERS) As Long
End Type
Type EXCEPTION_DEBUG_INFO
pExceptionRecord As EXCEPTION_RECORD
dwFirstChance As Long
End Type
Type CREATE_THREAD_DEBUG_INFO
hThread As Long
lpThreadLocalBase As Long
lpStartAddress As Long
End Type
Type CREATE_PROCESS_DEBUG_INFO
hFile As Long
hProcess As Long
hThread As Long
lpBaseOfImage As Long
dwDebugInfoFileOffset As Long
nDebugInfoSize As Long
lpThreadLocalBase As Long
lpStartAddress As Long
lpImageName As Long
fUnicode As Integer
End Type
Type EXIT_THREAD_DEBUG_INFO
dwExitCode As Long
End Type
Type EXIT_PROCESS_DEBUG_INFO
dwExitCode As Long
End Type
Type LOAD_DLL_DEBUG_INFO
hFile As Long
lpBaseOfDll As Long
dwDebugInfoFileOffset As Long
nDebugInfoSize As Long
lpImageName As Long
fUnicode As Integer
End Type
Type UNLOAD_DLL_DEBUG_INFO
lpBaseOfDll As Long
End Type
Type OUTPUT_DEBUG_STRING_INFO
lpDebugStringData As String
fUnicode As Integer
nDebugStringLength As Integer
End Type
Type RIP_INFO
dwError As Long
dwType As Long
End Type
Type OFSTRUCT
cBytes As Byte
fFixedDisk As Byte
nErrCode As Integer
Reserved1 As Integer
Reserved2 As Integer
szPathName(OFS_MAXPATHNAME) As Byte
End Type
Type CRITICAL_SECTION
dummy As Long
End Type
Type BY_HANDLE_FILE_INFORMATION
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
dwVolumeSerialNumber As Long
nFileSizeHigh As Long
nFileSizeLow As Long
nNumberOfLinks As Long
nFileIndexHigh As Long
nFileIndexLow As Long
End Type
Type MEMORY_BASIC_INFORMATION
BaseAddress As Long
AllocationBase As Long
AllocationProtect As Long
RegionSize As Long
State As Long
Protect As Long
lType As Long
End Type
Type EVENTLOGRECORD
Length As Long
Reserved As Long
RecordNumber As Long
TimeGenerated As Long
TimeWritten As Long
EventID As Long
EventType As Integer
NumStrings As Integer
EventCategory As Integer
ReservedFlags As Integer
ClosingRecordNumber As Long
StringOffset As Long
UserSidLength As Long
UserSidOffset As Long
DataLength As Long
DataOffset As Long
End Type
Type TOKEN_GROUPS
GroupCount As Long
Groups(ANYSIZE_ARRAY) As SID_AND_ATTRIBUTES
End Type
Type TOKEN_PRIVILEGES
PrivilegeCount As Long
Privileges(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES
End Type
Type CONTEXT
FltF0 As Double
FltF1 As Double
FltF2 As Double
FltF3 As Double
FltF4 As Double
FltF5 As Double
FltF6 As Double
FltF7 As Double
FltF8 As Double
FltF9 As Double
FltF10 As Double
FltF11 As Double
FltF12 As Double
FltF13 As Double
FltF14 As Double
FltF15 As Double
FltF16 As Double
FltF17 As Double
FltF18 As Double
FltF19 As Double
FltF20 As Double
FltF21 As Double
FltF22 As Double
FltF23 As Double
FltF24 As Double
FltF25 As Double
FltF26 As Double
FltF27 As Double
FltF28 As Double
FltF29 As Double
FltF30 As Double
FltF31 As Double
IntV0 As Double
IntT0 As Double
IntT1 As Double
IntT2 As Double
IntT3 As Double
IntT4 As Double
IntT5 As Double
IntT6 As Double
IntT7 As Double
IntS0 As Double
IntS1 As Double
IntS2 As Double
IntS3 As Double
IntS4 As Double
IntS5 As Double
IntFp As Double
IntA0 As Double
IntA1 As Double
IntA2 As Double
IntA3 As Double
IntA4 As Double
IntA5 As Double
IntT8 As Double
IntT9 As Double
IntT10 As Double
IntT11 As Double
IntRa As Double
IntT12 As Double
IntAt As Double
IntGp As Double
IntSp As Double
IntZero As Double
Fpcr As Double
SoftFpcr As Double
Fir As Double
Psr As Long
ContextFlags As Long
Fill(4) As Long
End Type
Type EXCEPTION_POINTERS
pExceptionRecord As EXCEPTION_RECORD
ContextRecord As CONTEXT
End Type
Type LDT_BYTES
BaseMid As Byte
Flags1 As Byte
Flags2 As Byte
BaseHi As Byte
End Type
Type LDT_ENTRY
LimitLow As Integer
BaseLow As Integer
HighWord As Long
End Type
Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(32) As Integer
StandardDate As SystemTime
StandardBias As Long
DaylightName(32) As Integer
DaylightDate As SystemTime
DaylightBias As Long
End Type
Type WIN32_STREAM_ID
dwStreamID As Long
dwStreamAttributes As Long
dwStreamSizeLow As Long
dwStreamSizeHigh As Long
dwStreamNameSize As Long
cStreamName As Byte
End Type
Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
Type CPINFO
MaxCharSize As Long
DefaultChar(MAX_DEFAULTCHAR) As Byte
LeadByte(MAX_LEADBYTES) As Byte
End Type
Type NUMBERFMT
NumDigits As Long
LeadingZero As Long
Grouping As Long
lpDecimalSep As String
lpThousandSep As String
NegativeOrder As Long
End Type
Type CURRENCYFMT
NumDigits As Long
LeadingZero As Long
Grouping As Long
lpDecimalSep As String
lpThousandSep As String
NegativeOrder As Long
PositiveOrder As Long
lpCurrencySymbol As String
End Type
Type COORD
X As Integer
Y As Integer
End Type
Type SMALL_RECT
Left As Integer
Top As Integer
Right As Integer
Bottom As Integer
End Type
Type KEY_EVENT_RECORD
bKeyDown As Long
wRepeatCount As Integer
wVirtualKeyCode As Integer
wVirtualScanCode As Integer
uChar As Integer
dwControlKeyState As Long
End Type
Type MOUSE_EVENT_RECORD
dwMousePosition As COORD
dwButtonState As Long
dwControlKeyState As Long
dwEventFlags As Long
End Type
Type WINDOW_BUFFER_SIZE_RECORD
dwSize As COORD
End Type
Type MENU_EVENT_RECORD
dwCommandId As Long
End Type
Type FOCUS_EVENT_RECORD
bSetFocus As Long
End Type
Type CHAR_INFO
Char As Integer
Attributes As Integer
End Type
Type CONSOLE_SCREEN_BUFFER_INFO
dwSize As COORD
dwCursorPosition As COORD
wAttributes As Integer
srWindow As SMALL_RECT
dwMaximumWindowSize As COORD
End Type
Type CONSOLE_CURSOR_INFO
dwSize As Long
bVisible As Long
End Type
Type xform
eM11 As Double
eM12 As Double
eM21 As Double
eM22 As Double
eDx As Double
eDy As Double
End Type
Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Type RGBTRIPLE
rgbtBlue As Byte
rgbtGreen As Byte
rgbtRed As Byte
End Type
Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Type BITMAPCOREHEADER
bcSize As Long
bcWidth As Integer
bcHeight As Integer
bcPlanes As Integer
bcBitCount As Integer
End Type
Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors As RGBQUAD
End Type
Type BITMAPCOREINFO
bmciHeader As BITMAPCOREHEADER
bmciColors As RGBTRIPLE
End Type
Type BITMAPFILEHEADER
bfType As Integer
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits As Long
End Typ