Coverage for ctypes\wintypes.py: 0%

# Coverage for ctypes\wintypes.py : 0%

## 130 statements 0 run 130 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | # The most useful windows datatypes import ctypes BYTE = ctypes.c_byte WORD = ctypes.c_ushort DWORD = ctypes.c_ulong #UCHAR = ctypes.c_uchar CHAR = ctypes.c_char WCHAR = ctypes.c_wchar UINT = ctypes.c_uint INT = ctypes.c_int DOUBLE = ctypes.c_double FLOAT = ctypes.c_float BOOLEAN = BYTE BOOL = ctypes.c_long class VARIANT_BOOL(ctypes._SimpleCData): _type_ = "v" def __repr__(self): return "%s(%r)" % (self.__class__.__name__, self.value) ULONG = ctypes.c_ulong LONG = ctypes.c_long USHORT = ctypes.c_ushort SHORT = ctypes.c_short # in the windows header files, these are structures. _LARGE_INTEGER = LARGE_INTEGER = ctypes.c_longlong _ULARGE_INTEGER = ULARGE_INTEGER = ctypes.c_ulonglong LPCOLESTR = LPOLESTR = OLESTR = ctypes.c_wchar_p LPCWSTR = LPWSTR = ctypes.c_wchar_p LPCSTR = LPSTR = ctypes.c_char_p LPCVOID = LPVOID = ctypes.c_void_p # WPARAM is defined as UINT_PTR (unsigned type) # LPARAM is defined as LONG_PTR (signed type) if ctypes.sizeof(ctypes.c_long) == ctypes.sizeof(ctypes.c_void_p): WPARAM = ctypes.c_ulong LPARAM = ctypes.c_long elif ctypes.sizeof(ctypes.c_longlong) == ctypes.sizeof(ctypes.c_void_p): WPARAM = ctypes.c_ulonglong LPARAM = ctypes.c_longlong ATOM = WORD LANGID = WORD COLORREF = DWORD LGRPID = DWORD LCTYPE = DWORD LCID = DWORD ################################################################ # HANDLE types HANDLE = ctypes.c_void_p # 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(ctypes.Structure): _fields_ = [("left", LONG), ("top", LONG), ("right", LONG), ("bottom", LONG)] tagRECT = _RECTL = RECTL = RECT class _SMALL_RECT(ctypes.Structure): _fields_ = [('Left', SHORT), ('Top', SHORT), ('Right', SHORT), ('Bottom', SHORT)] SMALL_RECT = _SMALL_RECT class _COORD(ctypes.Structure): _fields_ = [('X', SHORT), ('Y', SHORT)] class POINT(ctypes.Structure): _fields_ = [("x", LONG), ("y", LONG)] tagPOINT = _POINTL = POINTL = POINT class SIZE(ctypes.Structure): _fields_ = [("cx", LONG), ("cy", LONG)] tagSIZE = SIZEL = SIZE def RGB(red, green, blue): return red + (green << 8) + (blue << 16) class FILETIME(ctypes.Structure): _fields_ = [("dwLowDateTime", DWORD), ("dwHighDateTime", DWORD)] _FILETIME = FILETIME class MSG(ctypes.Structure): _fields_ = [("hWnd", HWND), ("message", UINT), ("wParam", WPARAM), ("lParam", LPARAM), ("time", DWORD), ("pt", POINT)] tagMSG = MSG MAX_PATH = 260 class WIN32_FIND_DATAA(ctypes.Structure): _fields_ = [("dwFileAttributes", DWORD), ("ftCreationTime", FILETIME), ("ftLastAccessTime", FILETIME), ("ftLastWriteTime", FILETIME), ("nFileSizeHigh", DWORD), ("nFileSizeLow", DWORD), ("dwReserved0", DWORD), ("dwReserved1", DWORD), ("cFileName", CHAR * MAX_PATH), ("cAlternateFileName", CHAR * 14)] class WIN32_FIND_DATAW(ctypes.Structure): _fields_ = [("dwFileAttributes", DWORD), ("ftCreationTime", FILETIME), ("ftLastAccessTime", FILETIME), ("ftLastWriteTime", FILETIME), ("nFileSizeHigh", DWORD), ("nFileSizeLow", DWORD), ("dwReserved0", DWORD), ("dwReserved1", DWORD), ("cFileName", WCHAR * MAX_PATH), ("cAlternateFileName", WCHAR * 14)] ################################################################ # Pointer types LPBOOL = PBOOL = ctypes.POINTER(BOOL) PBOOLEAN = ctypes.POINTER(BOOLEAN) LPBYTE = PBYTE = ctypes.POINTER(BYTE) PCHAR = ctypes.POINTER(CHAR) LPCOLORREF = ctypes.POINTER(COLORREF) LPDWORD = PDWORD = ctypes.POINTER(DWORD) LPFILETIME = PFILETIME = ctypes.POINTER(FILETIME) PFLOAT = ctypes.POINTER(FLOAT) LPHANDLE = PHANDLE = ctypes.POINTER(HANDLE) PHKEY = ctypes.POINTER(HKEY) LPHKL = ctypes.POINTER(HKL) LPINT = PINT = ctypes.POINTER(INT) PLARGE_INTEGER = ctypes.POINTER(LARGE_INTEGER) PLCID = ctypes.POINTER(LCID) LPLONG = PLONG = ctypes.POINTER(LONG) LPMSG = PMSG = ctypes.POINTER(MSG) LPPOINT = PPOINT = ctypes.POINTER(POINT) PPOINTL = ctypes.POINTER(POINTL) LPRECT = PRECT = ctypes.POINTER(RECT) LPRECTL = PRECTL = ctypes.POINTER(RECTL) LPSC_HANDLE = ctypes.POINTER(SC_HANDLE) PSHORT = ctypes.POINTER(SHORT) LPSIZE = PSIZE = ctypes.POINTER(SIZE) LPSIZEL = PSIZEL = ctypes.POINTER(SIZEL) PSMALL_RECT = ctypes.POINTER(SMALL_RECT) LPUINT = PUINT = ctypes.POINTER(UINT) PULARGE_INTEGER = ctypes.POINTER(ULARGE_INTEGER) PULONG = ctypes.POINTER(ULONG) PUSHORT = ctypes.POINTER(USHORT) PWCHAR = ctypes.POINTER(WCHAR) LPWIN32_FIND_DATAA = PWIN32_FIND_DATAA = ctypes.POINTER(WIN32_FIND_DATAA) LPWIN32_FIND_DATAW = PWIN32_FIND_DATAW = ctypes.POINTER(WIN32_FIND_DATAW) LPWORD = PWORD = ctypes.POINTER(WORD)