当前位置: 首页>>代码示例>>Python>>正文


Python wintypes.LPCSTR属性代码示例

本文整理汇总了Python中ctypes.wintypes.LPCSTR属性的典型用法代码示例。如果您正苦于以下问题:Python wintypes.LPCSTR属性的具体用法?Python wintypes.LPCSTR怎么用?Python wintypes.LPCSTR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在ctypes.wintypes的用法示例。


在下文中一共展示了wintypes.LPCSTR属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: open_device

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import LPCSTR [as 别名]
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)) 
开发者ID:FSecureLABS,项目名称:win_driver_plugin,代码行数:25,代码来源:driverlib.py

示例2: wide2utf8

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import LPCSTR [as 别名]
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 
开发者ID:Quantipy,项目名称:quantipy,代码行数:43,代码来源:generic.py

示例3: get_module_handle

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import LPCSTR [as 别名]
def get_module_handle(module_name: wintypes.LPCSTR) -> wintypes.HMODULE:
    pass 
开发者ID:NeKitDS,项目名称:gd.py,代码行数:4,代码来源:win.py

示例4: get_proc_address

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import LPCSTR [as 别名]
def get_proc_address(
    module_handle: wintypes.HMODULE, proc_name: wintypes.LPCSTR
) -> wintypes.LPVOID:
    pass 
开发者ID:NeKitDS,项目名称:gd.py,代码行数:6,代码来源:win.py

示例5: find_window

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import LPCSTR [as 别名]
def find_window(class_name: wintypes.LPCSTR, title: wintypes.LPCSTR) -> wintypes.HWND:
    pass 
开发者ID:NeKitDS,项目名称:gd.py,代码行数:4,代码来源:win.py

示例6: namer

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import LPCSTR [as 别名]
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() 
开发者ID:naparuba,项目名称:opsbro,代码行数:63,代码来源:threadmgr.py


注:本文中的ctypes.wintypes.LPCSTR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。