pythoncom.CoInitializeEx
CoInitializeEx(flags)
Initialize the COM libraries for the calling thread.
Parameters
Comments
There is no need to call this for the main Python thread, as it is called automatically by pythoncom (using sys.coinit_flags as the param, or COINIT_APARTMENTTHREADED if sys.coinit_flags does not exist).You must call this manually if you create a thread which wishes to use COM.
Return Value
This function will raise pythoncom.error for all error return values, including RPC_E_CHANGED_MODE error. This is in contrast to pythoncom::CoInitialize which will hide that specific error. If your code is happy to work in a threading model other than the one you specified, you must explicitly handle (and presumably ignore) this exception.