Пример #1
0
    def __get_device(self, device_id):
        device = self.__device_enum.get_device(device_id)
        device_topology = comtypes.cast(
            device.Activate(
                IID_IDeviceTopology,
                CLSCTX_INPROC_SERVER
            ),
            PIDeviceTopology
        )

        return AudioDevice(
            device_topology.GetDeviceId(),
            self.__device_enum
        )
Пример #2
0
    def __default_endpoint(self):
        from device import AudioDevice

        endpoint = self.__device_enum.default_endpoint(self.__data_flow)

        device_topology = comtypes.cast(
            endpoint.Activate(IID_IDeviceTopology, CLSCTX_INPROC_SERVER),
            PIDeviceTopology)

        device = AudioDevice(device_topology.GetDeviceId(), self.__device_enum)

        endpoint_id = endpoint.GetId()

        for endpoint in device:
            if endpoint.id == endpoint_id:
                return endpoint
Пример #3
0
    def __devices(self):
        used_names = []

        for endpt in self.__device_enum.endpoints:
            pStore = endpt.OpenPropertyStore(STGM_READ)
            try:
                name = pStore.GetValue(PKEY_DeviceInterface_FriendlyName)
            except comtypes.COMError:
                continue

            if name not in used_names:
                used_names += [name]
                device_topology = comtypes.cast(
                    endpt.Activate(IID_IDeviceTopology, CLSCTX_INPROC_SERVER),
                    PIDeviceTopology)

                yield AudioDevice(device_topology.GetDeviceId(),
                                  self.__device_enum)
Пример #4
0
 def activate(self, iid, pointer):
     return comtypes.cast(self.__part.Activate(CLSCTX_INPROC_SERVER, iid),
                          pointer)
Пример #5
0
            'Unregister',
            (['in'], DWORD, 'dwCookie'),
        ),
    ]


comtypes.CoInitialize()

pServiceProvider = comtypes.CoCreateInstance(
    CLSID_ImmersiveShell,
    IServiceProvider,
    comtypes.CLSCTX_LOCAL_SERVER,
)

pDesktopManagerInternal = comtypes.cast(
    pServiceProvider.QueryService(CLSID_VirtualDesktopManagerInternal,
                                  IID_IVirtualDesktopManagerInternal),
    ctypes.POINTER(IVirtualDesktopManagerInternal))

pObjectArray = POINTER(IObjectArray)()

pDesktopManagerInternal.GetDesktops(ctypes.byref(pObjectArray))

count = UINT()
pObjectArray.GetCount(ctypes.byref(count))

for i in range(count):
    pDesktop = POINTER(IVirtualDesktop)()
    pObjectArray.GetAt(i, IID_IVirtualDesktop, ctypes.byref(pDesktop))

    id = GUID()
    pDesktop.GetID(ctypes.byref(id))
Пример #6
0
 def __activate(self, iid, pointer):
     try:
         return comtypes.cast(
             self.__endpoint.Activate(iid, CLSCTX_INPROC_SERVER), pointer)
     except comtypes.COMError:
         raise AttributeError
Пример #7
0
 def __device_topology(self):
     return comtypes.cast(
         self.__endpoint.Activate(IID_IDeviceTopology,
                                  CLSCTX_INPROC_SERVER), PIDeviceTopology)