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


Python wintypes.LPSTR属性代码示例

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


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

示例1: wide2utf8

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import LPSTR [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

示例2: get_system_wow_64_dir_a

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

示例3: __str_to_winastr__

# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import LPSTR [as 别名]
def __str_to_winastr__(self, in_str_u):
		"""
		In: Python unicode string
		Out: ANSI_STRING
		"""

		in_str_a = in_str_u.encode('utf-8')
		in_astr = ANSI_STRING()
		in_astr.Length = len(in_str_a)
		in_astr.MaximumLength = len(in_str_a) + 2
		in_astr.Buffer = wintypes.LPSTR(in_str_a)

		return in_astr 
开发者ID:pleiszenburg,项目名称:zugbruecke,代码行数:15,代码来源:path.py


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