Temp <Temp@...> writes: > > Hi, I'm new to comtypes (and com in general) > > I'm trying to convert some code to Python from: > https://github.com/DanStevens/AudioEndPointController/blob/master/EndPointCon troller/EndPointController.cpp > The code is for enumeration and getting information about audio devices > in Windows Vista+. > > I found partial example code that gives me most of what I needed here: > http://stackoverflow.com/questions/32149809/read-and-or-change-windows-8- master-volume-in-python > I was able to add some missing stuff. > > But I'm stuck figuring out how to add "OpenPropertyStore": > https://msdn.microsoft.com/en- us/library/windows/desktop/dd371412%28v=vs.85%29.aspx > It's used to get the "Friendly" name of the audio device. > > In the comtypes documentation there is a command GetModule(), that's > supposed to get the definition about com objects. > But I can't figure out how to use it with the methods I need to use? > > My current code at the end of the message. > class IPolicyConfigVista(comtypes.IUnknown): > _iid_ = IID_IPolicyConfigVista > _methods_ = ( > _COMMETHOD([], _HRESULT, > 'SetDefaultEndpoint', > (['in'], _PCWSTR, 'wszDeviceId'), > (['in'], _DWORD, 'eRole')), > ) >
Hi, I'm also new to COM, but I worked with some recently. The order you define methods is important because of the vtable. See https://blogs.msdn.microsoft.com/oldnewthing/20040205-00/?p=40733 So in your code when you wrap the SetDefaultEndpoint() method, you must also define all the previous methods, like here: https://github.com/DanStevens/AudioEndPointController/blob/master/EndPointCon troller/PolicyConfig.h You don't have to write the full definition of the methods before, but they must exist. You can name them "NotImplemented", like I've done here https://github.com/AndreMiras/pycaw Hope it helps ------------------------------------------------------------------------------ Mobile security can be enabling, not merely restricting. Employees who bring their own devices (BYOD) to work are irked by the imposition of MDM restrictions. Mobile Device Manager Plus allows you to control only the apps on BYO-devices by containerizing them, leaving personal data untouched! https://ad.doubleclick.net/ddm/clk/304595813;131938128;j _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users