Esempio n. 1
0
class IMMDeviceEnumerator(comtypes.IUnknown):
    _iid_ = IID_IMMDeviceEnumerator
    _methods_ = (
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "EnumAudioEndpoints",
            (["in"], wintypes.DWORD, "dataFlow"),
            (["in"], wintypes.DWORD, "dwStateMask"),
            (["out", "retval"], ctypes.POINTER(PIMMDeviceCollection), "ppDevices"),
        ),
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "GetDefaultAudioEndpoint",
            (["in"], wintypes.DWORD, "dataFlow"),
            (["in"], wintypes.DWORD, "role"),
            (["out", "retval"], ctypes.POINTER(PIMMDevice), "ppDevices"),
        ),
    )

    @classmethod
    def get_default(cls, dataFlow, role):
        enumerator = comtypes.CoCreateInstance(
            CLSID_MMDeviceEnumerator, cls, comtypes.CLSCTX_INPROC_SERVER
        )
        return enumerator.GetDefaultAudioEndpoint(dataFlow, role)
Esempio n. 2
0
class IVdsVolume(comtypes.IUnknown):
    _iid_ = comtypes.GUID("{88306bb2-e71f-478c-86a2-79da200a0f11}")

    _methods_ = [
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'GetProperties',
            (['out'], ctypes.POINTER(VDS_VOLUME_PROP), 'pVolumeProperties')),
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'GetPack',
            (['out'], ctypes.POINTER(ctypes.POINTER(IVdsPack)), 'ppPack')),
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'QueryPlexes',
            (['out'], ctypes.POINTER(
                ctypes.POINTER(IEnumVdsObject)), 'ppEnum')),
        comtypes.COMMETHOD(
            [],
            comtypes.HRESULT,
            'Extend',
            (['in'], ctypes.POINTER(VDS_INPUT_DISK), 'pInputDiskArray'),
            (['in'], wintypes.LONG, 'lNumberOfDisks'),
            (['out'], ctypes.POINTER(ctypes.POINTER(IVdsAsync)), 'ppAsync'),
        ),
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'Shrink',
            (['in'], wintypes.ULARGE_INTEGER, 'ullNumberOfBytesToRemove'),
            (['out'], ctypes.POINTER(ctypes.POINTER(IVdsAsync)), 'ppAsync')),
    ]
Esempio n. 3
0
class IVdsServiceSAN(comtypes.IUnknown):
    _iid_ = comtypes.GUID("{fc5d23e8-a88b-41a5-8de0-2d2f73c5a630}")

    _methods_ = [
        comtypes.COMMETHOD([], comtypes.HRESULT, 'GetSANPolicy',
                           (['out'], ctypes.POINTER(wintypes.DWORD),
                            'pSanPolicy')),
        comtypes.COMMETHOD([], comtypes.HRESULT, 'SetSANPolicy',
                           (['in'], wintypes.DWORD, 'SanPolicy')),
    ]
Esempio n. 4
0
class IVdsService(comtypes.IUnknown):
    _iid_ = comtypes.GUID("{0818a8ef-9ba9-40d8-a6f9-e22833cc771e}")

    _methods_ = [
        comtypes.COMMETHOD([], comtypes.HRESULT, 'IsServiceReady'),
        comtypes.COMMETHOD([], comtypes.HRESULT, 'WaitForServiceReady'),
        comtypes.COMMETHOD([], comtypes.HRESULT, 'GetProperties',
                           (['out'], ctypes.c_void_p, 'pServiceProp')),
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'QueryProviders',
            (['in'], wintypes.DWORD, 'masks'),
            (['out'], ctypes.POINTER(
                ctypes.POINTER(IEnumVdsObject)), 'ppEnum'))
    ]
Esempio n. 5
0
class IVdsAsync(comtypes.IUnknown):
    _iid_ = comtypes.GUID("{d5d23b6d-5a55-4492-9889-397a3c2d2dbc}")

    _methods_ = [
        comtypes.COMMETHOD([], comtypes.HRESULT, 'Cancel'),
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'Wait',
            (['out'], ctypes.POINTER(ctypes.HRESULT), 'pHrResult'),
            (['out'], ctypes.POINTER(VDS_ASYNC_OUTPUT), 'pAsyncOut')),
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'QueryStatus',
            (['out'], ctypes.POINTER(ctypes.HRESULT), 'pHrResult'),
            (['out'], ctypes.POINTER(wintypes.ULONG), 'pulPercentCompleted')),
    ]
Esempio n. 6
0
class IMMDeviceEnumerator(comtypes.IUnknown):
    _iid_ = IID_IMMDeviceEnumerator
    _methods_ = (
        comtypes.COMMETHOD([], ctypes.HRESULT, 'EnumAudioEndpoints',
            (['in'], wintypes.DWORD, 'dataFlow'),
            (['in'], wintypes.DWORD, 'dwStateMask'),
            (['out','retval'], ctypes.POINTER(PIMMDeviceCollection),
             'ppDevices')),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'GetDefaultAudioEndpoint',
            (['in'], wintypes.DWORD, 'dataFlow'),
            (['in'], wintypes.DWORD, 'role'),
            (['out','retval'], ctypes.POINTER(PIMMDevice), 'ppDevices')))
    @classmethod
    def get_default(cls, dataFlow, role):
        enumerator = comtypes.CoCreateInstance(
            CLSID_MMDeviceEnumerator, cls, comtypes.CLSCTX_INPROC_SERVER)
        return enumerator.GetDefaultAudioEndpoint(dataFlow, role)
Esempio n. 7
0
class IVdsDisk(comtypes.IUnknown):
    _iid_ = comtypes.GUID("{07e5c822-f00c-47a1-8fce-b244da56fd06}")

    _methods_ = [
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'GetProperties',
            (['out'], ctypes.POINTER(VDS_DISK_PROP), 'pDiskProperties')),
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'GetPack',
            (['out'], ctypes.POINTER(ctypes.POINTER(IVdsPack)), 'ppPack')),
        comtypes.COMMETHOD([], comtypes.HRESULT, 'GetIdentificationData',
                           (['out'], ctypes.c_void_p, 'pLunInfo')),
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'QueryExtents',
            (['out'], ctypes.POINTER(
                ctypes.POINTER(VDS_DISK_EXTENT)), 'ppExtentArray'),
            (['out'], ctypes.POINTER(wintypes.LONG), 'plNumberOfExtents')),
    ]
Esempio n. 8
0
class IVdsSwProvider(comtypes.IUnknown):
    _iid_ = comtypes.GUID("{9aa58360-ce33-4f92-b658-ed24b14425b8}")

    _methods_ = [
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'QueryPacks',
            (['out'], ctypes.POINTER(
                ctypes.POINTER(IEnumVdsObject)), 'ppEnum'))
    ]
Esempio n. 9
0
class IVdsServiceLoader(comtypes.IUnknown):
    _iid_ = comtypes.GUID("{e0393303-90d4-4a97-ab71-e9b671ee2729}")

    _methods_ = [
        comtypes.COMMETHOD([], comtypes.HRESULT, 'LoadService',
                           (['in'], wintypes.LPCWSTR, 'pwszMachineName'),
                           (['out'], ctypes.POINTER(
                               ctypes.POINTER(IVdsService)), 'ppService'))
    ]
Esempio n. 10
0
class IVdsPack(comtypes.IUnknown):
    _iid_ = comtypes.GUID("{3b69d7f5-9d94-4648-91ca-79939ba263bf}")

    _methods_ = [
        comtypes.COMMETHOD([], comtypes.HRESULT, 'GetProperties',
                           (['out'], ctypes.c_void_p, 'pPackProp')),
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'GetProvider',
            (['out'], ctypes.POINTER(ctypes.POINTER(
                comtypes.IUnknown)), 'ppProvider')),
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'QueryVolumes',
            (['out'], ctypes.POINTER(
                ctypes.POINTER(IEnumVdsObject)), 'ppEnum')),
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'QueryDisks',
            (['out'], ctypes.POINTER(
                ctypes.POINTER(IEnumVdsObject)), 'ppEnum'))
    ]
Esempio n. 11
0
class IEnumVdsObject(comtypes.IUnknown):
    _iid_ = comtypes.GUID("{118610b7-8d94-4030-b5b8-500889788e4e}")

    _methods_ = [
        comtypes.COMMETHOD(
            [], comtypes.HRESULT, 'Next', (['in'], wintypes.ULONG, 'celt'),
            (['out'], ctypes.POINTER(ctypes.POINTER(
                comtypes.IUnknown)), 'ppObjectArray'),
            (['out'], ctypes.POINTER(wintypes.ULONG), 'pcFetched')),
    ]
Esempio n. 12
0
class IMMDevice(comtypes.IUnknown):
    _iid_ = IID_IMMDevice
    _methods_ = (comtypes.COMMETHOD(
        [], ctypes.HRESULT, 'Activate', (['in'], REFIID, 'iid'),
        (['in'], wintypes.DWORD, 'dwClsCtx'),
        (['in'], LPDWORD, 'pActivationParams', None),
        (['out', 'retval'], ctypes.POINTER(PIUnknown), 'ppInterface')),
                 comtypes.STDMETHOD(ctypes.HRESULT, 'OpenPropertyStore', []),
                 comtypes.STDMETHOD(ctypes.HRESULT, 'GetId', []),
                 comtypes.STDMETHOD(ctypes.HRESULT, 'GetState', []))
Esempio n. 13
0
class IMMDevice(comtypes.IUnknown):
    _iid_ = IID_IMMDevice
    _methods_ = (
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "Activate",
            (["in"], REFIID, "iid"),
            (["in"], wintypes.DWORD, "dwClsCtx"),
            (["in"], LPDWORD, "pActivationParams", None),
            (["out", "retval"], ctypes.POINTER(PIUnknown), "ppInterface"),
        ),
        comtypes.STDMETHOD(ctypes.HRESULT, "OpenPropertyStore", []),
        comtypes.STDMETHOD(ctypes.HRESULT, "GetId", []),
        comtypes.STDMETHOD(ctypes.HRESULT, "GetState", []),
    )
Esempio n. 14
0
from __future__ import unicode_literals
import ctypes
import _ctypes
import comtypes
import comtypes.client

port = comtypes.client.GetModule("portabledeviceapi.dll")
types = comtypes.client.GetModule("portabledevicetypes.dll")

methods = port.IEnumPortableDeviceObjectIDs._methods_
methods[0] = \
    comtypes.COMMETHOD([], ctypes.HRESULT, 'Next',
              ( ['in'], ctypes.c_ulong, 'cObjects' ),
              ( ['in', 'out'], ctypes.POINTER(ctypes.c_wchar_p), 'pObjIDs' ),  # out -> inout
              ( ['in', 'out'], ctypes.POINTER(ctypes.c_ulong), 'pcFetched' ))
del port.IEnumPortableDeviceObjectIDs.Next
port.IEnumPortableDeviceObjectIDs._methods_ = methods


def define_property_key(fmtid, pid):
    struct = port._tagpropertykey(fmtid=fmtid, pid=pid)
    return comtypes.pointer(struct)


WPD_OBJECT_PARENT_ID = define_property_key(
    comtypes.GUID("{EF6B490D-5CD8-437A-AFFC-DA8B60EE4A3C}"), 3)
WPD_OBJECT_NAME = define_property_key(
    comtypes.GUID("{EF6B490D-5CD8-437A-AFFC-DA8B60EE4A3C}"), 4)
WPD_OBJECT_CONTENT_TYPE = define_property_key(
    comtypes.GUID("{EF6B490D-5CD8-437A-AFFC-DA8B60EE4A3C}"), 7)
WPD_OBJECT_SIZE = define_property_key(
Esempio n. 15
0
class IAudioEndpointVolume(comtypes.IUnknown):
    _iid_ = IID_IAudioEndpointVolume
    _methods_ = (
        comtypes.STDMETHOD(ctypes.HRESULT, 'RegisterControlChangeNotify', []),
        comtypes.STDMETHOD(ctypes.HRESULT, 'UnregisterControlChangeNotify',
                           []),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'GetChannelCount',
                           (['out', 'retval'], LPUINT, 'pnChannelCount')),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'SetMasterVolumeLevel',
                           (['in'], ctypes.c_float, 'fLevelDB'),
                           (['in'], LPCGUID, 'pguidEventContext', None)),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'SetMasterVolumeLevelScalar',
                           (['in'], ctypes.c_float, 'fLevel'),
                           (['in'], LPCGUID, 'pguidEventContext', None)),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'GetMasterVolumeLevel',
                           (['out', 'retval'], LPFLOAT, 'pfLevelDB')),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'GetMasterVolumeLevelScalar',
                           (['out', 'retval'], LPFLOAT, 'pfLevel')),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'SetChannelVolumeLevel',
                           (['in'], wintypes.UINT, 'nChannel'),
                           (['in'], ctypes.c_float, 'fLevelDB'),
                           (['in'], LPCGUID, 'pguidEventContext', None)),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'SetChannelVolumeLevelScalar',
                           (['in'], wintypes.UINT, 'nChannel'),
                           (['in'], ctypes.c_float, 'fLevel'),
                           (['in'], LPCGUID, 'pguidEventContext', None)),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'GetChannelVolumeLevel',
                           (['in'], wintypes.UINT, 'nChannel'),
                           (['out', 'retval'], LPFLOAT, 'pfLevelDB')),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'GetChannelVolumeLevelScalar',
                           (['in'], wintypes.UINT, 'nChannel'),
                           (['out', 'retval'], LPFLOAT, 'pfLevel')),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'SetMute',
                           (['in'], wintypes.BOOL, 'bMute'),
                           (['in'], LPCGUID, 'pguidEventContext', None)),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'GetMute',
                           (['out', 'retval'], LPBOOL, 'pbMute')),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'GetVolumeStepInfo',
                           (['out', 'retval'], LPUINT, 'pnStep'),
                           (['out', 'retval'], LPUINT, 'pnStepCount')),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'VolumeStepUp',
                           (['in'], LPCGUID, 'pguidEventContext', None)),
        comtypes.COMMETHOD([], ctypes.HRESULT, 'VolumeStepDown',
                           (['in'], LPCGUID, 'pguidEventContext', None)),
        comtypes.COMMETHOD(
            [], ctypes.HRESULT, 'QueryHardwareSupport',
            (['out', 'retval'], LPDWORD, 'pdwHardwareSupportMask')),
        comtypes.COMMETHOD(
            [], ctypes.HRESULT, 'GetVolumeRange',
            (['out', 'retval'], LPFLOAT, 'pfLevelMinDB'),
            (['out', 'retval'], LPFLOAT, 'pfLevelMaxDB'),
            (['out', 'retval'], LPFLOAT, 'pfVolumeIncrementDB')))

    @classmethod
    def get_default(cls):
        endpoint = IMMDeviceEnumerator.get_default(eRender, eMultimedia)
        interface = endpoint.Activate(cls._iid_, comtypes.CLSCTX_INPROC_SERVER)
        return ctypes.cast(interface, ctypes.POINTER(cls))
Esempio n. 16
0
 def STDMETHODVCALLTYPE(idl_flags, res_type, func_name, *args):
     return comtypes.COMMETHOD(idl_flags, res_type, func_name, *args)
Esempio n. 17
0
class IAudioEndpointVolume(comtypes.IUnknown):
    _iid_ = IID_IAudioEndpointVolume
    _methods_ = (
        comtypes.STDMETHOD(ctypes.HRESULT, "RegisterControlChangeNotify", []),
        comtypes.STDMETHOD(ctypes.HRESULT, "UnregisterControlChangeNotify", []),
        comtypes.COMMETHOD(
            [], ctypes.HRESULT, "GetChannelCount", (["out", "retval"], LPUINT, "pnChannelCount")
        ),
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "SetMasterVolumeLevel",
            (["in"], ctypes.c_float, "fLevelDB"),
            (["in"], LPCGUID, "pguidEventContext", None),
        ),
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "SetMasterVolumeLevelScalar",
            (["in"], ctypes.c_float, "fLevel"),
            (["in"], LPCGUID, "pguidEventContext", None),
        ),
        comtypes.COMMETHOD(
            [], ctypes.HRESULT, "GetMasterVolumeLevel", (["out", "retval"], LPFLOAT, "pfLevelDB")
        ),
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "GetMasterVolumeLevelScalar",
            (["out", "retval"], LPFLOAT, "pfLevel"),
        ),
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "SetChannelVolumeLevel",
            (["in"], wintypes.UINT, "nChannel"),
            (["in"], ctypes.c_float, "fLevelDB"),
            (["in"], LPCGUID, "pguidEventContext", None),
        ),
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "SetChannelVolumeLevelScalar",
            (["in"], wintypes.UINT, "nChannel"),
            (["in"], ctypes.c_float, "fLevel"),
            (["in"], LPCGUID, "pguidEventContext", None),
        ),
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "GetChannelVolumeLevel",
            (["in"], wintypes.UINT, "nChannel"),
            (["out", "retval"], LPFLOAT, "pfLevelDB"),
        ),
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "GetChannelVolumeLevelScalar",
            (["in"], wintypes.UINT, "nChannel"),
            (["out", "retval"], LPFLOAT, "pfLevel"),
        ),
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "SetMute",
            (["in"], wintypes.BOOL, "bMute"),
            (["in"], LPCGUID, "pguidEventContext", None),
        ),
        comtypes.COMMETHOD([], ctypes.HRESULT, "GetMute", (["out", "retval"], LPBOOL, "pbMute")),
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "GetVolumeStepInfo",
            (["out", "retval"], LPUINT, "pnStep"),
            (["out", "retval"], LPUINT, "pnStepCount"),
        ),
        comtypes.COMMETHOD(
            [], ctypes.HRESULT, "VolumeStepUp", (["in"], LPCGUID, "pguidEventContext", None)
        ),
        comtypes.COMMETHOD(
            [], ctypes.HRESULT, "VolumeStepDown", (["in"], LPCGUID, "pguidEventContext", None)
        ),
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "QueryHardwareSupport",
            (["out", "retval"], LPDWORD, "pdwHardwareSupportMask"),
        ),
        comtypes.COMMETHOD(
            [],
            ctypes.HRESULT,
            "GetVolumeRange",
            (["out", "retval"], LPFLOAT, "pfLevelMinDB"),
            (["out", "retval"], LPFLOAT, "pfLevelMaxDB"),
            (["out", "retval"], LPFLOAT, "pfVolumeIncrementDB"),
        ),
    )

    @classmethod
    def get_default(cls):
        endpoint = IMMDeviceEnumerator.get_default(eRender, eMultimedia)
        interface = endpoint.Activate(cls._iid_, comtypes.CLSCTX_INPROC_SERVER)
        return ctypes.cast(interface, ctypes.POINTER(cls))