Add some windows datatypes that were missing from this file, and add

the aliases defined in windows header files for the structures.
This commit is contained in:
Thomas Heller 2006-06-13 08:56:14 +00:00
parent 6d3d339d21
commit a7e823fd2c
1 changed files with 72 additions and 26 deletions

View File

@ -1,63 +1,107 @@
###################################################################### ######################################################################
# This file should be kept compatible with Python 2.3, see PEP 291. # # This file should be kept compatible with Python 2.3, see PEP 291. #
###################################################################### ######################################################################
# XXX This module needs cleanup.
# The most useful windows datatypes
from ctypes import * from ctypes import *
DWORD = c_ulong
WORD = c_ushort
BYTE = c_byte BYTE = c_byte
WORD = c_ushort
DWORD = c_ulong
BOOLEAN = BYTE
BOOL = c_long
VARIANT_BOOL = c_short
ULONG = c_ulong ULONG = c_ulong
LONG = c_long LONG = c_long
# in the windows header files, these are structures.
LARGE_INTEGER = c_longlong LARGE_INTEGER = c_longlong
ULARGE_INTEGER = c_ulonglong ULARGE_INTEGER = c_ulonglong
LPCOLESTR = LPOLESTR = OLESTR = c_wchar_p
HANDLE = c_ulong # in the header files: void * LPCWSTR = LPWSTR = c_wchar_p
LPCSTR = LPSTR = c_char_p
HWND = HANDLE
HDC = HANDLE
HMODULE = HANDLE
HINSTANCE = HANDLE
HRGN = HANDLE
HTASK = HANDLE
HKEY = HANDLE
HPEN = HANDLE
HGDIOBJ = HANDLE
HMENU = HANDLE
LCID = DWORD
WPARAM = c_uint WPARAM = c_uint
LPARAM = c_long LPARAM = c_long
BOOL = c_long ATOM = WORD
VARIANT_BOOL = c_short LANGID = WORD
LPCOLESTR = LPOLESTR = OLESTR = c_wchar_p COLORREF = DWORD
LPCWSTR = LPWSTR = c_wchar_p LGRPID = DWORD
LCTYPE = DWORD
LPCSTR = LPSTR = c_char_p LCID = DWORD
################################################################
# HANDLE types
HANDLE = c_ulong # in the header files: void *
HACCEL = HANDLE
HBITMAP = HANDLE
HBRUSH = HANDLE
HCOLORSPACE = HANDLE
HDC = HANDLE
HDESK = HANDLE
HDWP = HANDLE
HENHMETAFILE = HANDLE
HFONT = HANDLE
HGDIOBJ = HANDLE
HGLOBAL = HANDLE
HHOOK = HANDLE
HICON = HANDLE
HINSTANCE = HANDLE
HKEY = HANDLE
HKL = HANDLE
HLOCAL = HANDLE
HMENU = HANDLE
HMETAFILE = HANDLE
HMODULE = HANDLE
HMONITOR = HANDLE
HPALETTE = HANDLE
HPEN = HANDLE
HRGN = HANDLE
HRSRC = HANDLE
HSTR = HANDLE
HTASK = HANDLE
HWINSTA = HANDLE
HWND = HANDLE
SC_HANDLE = HANDLE
SERVICE_STATUS_HANDLE = HANDLE
################################################################
# Some important structure definitions
class RECT(Structure): class RECT(Structure):
_fields_ = [("left", c_long), _fields_ = [("left", c_long),
("top", c_long), ("top", c_long),
("right", c_long), ("right", c_long),
("bottom", c_long)] ("bottom", c_long)]
RECTL = RECT tagRECT = _RECTL = RECTL = RECT
class _SMALL_RECT(Structure):
_fields_ = [('Left', c_short),
('Top', c_short),
('Right', c_short),
('Bottom', c_short)]
SMALL_RECT = _SMALL_RECT
class _COORD(Structure):
_fields_ = [('X', c_short),
('Y', c_short)]
class POINT(Structure): class POINT(Structure):
_fields_ = [("x", c_long), _fields_ = [("x", c_long),
("y", c_long)] ("y", c_long)]
POINTL = POINT tagPOINT = _POINTL = POINTL = POINT
class SIZE(Structure): class SIZE(Structure):
_fields_ = [("cx", c_long), _fields_ = [("cx", c_long),
("cy", c_long)] ("cy", c_long)]
SIZEL = SIZE tagSIZE = SIZEL = SIZE
def RGB(red, green, blue): def RGB(red, green, blue):
return red + (green << 8) + (blue << 16) return red + (green << 8) + (blue << 16)
@ -65,6 +109,7 @@ def RGB(red, green, blue):
class FILETIME(Structure): class FILETIME(Structure):
_fields_ = [("dwLowDateTime", DWORD), _fields_ = [("dwLowDateTime", DWORD),
("dwHighDateTime", DWORD)] ("dwHighDateTime", DWORD)]
_FILETIME = FILETIME
class MSG(Structure): class MSG(Structure):
_fields_ = [("hWnd", HWND), _fields_ = [("hWnd", HWND),
@ -73,6 +118,7 @@ class MSG(Structure):
("lParam", LPARAM), ("lParam", LPARAM),
("time", DWORD), ("time", DWORD),
("pt", POINT)] ("pt", POINT)]
tagMSG = MSG
MAX_PATH = 260 MAX_PATH = 260
class WIN32_FIND_DATAA(Structure): class WIN32_FIND_DATAA(Structure):