Fixed some Windows not appearing when opening file

This commit is contained in:
LAGonauta 2020-05-10 07:26:54 -03:00
parent 25673ab145
commit 03f17b8f39
2 changed files with 13 additions and 3 deletions

View file

@ -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) {

View file

@ -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