Closed AndrewChan2022 closed 11 months ago
This is almost certainly because the interface in question doesn't support IDispatch
No, this component is used by customer to query visual studio version info, so no need support IDispatch and ole features.
As my understand, pythoncom is by design to support only subset of com that support IDispatch interface, so I need use other approach to get this non-ole component?
I using ctypes to accomplish this task.
I think COM without IDispatch maybe apply to lightweight tasks like finding VisualStudio installation.
https://github.com/AndrewChan2022/PyVisualStudioSetupConfiguration
In that case I think you could have just use IID_IUnknown
- but it sounds like there's nothing to do here.
yes, pythoncom also success when I change the iid to IUnknown, but still cannot query other interface by IUnknown :)
thanks.
import pythoncom, pywintypes
pythoncom.CoInitialize()
clsid = pywintypes.IID("{177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D}")
iid = pywintypes.IID("{00000000-0000-0000-C000-000000000046}")
obj = pythoncom.CoCreateInstance(clsid, None, 1, iid)
print(obj)
output:
<PyIUnknown at 0x000001DD5FEA20A0 with obj at 0x000001DD5FEA2190>
create SetupConfigurationClass success, but fail
step 1. install visual studio on the windows, so there are com class SetupConfigurationClass
document here Microsoft.VisualStudio.Setup.Configuration
step 2. create com object of SetupConfigurationClass fail
step 3. however using raw ctypes method success
Name: pywin32 Version: 306
Python 3.11.4