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


Python ctypes.wstring_at方法代码示例

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


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

示例1: windowProc

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import wstring_at [as 别名]
def windowProc(self, hwnd, msg, wParam, lParam):
		if msg != WM_COPYDATA:
			return
		hwnd = wParam
		struct_pointer = lParam
		message_data = ctypes.cast(struct_pointer, PCOPYDATASTRUCT)
		url = ctypes.wstring_at(message_data.contents.lpData)
		log.info("Received url: %s" % url)
		try:
			con_info = connection_info.ConnectionInfo.from_url(url)
		except connection_info.URLParsingError:
			wx.CallLater(50, gui.messageBox, parent=gui.mainFrame, caption=_("Invalid URL"),
			# Translators: Message shown when an invalid URL has been provided.
			message=_("Unable to parse url \"%s\"")%url, style=wx.OK | wx.ICON_ERROR)
			log.exception("unable to parse nvdaremote:// url %s" % url)
			raise
		log.info("Connection info: %r" % con_info)
		if callable(self.callback):
			wx.CallLater(50, self.callback, con_info) 
开发者ID:NVDARemote,项目名称:NVDARemote,代码行数:21,代码来源:url_handler.py

示例2: _extend_volumes

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import wstring_at [as 别名]
def _extend_volumes(self, pack, volume_indexes):
        for unk in _enumerate(pack.QueryVolumes()):
            volume = unk.QueryInterface(vds.IVdsVolume)
            volume_prop = volume.GetProperties()
            try:
                extend_volume = True
                if volume_indexes:
                    volume_name = ctypes.wstring_at(volume_prop.pwszName)
                    volume_idx = self._get_volume_index(volume_name)
                    if volume_idx not in volume_indexes:
                        extend_volume = False

                if extend_volume:
                    self._extend_volume(pack, volume, volume_prop)
            finally:
                ole32.CoTaskMemFree(volume_prop.pwszName) 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:18,代码来源:vds_storage_manager.py

示例3: _extend_volume

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import wstring_at [as 别名]
def _extend_volume(self, pack, volume, volume_prop):
        volume_extents = self._get_volume_extents_to_resize(pack,
                                                            volume_prop.id)
        input_disks = []

        for (volume_extent, volume_extend_size) in volume_extents:
            input_disk = vds.VDS_INPUT_DISK()
            input_disks.append(input_disk)

            input_disk.diskId = volume_extent.diskId
            input_disk.memberIdx = volume_extent.memberIdx
            input_disk.plexId = volume_extent.plexId
            input_disk.ullSize = volume_extend_size

        if input_disks:
            extend_size = sum([i.ullSize for i in input_disks])
            volume_name = ctypes.wstring_at(volume_prop.pwszName)
            LOG.info('Extending volume "%s" with %s bytes' %
                     (volume_name, extend_size))

            input_disks_ar = (vds.VDS_INPUT_DISK *
                              len(input_disks))(*input_disks)
            extend_job = volume.Extend(input_disks_ar, len(input_disks))
            extend_job.Wait() 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:26,代码来源:vds_storage_manager.py

示例4: preferredLanguages

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import wstring_at [as 别名]
def preferredLanguages(self):

        if platform=='darwin':
            return NSLocale.preferredLanguages()

        elif platform=='win32':

            def wszarray_to_list(array):
                offset = 0
                while offset < len(array):
                    sz = ctypes.wstring_at(ctypes.addressof(array) + offset*2)
                    if sz:
                        yield sz
                        offset += len(sz)+1
                    else:
                        break

            num = ctypes.c_ulong()
            size = ctypes.c_ulong(0)
            if (GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, ctypes.byref(num), None, ctypes.byref(size)) and size.value):
                buf = ctypes.create_unicode_buffer(size.value)
                if GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, ctypes.byref(num), ctypes.byref(buf), ctypes.byref(size)):
                    return wszarray_to_list(buf)
            return []

        else:	# POSIX
            lang = locale.getlocale()[0]
            return lang and [lang.replace('_','-')] or []

# singletons 
开发者ID:EDCD,项目名称:EDMarketConnector,代码行数:32,代码来源:l10n.py

示例5: get_tags

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import wstring_at [as 别名]
def get_tags(handle, tags = BASS_TAG_OGG):
	result = []
	addr = BASS_ChannelGetTags(handle, tags)
	res = b''
	while isinstance(res, (str, bytes)):
		res = ctypes.string_at(addr)
		#if sys.hexversion >= 0x03000000:
			#res = ctypes.wstring_at(addr)
		addr += len(res) + 1
		if res:
			if 32 < bass_ord(res[0]) < 256:
				result.append(res)
			else:
				res = None
	return result 
开发者ID:Wyliodrin,项目名称:pybass,代码行数:17,代码来源:pybass.py

示例6: get

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import wstring_at [as 别名]
def get(self, key):
            typ  = DWORD()
            size = DWORD()
            if RegQueryValueEx(self.hkey, key, 0, ctypes.byref(typ), None, ctypes.byref(size)) or typ.value not in [REG_SZ, REG_MULTI_SZ]:
                return None
            buf = ctypes.create_unicode_buffer(size.value / 2)
            if RegQueryValueEx(self.hkey, key, 0, ctypes.byref(typ), buf, ctypes.byref(size)):
                return None
            elif typ.value == REG_MULTI_SZ:
                return [x for x in ctypes.wstring_at(buf, len(buf)-2).split(u'\x00')]
            else:
                return unicode(buf.value) 
开发者ID:EDCD,项目名称:EDMarketConnector,代码行数:14,代码来源:config.py

示例7: EnumKey

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import wstring_at [as 别名]
def EnumKey(key, index):
    """This calls the Windows RegEnumKeyEx function in a Unicode safe way."""
    buf = ctypes.create_unicode_buffer(257)
    length = ctypes.wintypes.DWORD(257)
    rc = RegEnumKeyEx(key.handle, index, ctypes.cast(buf, ctypes.c_wchar_p),
                      ctypes.byref(length), LPDWORD(), ctypes.c_wchar_p(),
                      LPDWORD(), ctypes.POINTER(FileTime)())
    if rc != 0:
        raise ctypes.WinError(2)

    return ctypes.wstring_at(buf, length.value).rstrip(u"\x00") 
开发者ID:google,项目名称:rekall,代码行数:13,代码来源:registry.py

示例8: Reg2Py

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import wstring_at [as 别名]
def Reg2Py(data, size, data_type):
    if data_type == winreg.REG_DWORD:
        if size == 0:
            return 0
        return ctypes.cast(data, ctypes.POINTER(ctypes.c_int)).contents.value
    elif data_type == winreg.REG_SZ or data_type == winreg.REG_EXPAND_SZ:
        return ctypes.wstring_at(data, size // 2).rstrip(u"\x00")
    elif data_type == winreg.REG_MULTI_SZ:
        return ctypes.wstring_at(data, size // 2).rstrip(u"\x00").split(u"\x00")
    else:
        if size == 0:
            return None
        return ctypes.string_at(data, size) 
开发者ID:google,项目名称:rekall,代码行数:15,代码来源:registry.py

示例9: _decode_surrogatepass

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import wstring_at [as 别名]
def _decode_surrogatepass(data, codec):
    """Like data.decode(codec, 'surrogatepass') but makes utf-16-le/be work
    on Python < 3.4 + Windows

    https://bugs.python.org/issue27971

    Raises UnicodeDecodeError, LookupError
    """

    try:
        return data.decode(codec, _surrogatepass)
    except UnicodeDecodeError:
        if not _codec_can_decode_with_surrogatepass(codec):
            if _normalize_codec(codec) == "utf-16-be":
                data = _swap_bytes(data)
                codec = "utf-16-le"
            if _normalize_codec(codec) == "utf-16-le":
                buffer_ = ctypes.create_string_buffer(data + b"\x00\x00")
                value = ctypes.wstring_at(buffer_, len(data) // 2)
                if value.encode("utf-16-le", _surrogatepass) != data:
                    raise
                return value
            else:
                raise
        else:
            raise 
开发者ID:bugatsinho,项目名称:bugatsinho.github.io,代码行数:28,代码来源:_fsnative.py

示例10: FillDeviceAttributes

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import wstring_at [as 别名]
def FillDeviceAttributes(device, descriptor):
  """Fill out the attributes of the device.

  Fills the devices HidAttributes and product string
  into the descriptor.

  Args:
    device: A handle to the open device
    descriptor: The DeviceDescriptor to populate with the
      attributes.

  Returns:
    None

  Raises:
    WindowsError when unable to obtain attributes or product
      string.
  """
  attributes = HidAttributes()
  result = hid.HidD_GetAttributes(device, ctypes.byref(attributes))
  if not result:
    raise ctypes.WinError()

  buf = ctypes.create_string_buffer(1024)
  result = hid.HidD_GetProductString(device, buf, 1024)

  if not result:
    raise ctypes.WinError()

  descriptor.vendor_id = attributes.VendorID
  descriptor.product_id = attributes.ProductID
  descriptor.product_string = ctypes.wstring_at(buf) 
开发者ID:google,项目名称:pyu2f,代码行数:34,代码来源:windows.py

示例11: peb_syswow

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import wstring_at [as 别名]
def peb_syswow(self):
        """The 64bits PEB of a SysWow64 process

            :type: :class:`PEB`
		"""
        if not self.is_wow_64:
            raise ValueError("Not a syswow process")
        return windows.syswow64.get_current_process_syswow_peb()

    # TODO: use ctypes.string_ad / ctypes.wstring_at for read_string / read_wstring ? 
开发者ID:hakril,项目名称:PythonForWindows,代码行数:12,代码来源:process.py

示例12: __str__

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import wstring_at [as 别名]
def __str__(self):
        if self.value is None:
            return ""
        length = ctypes.c_uint32()
        ptr = WindowsGetStringRawBuffer(self, ctypes.byref(length))
        return ctypes.wstring_at(ptr, length.value) 
开发者ID:ninthDevilHAUNSTER,项目名称:ArknightsAutoHelper,代码行数:8,代码来源:winstring.py

示例13: Handler

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import wstring_at [as 别名]
def Handler(self, hwnd, mesg, wParam, lParam):
        if not self.runFlg:
            return True
        cpyData = cast(lParam, PCOPYDATASTRUCT)
        cmd = cpyData.contents.dwData
        msg = wstring_at(cpyData.contents.lpData)
        if cmd == CMD_CONNECT:
            self.mpcHwnd = int(msg)
            self.connected = True
            eg.TriggerEvent("Connected",prefix="MPC-HC")
        elif cmd == CMD_STATE:
            state = int(msg)
            if self.state != state:
                self.state = state
                eg.TriggerEvent("State."+MPC_LOADSTATE[state],prefix="MPC-HC")
        elif cmd == CMD_NOWPLAYING:
            if self.playstate == 3: # if the plugin is started when the MPC-HC is already playing
                self.playstate = 0
            msg = self.ParseMsg(msg)
            if msg !=  self.np_payload:
                self.np_payload = msg
                eg.TriggerEvent("NowPlaying",prefix="MPC-HC", payload = msg)

        elif cmd == CMD_PLAYMODE:
            self.playstate = int(msg)
            eg.TriggerEvent("Playstate."+MPC_PLAYSTATE[self.playstate],prefix="MPC-HC")

        elif cmd == CMD_NOTIFYSEEK:
            eg.TriggerEvent("Seek",prefix="MPC-HC",payload = int(0.5+float(msg)))

        elif cmd in (
            CMD_CURRENTPOSITION,
            CMD_LISTSUBTITLETRACKS,
            CMD_LISTAUDIOTRACKS,
            CMD_PLAYLIST
        ):
            if self.event:
                self.result = self.ParseMsg(msg)
                SetEvent(self.event)

        elif cmd == CMD_NOTIFYENDOFSTREAM:
            eg.TriggerEvent("EndOfStream",prefix="MPC-HC")
        return True 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:45,代码来源:__init__.py


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