From 0ece276ecbf6cd1b8efd130fba80bc2c7fb67a81 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Wed, 15 Apr 2020 14:32:39 -0700 Subject: [PATCH] Add COM initializition to Windows template (#54881) Plugins, and the library, should be able to use COM without special setup. This adds COM initialization to the runner template so that it's available for any code on the main thread. --- .../flutter_tools/templates/app/windows.tmpl/runner/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/flutter_tools/templates/app/windows.tmpl/runner/main.cpp b/packages/flutter_tools/templates/app/windows.tmpl/runner/main.cpp index 7d9203d6df6..c428b4b3f53 100644 --- a/packages/flutter_tools/templates/app/windows.tmpl/runner/main.cpp +++ b/packages/flutter_tools/templates/app/windows.tmpl/runner/main.cpp @@ -16,6 +16,9 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, ::AllocConsole(); } + // Initialize COM, so that it is available for use in the library and/or plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + RunLoop run_loop; flutter::DartProject project(L"data"); @@ -29,5 +32,6 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, run_loop.Run(); + ::CoUninitialize(); return EXIT_SUCCESS; }