Application d'instance unique Flutter

// paste at the beginning of CreateAndShow at windows/runner/win32_window.cpp

HANDLE hMutexHandle = CreateMutex(NULL, TRUE, L"my.app.mutex");
  HWND handle = FindWindowA(NULL, "My App Name");

  hMutexHandle; // This line is required to supress "local variable is initialized but not referenced" error/warning.

  if (GetLastError() == ERROR_ALREADY_EXISTS)
  {
    WINDOWPLACEMENT place = {sizeof(WINDOWPLACEMENT)};
    GetWindowPlacement(handle, &place);
    switch (place.showCmd)
    {
    case SW_SHOWMAXIMIZED:
      ShowWindow(handle, SW_SHOWMAXIMIZED);
      break;
    case SW_SHOWMINIMIZED:
      ShowWindow(handle, SW_RESTORE);
      break;
    default:
      ShowWindow(handle, SW_NORMAL);
      break;
    }
    SetWindowPos(0, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
    SetForegroundWindow(handle);
    return 0;
  }
CatgirlSimp