public static void CreateGFrame(string[] args) { InitialAction a = new InitialAction(); _globalMutex = Win32.CreateMutex(IntPtr.Zero, 0, "PoderosaGlobalMutex"); bool already_exists = (Win32.GetLastError() == Win32.ERROR_ALREADY_EXISTS); if (_globalMutex == IntPtr.Zero) { throw new Exception("Global mutex could not open"); } LoadEnvironment(a); Init(a, args, already_exists); //System.Windows.Forms.Application.Run(_frame); //_frame.Show(); if (!_closeWithoutSave) { SaveEnvironment(); } GEnv.Terminate(); Win32.CloseHandle(_globalMutex); }
private static IntPtr CheckDuplicatedInstance() { IntPtr t = Win32.CreateEvent(IntPtr.Zero, 0, 0, "PoderosaHandle"); if (Win32.GetLastError() == Win32.ERROR_ALREADY_EXISTS) { Win32.CloseHandle(t); return(IntPtr.Zero); } else { return(t); } }