🐛 Close #15 with vide coding (not tested)
This commit is contained in:
		@@ -102,6 +102,6 @@ static void my_application_init(MyApplication* self) {}
 | 
			
		||||
MyApplication* my_application_new() {
 | 
			
		||||
  return MY_APPLICATION(g_object_new(my_application_get_type(),
 | 
			
		||||
                                     "application-id", APPLICATION_ID,
 | 
			
		||||
                                     "flags", G_APPLICATION_NON_UNIQUE,
 | 
			
		||||
                                     "flags", G_APPLICATION_FLAGS_NONE,
 | 
			
		||||
                                     nullptr));
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,8 +8,29 @@ auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
 | 
			
		||||
#include "flutter_window.h"
 | 
			
		||||
#include "utils.h"
 | 
			
		||||
 | 
			
		||||
HANDLE g_hMutex = NULL;
 | 
			
		||||
 | 
			
		||||
bool CheckIfAlreadyRunning() {
 | 
			
		||||
    g_hMutex = CreateMutex(NULL, FALSE, L"Global\\SolianDesktop");
 | 
			
		||||
 | 
			
		||||
    if (g_hMutex == NULL) {
 | 
			
		||||
        return true; // Mutex creation failed
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (GetLastError() == ERROR_ALREADY_EXISTS) {
 | 
			
		||||
        CloseHandle(g_hMutex);
 | 
			
		||||
        return true; // Another instance is running
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
 | 
			
		||||
                      _In_ wchar_t *command_line, _In_ int show_command) {
 | 
			
		||||
  if (CheckIfAlreadyRunning()) {
 | 
			
		||||
    return EXIT_SUCCESS;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Attach to console when present (e.g., 'flutter run') or create a
 | 
			
		||||
  // new console when running with a debugger.
 | 
			
		||||
  if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user