diff --git a/libdino/src/application.vala b/libdino/src/application.vala index f381c21d..4cb54a42 100644 --- a/libdino/src/application.vala +++ b/libdino/src/application.vala @@ -61,6 +61,9 @@ public interface Application : GLib.Application { }); shutdown.connect(() => { stream_interactor.connection_manager.make_offline_all(); +#if _WIN32 + Dino.Util.CoUninitialize(); +#endif }); open.connect((files, hint) => { if (files.length != 1) { diff --git a/libdino/src/service/util.vala b/libdino/src/service/util.vala index 6680cade..dbc98b2a 100644 --- a/libdino/src/service/util.vala +++ b/libdino/src/service/util.vala @@ -7,8 +7,15 @@ public class Util { [CCode (cname = "ShellExecuteA")] private static extern int ShellExecuteA(int* hwnd, string operation, string file, string parameters, string directory, int showCmd); - private static int ShellExecute(string file) { - return ShellExecuteA(null, null, file, null, null, 0); + [CCode (cname = "CoInitialize")] + public static extern int CoInitialize(void* reserved); + + [CCode (cname = "CoUninitialize")] + public static extern void CoUninitialize(); + + private static int ShellExecute(string operation, string file) { + CoInitialize(null); + return ShellExecuteA(null, operation, file, null, null, 1); } #endif @@ -39,7 +46,7 @@ public class Util { public static void launch_default_for_uri(string file_uri) { #if _WIN32 - Dino.Util.ShellExecute(file_uri); + Dino.Util.ShellExecute("open", file_uri); #else AppInfo.launch_default_for_uri(file_uri, null); #endif