1 ######################################################################
2 # This file should be kept compatible with Python 2.3, see PEP 291. #
3 ######################################################################
5 # The most useful windows datatypes
20 from ctypes
import _SimpleCData
21 class VARIANT_BOOL(_SimpleCData
):
24 return "%s(%r)" % (self
.__class
__.__name
__, self
.value
)
29 # in the windows header files, these are structures.
30 _LARGE_INTEGER
= LARGE_INTEGER
= c_longlong
31 _ULARGE_INTEGER
= ULARGE_INTEGER
= c_ulonglong
33 LPCOLESTR
= LPOLESTR
= OLESTR
= c_wchar_p
34 LPCWSTR
= LPWSTR
= c_wchar_p
35 LPCSTR
= LPSTR
= c_char_p
37 # WPARAM is defined as UINT_PTR (unsigned type)
38 # LPARAM is defined as LONG_PTR (signed type)
39 if sizeof(c_long
) == sizeof(c_void_p
):
42 elif sizeof(c_longlong
) == sizeof(c_void_p
):
55 ################################################################
57 HANDLE
= c_void_p
# in the header files: void *
89 SERVICE_STATUS_HANDLE
= HANDLE
91 ################################################################
92 # Some important structure definitions
94 class RECT(Structure
):
95 _fields_
= [("left", c_long
),
99 tagRECT
= _RECTL
= RECTL
= RECT
101 class _SMALL_RECT(Structure
):
102 _fields_
= [('Left', c_short
),
106 SMALL_RECT
= _SMALL_RECT
108 class _COORD(Structure
):
109 _fields_
= [('X', c_short
),
112 class POINT(Structure
):
113 _fields_
= [("x", c_long
),
115 tagPOINT
= _POINTL
= POINTL
= POINT
117 class SIZE(Structure
):
118 _fields_
= [("cx", c_long
),
120 tagSIZE
= SIZEL
= SIZE
122 def RGB(red
, green
, blue
):
123 return red
+ (green
<< 8) + (blue
<< 16)
125 class FILETIME(Structure
):
126 _fields_
= [("dwLowDateTime", DWORD
),
127 ("dwHighDateTime", DWORD
)]
130 class MSG(Structure
):
131 _fields_
= [("hWnd", HWND
),
140 class WIN32_FIND_DATAA(Structure
):
141 _fields_
= [("dwFileAttributes", DWORD
),
142 ("ftCreationTime", FILETIME
),
143 ("ftLastAccessTime", FILETIME
),
144 ("ftLastWriteTime", FILETIME
),
145 ("nFileSizeHigh", DWORD
),
146 ("nFileSizeLow", DWORD
),
147 ("dwReserved0", DWORD
),
148 ("dwReserved1", DWORD
),
149 ("cFileName", c_char
* MAX_PATH
),
150 ("cAlternameFileName", c_char
* 14)]
152 class WIN32_FIND_DATAW(Structure
):
153 _fields_
= [("dwFileAttributes", DWORD
),
154 ("ftCreationTime", FILETIME
),
155 ("ftLastAccessTime", FILETIME
),
156 ("ftLastWriteTime", FILETIME
),
157 ("nFileSizeHigh", DWORD
),
158 ("nFileSizeLow", DWORD
),
159 ("dwReserved0", DWORD
),
160 ("dwReserved1", DWORD
),
161 ("cFileName", c_wchar
* MAX_PATH
),
162 ("cAlternameFileName", c_wchar
* 14)]
164 __all__
= ['ATOM', 'BOOL', 'BOOLEAN', 'BYTE', 'COLORREF', 'DOUBLE',
165 'DWORD', 'FILETIME', 'HACCEL', 'HANDLE', 'HBITMAP', 'HBRUSH',
166 'HCOLORSPACE', 'HDC', 'HDESK', 'HDWP', 'HENHMETAFILE', 'HFONT',
167 'HGDIOBJ', 'HGLOBAL', 'HHOOK', 'HICON', 'HINSTANCE', 'HKEY',
168 'HKL', 'HLOCAL', 'HMENU', 'HMETAFILE', 'HMODULE', 'HMONITOR',
169 'HPALETTE', 'HPEN', 'HRGN', 'HRSRC', 'HSTR', 'HTASK', 'HWINSTA',
170 'HWND', 'LANGID', 'LARGE_INTEGER', 'LCID', 'LCTYPE', 'LGRPID',
171 'LONG', 'LPARAM', 'LPCOLESTR', 'LPCSTR', 'LPCWSTR', 'LPOLESTR',
172 'LPSTR', 'LPWSTR', 'MAX_PATH', 'MSG', 'OLESTR', 'POINT',
173 'POINTL', 'RECT', 'RECTL', 'RGB', 'SC_HANDLE',
174 'SERVICE_STATUS_HANDLE', 'SIZE', 'SIZEL', 'SMALL_RECT', 'UINT',
175 'ULARGE_INTEGER', 'ULONG', 'VARIANT_BOOL', 'WCHAR',
176 'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW', 'WORD', 'WPARAM', '_COORD',
177 '_FILETIME', '_LARGE_INTEGER', '_POINTL', '_RECTL', '_SMALL_RECT',
178 '_ULARGE_INTEGER', 'tagMSG', 'tagPOINT', 'tagRECT', 'tagSIZE']