Python ctypes.wintypes.LPCSTR Examples
The following are 6
code examples of ctypes.wintypes.LPCSTR().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ctypes.wintypes
, or try the search function
.
Example #1
Source File: driverlib.py From win_driver_plugin with BSD 3-Clause "New" or "Revised" License | 6 votes |
def open_device(self, access=GENERIC_READ | GENERIC_WRITE, mode=0, creation=OPEN_EXISTING, flags=FILE_ATTRIBUTE_NORMAL): """See: CreateFile function http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx """ CreateFile_Fn = ctypes.windll.kernel32.CreateFileA CreateFile_Fn.argtypes = [ wintypes.LPCSTR, # _In_ LPCTSTR lpFileName wintypes.DWORD, # _In_ DWORD dwDesiredAccess wintypes.DWORD, # _In_ DWORD dwShareMode LPSECURITY_ATTRIBUTES, # _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes wintypes.DWORD, # _In_ DWORD dwCreationDisposition wintypes.DWORD, # _In_ DWORD dwFlagsAndAttributes wintypes.HANDLE] # _In_opt_ HANDLE hTemplateFile CreateFile_Fn.restype = wintypes.HANDLE self.handle = wintypes.HANDLE(CreateFile_Fn('\\\\.\\' + self.name, access, mode, NULL, creation, flags, NULL))
Example #2
Source File: generic.py From quantipy with MIT License | 5 votes |
def wide2utf8(self, fn): """Take a unicode file name string and encode it to a multibyte string that Windows can use to represent file names (CP65001, UTF-8) http://msdn.microsoft.com/en-us/library/windows/desktop/dd374130""" from ctypes import wintypes _CP_UTF8 = 65001 _CP_ACP = 0 # ANSI _LPBOOL = POINTER(c_long) _wideCharToMultiByte = windll.kernel32.WideCharToMultiByte _wideCharToMultiByte.restype = c_int _wideCharToMultiByte.argtypes = [wintypes.UINT, wintypes.DWORD, wintypes.LPCWSTR, c_int, wintypes.LPSTR, c_int, wintypes.LPCSTR, _LPBOOL] codePage = _CP_UTF8 dwFlags = 0 lpWideCharStr = fn cchWideChar = len(fn) lpMultiByteStr = None cbMultiByte = 0 # zero requests size lpDefaultChar = None lpUsedDefaultChar = None # get size mbcssize = _wideCharToMultiByte( codePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar) if mbcssize <= 0: raise WinError(mbcssize) lpMultiByteStr = create_string_buffer(mbcssize) # convert retcode = _wideCharToMultiByte( codePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, mbcssize, lpDefaultChar, lpUsedDefaultChar) if retcode <= 0: raise WinError(retcode) return lpMultiByteStr.value
Example #3
Source File: win.py From gd.py with MIT License | 5 votes |
def get_module_handle(module_name: wintypes.LPCSTR) -> wintypes.HMODULE: pass
Example #4
Source File: win.py From gd.py with MIT License | 5 votes |
def get_proc_address( module_handle: wintypes.HMODULE, proc_name: wintypes.LPCSTR ) -> wintypes.LPVOID: pass
Example #5
Source File: win.py From gd.py with MIT License | 5 votes |
def find_window(class_name: wintypes.LPCSTR, title: wintypes.LPCSTR) -> wintypes.HWND: pass
Example #6
Source File: threadmgr.py From opsbro with MIT License | 4 votes |
def namer(): # If no ctypes, like in a static python build: exit try: import ctypes except ImportError: return import threading import time from ctypes import wintypes class THREADNAME_INFO(ctypes.Structure): _pack_ = 8 _fields_ = [ ("dwType", wintypes.DWORD), ("szName", wintypes.LPCSTR), ("dwThreadID", wintypes.DWORD), ("dwFlags", wintypes.DWORD), ] def __init__(self): self.dwType = 0x1000 self.dwFlags = 0 def debugChecker(): kernel32 = ctypes.WinDLL("kernel32", use_last_error=True) RaiseException = kernel32.RaiseException RaiseException.argtypes = [ wintypes.DWORD, wintypes.DWORD, wintypes.DWORD, ctypes.c_void_p] RaiseException.restype = None IsDebuggerPresent = kernel32.IsDebuggerPresent IsDebuggerPresent.argtypes = [] IsDebuggerPresent.restype = wintypes.BOOL MS_VC_EXCEPTION = 0x406D1388 info = THREADNAME_INFO() while True: time.sleep(1) if IsDebuggerPresent(): for thread in threading.enumerate(): if thread.ident is None: continue # not started if hasattr(threading, "_MainThread"): if isinstance(thread, threading._MainThread): continue # don't name the main thread info.szName = "%s (Python)" % (thread.name,) info.dwThreadID = thread.ident try: RaiseException(MS_VC_EXCEPTION, 0, ctypes.sizeof(info) / ctypes.sizeof( ctypes.c_void_p), ctypes.addressof(info)) except: pass dt = threading.Thread(target=debugChecker, name="MSVC debugging support thread") dt.daemon = True dt.start()