當前位置: 首頁>>代碼示例>>Python>>正文


Python wintypes.WCHAR屬性代碼示例

本文整理匯總了Python中ctypes.wintypes.WCHAR屬性的典型用法代碼示例。如果您正苦於以下問題:Python wintypes.WCHAR屬性的具體用法?Python wintypes.WCHAR怎麽用?Python wintypes.WCHAR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在ctypes.wintypes的用法示例。


在下文中一共展示了wintypes.WCHAR屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from ctypes import wintypes [as 別名]
# 或者: from ctypes.wintypes import WCHAR [as 別名]
def __init__(self, filter_in, events):
        struct_size = len(events) * ct.sizeof(wt.USHORT) + ct.sizeof(EVENT_FILTER_EVENT_ID)
        self._buf = (ct.c_char * struct_size)()
        self._props = ct.cast(ct.pointer(self._buf), ct.POINTER(EVENT_FILTER_EVENT_ID))
        self._props.contents.FilterIn = filter_in
        self._props.contents.Reserved = 0
        self._props.contents.Count = len(events)

        for i in range(len(events)):
            ct.memmove(ct.cast(ct.addressof(self._buf) + ct.sizeof(EVENT_FILTER_EVENT_ID) + (ct.sizeof(wt.WCHAR) * i),
                               ct.c_void_p),
                       ct.byref(wt.USHORT(events[i])),
                       ct.sizeof(wt.WCHAR)) 
開發者ID:fireeye,項目名稱:pywintrace,代碼行數:15,代碼來源:evntprov.py

示例2: _get_cch_referenced_domain_name

# 需要導入模塊: from ctypes import wintypes [as 別名]
# 或者: from ctypes.wintypes import WCHAR [as 別名]
def _get_cch_referenced_domain_name(domain_name):
        return wintypes.DWORD(
            ctypes.sizeof(domain_name) // ctypes.sizeof(wintypes.WCHAR)) 
開發者ID:cloudbase,項目名稱:cloudbase-init,代碼行數:5,代碼來源:windows.py

示例3: PrintName

# 需要導入模塊: from ctypes import wintypes [as 別名]
# 或者: from ctypes.wintypes import WCHAR [as 別名]
def PrintName(self):
    arrayt = WCHAR * (self.PrintNameLength // 2)
    offset = type(self).PathBuffer.offset + self.PrintNameOffset
    return arrayt.from_address(addressof(self) + offset).value 
開發者ID:GerritCodeReview,項目名稱:git-repo,代碼行數:6,代碼來源:platform_utils_win32.py

示例4: _get_physical_monitors_from_hmonitor

# 需要導入模塊: from ctypes import wintypes [as 別名]
# 或者: from ctypes.wintypes import WCHAR [as 別名]
def _get_physical_monitors_from_hmonitor(hmonitor: wintypes.HMONITOR) -> list:
    """
    Retrieves the physical monitors associated with an HMONITOR monitor handle

    https://msdn.microsoft.com/en-us/library/vs/alm/dd692950(v=vs.85).aspx
    BOOL GetPhysicalMonitorsFromHMONITOR(
        _In_   HMONITOR hMonitor,
        _In_   DWORD dwPhysicalMonitorArraySize,
        _Out_  LPPHYSICAL_MONITOR pPhysicalMonitorArray
    );
    
    Retrieves the number of physical monitors associated with an HMONITOR monitor handle.
    Call this function before calling GetPhysicalMonitorsFromHMONITOR.
    https://msdn.microsoft.com/en-us/library/dd692948(v=vs.85).aspx
    BOOL GetNumberOfPhysicalMonitorsFromHMONITOR(
        _In_   HMONITOR hMonitor,
        _Out_  LPDWORD pdwNumberOfPhysicalMonitors
    );

    :param hmonitor:
    :return:

    """
    class _PhysicalMonitorStructure(ctypes.Structure):
        """
        PHYSICAL_MONITOR Structure.
        https://msdn.microsoft.com/en-us/library/vs/alm/dd692967(v=vs.85).aspx
        typedef struct _PHYSICAL_MONITOR {
            HANDLE hPhysicalMonitor;
            WCHAR  szPhysicalMonitorDescription[PHYSICAL_MONITOR_DESCRIPTION_SIZE];
        } PHYSICAL_MONITOR, *LPPHYSICAL_MONITOR;

        PHYSICAL_MONITOR_DESCRIPTION_SIZE = 128
        """
        _fields_ = [
            ("hPhysicalMonitor", wintypes.HANDLE),
            ("szPhysicalMonitorDescription", wintypes.WCHAR * 128)
        ]

    # Retrieves the number of physical monitors
    phy_monitor_number = wintypes.DWORD()
    api_call_get_number = ctypes.windll.Dxva2.GetNumberOfPhysicalMonitorsFromHMONITOR
    if not api_call_get_number(hmonitor, ctypes.byref(phy_monitor_number)):
        _LOGGER.error(ctypes.WinError())
        return []
    
    # Retrieves the physical monitors
    api_call_get_monitor = ctypes.windll.Dxva2.GetPhysicalMonitorsFromHMONITOR
    # create array
    phy_monitor_array = (_PhysicalMonitorStructure * phy_monitor_number.value)()
    if not api_call_get_monitor(hmonitor, phy_monitor_number, phy_monitor_array):
        _LOGGER.error(ctypes.WinError())
        return []
    
    return list(phy_monitor_array) 
開發者ID:dot-osk,項目名稱:monitor_ctrl,代碼行數:57,代碼來源:vcp.py


注:本文中的ctypes.wintypes.WCHAR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。