1 ######################################################################
2 # This file should be kept compatible with Python 2.3, see PEP 291. #
3 ######################################################################
5 # The most useful windows datatypes
22 from ctypes
import _SimpleCData
23 class VARIANT_BOOL(_SimpleCData
):
26 return "%s(%r)" % (self
.__class
__.__name
__, self
.value
)
34 # in the windows header files, these are structures.
35 _LARGE_INTEGER
= LARGE_INTEGER
= c_longlong
36 _ULARGE_INTEGER
= ULARGE_INTEGER
= c_ulonglong
38 LPCOLESTR
= LPOLESTR
= OLESTR
= c_wchar_p
39 LPCWSTR
= LPWSTR
= c_wchar_p
40 LPCSTR
= LPSTR
= c_char_p
41 LPCVOID
= LPVOID
= c_void_p
43 # WPARAM is defined as UINT_PTR (unsigned type)
44 # LPARAM is defined as LONG_PTR (signed type)
45 if sizeof(c_long
) == sizeof(c_void_p
):
48 elif sizeof(c_longlong
) == sizeof(c_void_p
):
61 ################################################################
63 HANDLE
= c_void_p
# in the header files: void *
95 SERVICE_STATUS_HANDLE
= HANDLE
97 ################################################################
98 # Some important structure definitions
100 class RECT(Structure
):
101 _fields_
= [("left", c_long
),
105 tagRECT
= _RECTL
= RECTL
= RECT
107 class _SMALL_RECT(Structure
):
108 _fields_
= [('Left', c_short
),
112 SMALL_RECT
= _SMALL_RECT
114 class _COORD(Structure
):
115 _fields_
= [('X', c_short
),
118 class POINT(Structure
):
119 _fields_
= [("x", c_long
),
121 tagPOINT
= _POINTL
= POINTL
= POINT
123 class SIZE(Structure
):
124 _fields_
= [("cx", c_long
),
126 tagSIZE
= SIZEL
= SIZE
128 def RGB(red
, green
, blue
):
129 return red
+ (green
<< 8) + (blue
<< 16)
131 class FILETIME(Structure
):
132 _fields_
= [("dwLowDateTime", DWORD
),
133 ("dwHighDateTime", DWORD
)]
136 class MSG(Structure
):
137 _fields_
= [("hWnd", HWND
),
146 class WIN32_FIND_DATAA(Structure
):
147 _fields_
= [("dwFileAttributes", DWORD
),
148 ("ftCreationTime", FILETIME
),
149 ("ftLastAccessTime", FILETIME
),
150 ("ftLastWriteTime", FILETIME
),
151 ("nFileSizeHigh", DWORD
),
152 ("nFileSizeLow", DWORD
),
153 ("dwReserved0", DWORD
),
154 ("dwReserved1", DWORD
),
155 ("cFileName", c_char
* MAX_PATH
),
156 ("cAlternateFileName", c_char
* 14)]
158 class WIN32_FIND_DATAW(Structure
):
159 _fields_
= [("dwFileAttributes", DWORD
),
160 ("ftCreationTime", FILETIME
),
161 ("ftLastAccessTime", FILETIME
),
162 ("ftLastWriteTime", FILETIME
),
163 ("nFileSizeHigh", DWORD
),
164 ("nFileSizeLow", DWORD
),
165 ("dwReserved0", DWORD
),
166 ("dwReserved1", DWORD
),
167 ("cFileName", c_wchar
* MAX_PATH
),
168 ("cAlternateFileName", c_wchar
* 14)]
170 __all__
= ['ATOM', 'BOOL', 'BOOLEAN', 'BYTE', 'COLORREF', 'DOUBLE', 'DWORD',
171 'FILETIME', 'FLOAT', 'HACCEL', 'HANDLE', 'HBITMAP', 'HBRUSH',
172 'HCOLORSPACE', 'HDC', 'HDESK', 'HDWP', 'HENHMETAFILE', 'HFONT',
173 'HGDIOBJ', 'HGLOBAL', 'HHOOK', 'HICON', 'HINSTANCE', 'HKEY',
174 'HKL', 'HLOCAL', 'HMENU', 'HMETAFILE', 'HMODULE', 'HMONITOR',
175 'HPALETTE', 'HPEN', 'HRGN', 'HRSRC', 'HSTR', 'HTASK', 'HWINSTA',
176 'HWND', 'INT', 'LANGID', 'LARGE_INTEGER', 'LCID', 'LCTYPE',
177 'LGRPID', 'LONG', 'LPARAM', 'LPCOLESTR', 'LPCSTR', 'LPCVOID',
178 'LPCWSTR', 'LPOLESTR', 'LPSTR', 'LPVOID', 'LPWSTR', 'MAX_PATH',
179 'MSG', 'OLESTR', 'POINT', 'POINTL', 'RECT', 'RECTL', 'RGB',
180 'SC_HANDLE', 'SERVICE_STATUS_HANDLE', 'SHORT', 'SIZE', 'SIZEL',
181 'SMALL_RECT', 'UINT', 'ULARGE_INTEGER', 'ULONG', 'USHORT',
182 'VARIANT_BOOL', 'WCHAR', 'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW',
183 'WORD', 'WPARAM', '_COORD', '_FILETIME', '_LARGE_INTEGER',
184 '_POINTL', '_RECTL', '_SMALL_RECT', '_ULARGE_INTEGER', 'tagMSG',
185 'tagPOINT', 'tagRECT', 'tagSIZE']