🐛 Close #15 with vide coding (not tested)

This commit is contained in:
2025-03-20 22:45:53 +08:00
parent 02227852f8
commit 2de93a0486
2 changed files with 22 additions and 1 deletions

View File

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