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

Handle RPC_E_CHANGED_MODE return value from CoInitializeEx better. #73

Closed
wants to merge 3 commits into from

Conversation

hrydgard
Copy link

@hrydgard hrydgard commented Jul 2, 2019

Fixes #72.

This is my proposal for a minimal-impact fix for the issue. I don't know if anyone really still uses COINIT_APARTMENTTHREADED mode though.

When CoInitializeEx returns RPC_E_CHANGED_MODE, it's not because it actually changed the mode but because you requested an invalid mode change, which didn't actually happen. COM still works in the old mode. So handling this error and avoiding calling CoUninitialize fixes this with zero impact to existing code.

@hrydgard
Copy link
Author

Please just go ahead and merge this, it's safe and more people are running into the bug, see the new comment in #72 .

@mlabbe
Copy link
Owner

mlabbe commented Sep 28, 2019

Similar implementation has been added on top of a refactor so this PR will not be directly accepted.

@mlabbe mlabbe closed this Sep 28, 2019
@hrydgard hrydgard deleted the coinitialize-fix branch August 9, 2021 08:42
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

Successfully merging this pull request may close these issues.

CoInitializeEx return value RPC_E_CHANGED_MODE not handled correctly
2 participants