Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_windows_vdi_IObjectArray_method_GetAt(self):
method = (
ctypes.HRESULT,
"GetAt",
(
ctypes.wintypes.UINT,
ctypes.POINTER(GUID),
ctypes.POINTER(ctypes.wintypes.LPVOID),
),
((1, "uiIndex"), (1, "riid"), (1, "ppv")),
("Method GetAt",),
"Method GetAt",
)
assert method == vdi.IObjectArray._methods_[1]
The Python implementation is based on the work by @kdschlosser
(, )
"""
import ctypes
import ctypes.wintypes
import comtypes
from comtypes import COMMETHOD, helpstring
from comtypes.GUID import GUID
S_OK = 0x00000000
## UIDS
CLSID_ImmersiveShell = GUID("{C2F03A33-21F5-47FA-B4BB-156362A2F239}")
CLSID_VirtualDesktopManager = GUID("{AA509086-5CA9-4C25-8F95-589D3C07B48A}")
CLSID_VirtualDesktopManagerInternal = GUID("{C5E0CDCA-7B6E-41B2-9FC4-D93975CC467B}")
IID_IServiceProvider = GUID("{6D5140C1-7436-11CE-8034-00AA006009FA}")
IID_IInspectable = GUID("{AF86E2E0-B12D-4C6A-9C5A-D7AA65101E90}")
IID_IApplicationViewConsolidatedEventArgs = GUID(
"{514449EC-7EA2-4DE7-A6A6-7DFBAAEBB6FB}"
)
IID_IApplicationView = GUID("{D222D519-4361-451E-96C4-60F4F9742DB0}")
IID_IApplicationViewCollection = GUID("{1841C6D7-4F9D-42C0-AF41-8747538F10E5}")
IID_IVirtualDesktop = GUID("{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}")
IID_IVirtualDesktopManager = GUID("{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}")
IID_IVirtualDesktopManagerInternal = GUID("{F31574D6-B682-4CDC-BD56-1827860ABEC6}")
## STRUCTURES
( ['out'], POINTER(GUID), 'pClassID' )),
]
class IServiceProvider(IUnknown):
_iid_ = GUID('{6D5140C1-7436-11CE-8034-00AA006009FA}')
# Overridden QueryService to make it nicer to use (passing it an
# interface and it returns a pointer to that interface)
def QueryService(self, serviceIID, interface):
p = POINTER(interface)()
self._QueryService(byref(serviceIID), byref(interface._iid_), byref(p))
return p
_methods_ = [
COMMETHOD([], HRESULT, 'QueryService',
( ['in'], POINTER(GUID), 'guidService' ),
( ['in'], POINTER(GUID), 'riid' ),
( ['in'], POINTER(c_void_p), 'ppvObject' ))
]
################################################################
def CoGetObject(displayname, interface):
"""Convert a displayname to a moniker, then bind and return the object
identified by the moniker."""
if interface is None:
interface = IUnknown
punk = POINTER(interface)()
# Do we need a way to specify the BIND_OPTS parameter?
_ole32.CoGetObject(unicode(displayname),
None,
byref(interface._iid_),
byref(punk))
from comtypes.GUID import GUID
S_OK = 0x00000000
## UIDS
CLSID_ImmersiveShell = GUID("{C2F03A33-21F5-47FA-B4BB-156362A2F239}")
CLSID_VirtualDesktopManager = GUID("{AA509086-5CA9-4C25-8F95-589D3C07B48A}")
CLSID_VirtualDesktopManagerInternal = GUID("{C5E0CDCA-7B6E-41B2-9FC4-D93975CC467B}")
IID_IServiceProvider = GUID("{6D5140C1-7436-11CE-8034-00AA006009FA}")
IID_IInspectable = GUID("{AF86E2E0-B12D-4C6A-9C5A-D7AA65101E90}")
IID_IApplicationViewConsolidatedEventArgs = GUID(
"{514449EC-7EA2-4DE7-A6A6-7DFBAAEBB6FB}"
)
IID_IApplicationView = GUID("{D222D519-4361-451E-96C4-60F4F9742DB0}")
IID_IApplicationViewCollection = GUID("{1841C6D7-4F9D-42C0-AF41-8747538F10E5}")
IID_IVirtualDesktop = GUID("{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}")
IID_IVirtualDesktopManager = GUID("{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}")
IID_IVirtualDesktopManagerInternal = GUID("{F31574D6-B682-4CDC-BD56-1827860ABEC6}")
## STRUCTURES
class HSTRING__(ctypes.Structure):
"""Class holding structure for the immutable strings in the Windows Runtime."""
_fields_ = [("unused", ctypes.wintypes.INT)]
class EventRegistrationToken(ctypes.Structure):
"""Class holding structure for a delegate that receives change notifications."""
_fields_ = [("value", ctypes.c_int64)]
import ctypes
import ctypes.wintypes
import comtypes
from comtypes import COMMETHOD, helpstring
from comtypes.GUID import GUID
S_OK = 0x00000000
## UIDS
CLSID_ImmersiveShell = GUID("{C2F03A33-21F5-47FA-B4BB-156362A2F239}")
CLSID_VirtualDesktopManager = GUID("{AA509086-5CA9-4C25-8F95-589D3C07B48A}")
CLSID_VirtualDesktopManagerInternal = GUID("{C5E0CDCA-7B6E-41B2-9FC4-D93975CC467B}")
IID_IServiceProvider = GUID("{6D5140C1-7436-11CE-8034-00AA006009FA}")
IID_IInspectable = GUID("{AF86E2E0-B12D-4C6A-9C5A-D7AA65101E90}")
IID_IApplicationViewConsolidatedEventArgs = GUID(
"{514449EC-7EA2-4DE7-A6A6-7DFBAAEBB6FB}"
)
IID_IApplicationView = GUID("{D222D519-4361-451E-96C4-60F4F9742DB0}")
IID_IApplicationViewCollection = GUID("{1841C6D7-4F9D-42C0-AF41-8747538F10E5}")
IID_IVirtualDesktop = GUID("{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}")
IID_IVirtualDesktopManager = GUID("{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}")
IID_IVirtualDesktopManagerInternal = GUID("{F31574D6-B682-4CDC-BD56-1827860ABEC6}")
## STRUCTURES
class HSTRING__(ctypes.Structure):
"""Class holding structure for the immutable strings in the Windows Runtime."""
_fields_ = [("unused", ctypes.wintypes.INT)]
import ctypes
import ctypes.wintypes
import comtypes
from comtypes import COMMETHOD, helpstring
from comtypes.GUID import GUID
S_OK = 0x00000000
## UIDS
CLSID_ImmersiveShell = GUID("{C2F03A33-21F5-47FA-B4BB-156362A2F239}")
CLSID_VirtualDesktopManager = GUID("{AA509086-5CA9-4C25-8F95-589D3C07B48A}")
CLSID_VirtualDesktopManagerInternal = GUID("{C5E0CDCA-7B6E-41B2-9FC4-D93975CC467B}")
IID_IServiceProvider = GUID("{6D5140C1-7436-11CE-8034-00AA006009FA}")
IID_IInspectable = GUID("{AF86E2E0-B12D-4C6A-9C5A-D7AA65101E90}")
IID_IApplicationViewConsolidatedEventArgs = GUID(
"{514449EC-7EA2-4DE7-A6A6-7DFBAAEBB6FB}"
)
IID_IApplicationView = GUID("{D222D519-4361-451E-96C4-60F4F9742DB0}")
IID_IApplicationViewCollection = GUID("{1841C6D7-4F9D-42C0-AF41-8747538F10E5}")
IID_IVirtualDesktop = GUID("{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}")
IID_IVirtualDesktopManager = GUID("{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}")
IID_IVirtualDesktopManagerInternal = GUID("{F31574D6-B682-4CDC-BD56-1827860ABEC6}")
## STRUCTURES
class HSTRING__(ctypes.Structure):
"""Class holding structure for the immutable strings in the Windows Runtime."""
_fields_ = [("unused", ctypes.wintypes.INT)]
(, )
"""
import ctypes
import ctypes.wintypes
import comtypes
from comtypes import COMMETHOD, helpstring
from comtypes.GUID import GUID
S_OK = 0x00000000
## UIDS
CLSID_ImmersiveShell = GUID("{C2F03A33-21F5-47FA-B4BB-156362A2F239}")
CLSID_VirtualDesktopManager = GUID("{AA509086-5CA9-4C25-8F95-589D3C07B48A}")
CLSID_VirtualDesktopManagerInternal = GUID("{C5E0CDCA-7B6E-41B2-9FC4-D93975CC467B}")
IID_IServiceProvider = GUID("{6D5140C1-7436-11CE-8034-00AA006009FA}")
IID_IInspectable = GUID("{AF86E2E0-B12D-4C6A-9C5A-D7AA65101E90}")
IID_IApplicationViewConsolidatedEventArgs = GUID(
"{514449EC-7EA2-4DE7-A6A6-7DFBAAEBB6FB}"
)
IID_IApplicationView = GUID("{D222D519-4361-451E-96C4-60F4F9742DB0}")
IID_IApplicationViewCollection = GUID("{1841C6D7-4F9D-42C0-AF41-8747538F10E5}")
IID_IVirtualDesktop = GUID("{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}")
IID_IVirtualDesktopManager = GUID("{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}")
IID_IVirtualDesktopManagerInternal = GUID("{F31574D6-B682-4CDC-BD56-1827860ABEC6}")
## STRUCTURES
class HSTRING__(ctypes.Structure):
class IUnknown(object):
"""The most basic COM interface.
Each subclasses of IUnknown must define these class attributes:
_iid_ - a GUID instance defining the identifier of this interface
_methods_ - a list of methods for this interface.
The _methods_ list must in VTable order. Methods are specified
with STDMETHOD or COMMETHOD calls.
"""
_case_insensitive_ = False
__metaclass__ = _cominterface_meta
_iid_ = GUID("{00000000-0000-0000-C000-000000000046}")
_methods_ = [
STDMETHOD(HRESULT, "QueryInterface",
[POINTER(GUID), POINTER(c_void_p)]),
STDMETHOD(c_ulong, "AddRef"),
STDMETHOD(c_ulong, "Release")
]
def QueryInterface(self, interface, iid=None):
"QueryInterface(interface) -> instance"
p = POINTER(interface)()
if iid is None:
iid = interface._iid_
self.__com_QueryInterface(byref(iid), byref(p))
clsid = self.__dict__.get('__clsid')
if clsid is not None:
from comtypes import COMMETHOD, helpstring
from comtypes.GUID import GUID
S_OK = 0x00000000
## UIDS
CLSID_ImmersiveShell = GUID("{C2F03A33-21F5-47FA-B4BB-156362A2F239}")
CLSID_VirtualDesktopManager = GUID("{AA509086-5CA9-4C25-8F95-589D3C07B48A}")
CLSID_VirtualDesktopManagerInternal = GUID("{C5E0CDCA-7B6E-41B2-9FC4-D93975CC467B}")
IID_IServiceProvider = GUID("{6D5140C1-7436-11CE-8034-00AA006009FA}")
IID_IInspectable = GUID("{AF86E2E0-B12D-4C6A-9C5A-D7AA65101E90}")
IID_IApplicationViewConsolidatedEventArgs = GUID(
"{514449EC-7EA2-4DE7-A6A6-7DFBAAEBB6FB}"
)
IID_IApplicationView = GUID("{D222D519-4361-451E-96C4-60F4F9742DB0}")
IID_IApplicationViewCollection = GUID("{1841C6D7-4F9D-42C0-AF41-8747538F10E5}")
IID_IVirtualDesktop = GUID("{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}")
IID_IVirtualDesktopManager = GUID("{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}")
IID_IVirtualDesktopManagerInternal = GUID("{F31574D6-B682-4CDC-BD56-1827860ABEC6}")
## STRUCTURES
class HSTRING__(ctypes.Structure):
"""Class holding structure for the immutable strings in the Windows Runtime."""
_fields_ = [("unused", ctypes.wintypes.INT)]
class EventRegistrationToken(ctypes.Structure):
"""Class holding structure for a delegate that receives change notifications."""
def Release(self):
"Decrease the internal refcount by one and return it."
return self.__com_Release()
# IPersist is a trivial interface, which allows to ask an object about
# its clsid.
class IPersist(IUnknown):
_iid_ = GUID('{0000010C-0000-0000-C000-000000000046}')
_idlflags_ = []
_methods_ = [
COMMETHOD([], HRESULT, 'GetClassID',
( ['out'], POINTER(GUID), 'pClassID' )),
]
class IServiceProvider(IUnknown):
_iid_ = GUID('{6D5140C1-7436-11CE-8034-00AA006009FA}')
# Overridden QueryService to make it nicer to use (passing it an
# interface and it returns a pointer to that interface)
def QueryService(self, serviceIID, interface):
p = POINTER(interface)()
self._QueryService(byref(serviceIID), byref(interface._iid_), byref(p))
return p
_methods_ = [
COMMETHOD([], HRESULT, 'QueryService',
( ['in'], POINTER(GUID), 'guidService' ),
( ['in'], POINTER(GUID), 'riid' ),
( ['in'], POINTER(c_void_p), 'ppvObject' ))
]
################################################################