Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best strategies for working with other Windows COM modules? (CoInitialize APARTMENTTHREADED, etc) #9

Open
ewmailing opened this issue Jun 13, 2018 · 1 comment

Comments

@ewmailing
Copy link

ewmailing commented Jun 13, 2018

Can you give any tips on how to best work/cooperate with other Windows modules that also use COM?

While, trying to integrate the techniques of this module, I discovered the initialization of
Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);
conflicts with other modules that call CoInitialize with different options.

Most notably, I am using a GUI library that uses CoInitializeEx(NULL, COINIT_APARTMENTTHREADED), and I think things like the Windows File Dialog or any OLE components will not work if put into MULTITHREADED mode.

For curiosity, I tried changing this module to Windows::Foundation::Initialize(RO_INIT_SINGLETHREADED) (there don't appear to be any APARTMENT options), but in my actual program, exceptions were thrown at things like CreateWatcher().

Right now my thinking is to try putting this (and other UWP modules) on a background thread first and then calling Windows::Foundation::Initialize(RO_INIT_MULTITHREADED).

I'm hoping you can give a statement if that will actually work (and if there are any other gotchas to watch out for), or if there is a simpler/better way to do this.

Thanks!

@stammen
Copy link
Owner

stammen commented Jun 13, 2018

I would try putting the winrt code on another thread first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants