OSDN Git Service

Mutexによる二重起動チェックの位置を、プロジェクトソース側に移動
authornaru <bottle@mikage.to>
Sun, 14 Mar 2004 09:19:17 +0000 (09:19 +0000)
committernaru <bottle@mikage.to>
Sun, 14 Mar 2004 09:19:17 +0000 (09:19 +0000)
bottleclient/MainForm.pas
bottleclient/SstpBottle.dpr

index eb8cf07..c5910d7 100755 (executable)
@@ -559,20 +559,6 @@ begin
 
   FOriginalCaption := Self.Caption;
 
-  {$IFDEF NOMUTEX}
-  ShowMessage('\93ñ\8fd\8bN\93®\8b\96\89Â\83o\81[\83W\83\87\83\93\82Å\82·\81B'#13#10 + VersionString);
-  {$ELSE}
-  FMutex := CreateMutex(nil, true, 'SSTPBottleClient2');
-  if GetLastError = ERROR_ALREADY_EXISTS then begin
-    Beep;
-    ShowMessage('SSTP Bottle Client\82Í\93ñ\8fd\8bN\93®\82Å\82«\82Ü\82¹\82ñ');
-    CloseHandle(FMutex);
-    Application.Terminate;
-    Application.ProcessMessages; //WM_QUIT\82ð\97¬\82·
-    Exit;
-  end;
-  {$ENDIF}
-
   UpdateLayout;
   mnShowToolBar.Checked := Pref.ShowToolBar;
   mnShowConstBar.Checked := Pref.ShowConstBar;
@@ -654,10 +640,6 @@ begin
   SaveChainRuleList;
   BottleChainRuleList.Free;
 
-  {$IFDEF BOTTLEMUTEX}
-  if FMutex > 0 then
-    CloseHandle(FMutex);
-  {$ENDIF}
 end;
 
 
index 699a2e3..d8c14f2 100755 (executable)
@@ -22,6 +22,8 @@ program SstpBottle;
 
 uses
   Forms,
+  Dialogs,
+  Windows,
   MainForm in 'MainForm.pas' {frmSender},
   BRegExp in 'BRegExp.pas',
   BottleDef in 'BottleDef.pas',
@@ -61,7 +63,8 @@ uses
   StrReplace in 'StrReplace.pas',
   RegexUtils in 'RegexUtils.pas',
   StrReplaceFrame in 'StrReplaceFrame.pas' {frmStrReplaceFrame: TFrame},
-  StrReplaceDialog in 'StrReplaceDialog.pas' {frmStrReplaceDialog};
+  StrReplaceDialog in 'StrReplaceDialog.pas' {frmStrReplaceDialog},
+  ReplacePresetEditor in 'ReplacePresetEditor.pas' {frmReplacePresetEditor: TFrame};
 
 // \8c^\95t\82«\92è\90\94\82ð\95Ï\8dX\82Å\82«\82é\82æ\82¤\82É\82·\82é\83R\83\93\83p\83C\83\89\83I\83v\83V\83\87\83\93
 // \88ê\95\94\82Ì\83R\83\93\83|\81[\83l\83\93\83g\82É\82±\82ê\82ª\95K\97v
@@ -80,8 +83,21 @@ uses
   {$IFEND}
 {$ENDIF}
 
+var
+  Mutex: THandle;
+
 begin
-  // MemChk;
+  {$IFDEF NOMUTEX}
+  ShowMessage('\93ñ\8fd\8bN\93®\8b\96\89Â\83o\81[\83W\83\87\83\93\82Å\82·\81B'#13#10 + VersionString);
+  {$ELSE}
+  Mutex := CreateMutex(nil, true, 'SSTPBottleClient2');
+  if GetLastError = ERROR_ALREADY_EXISTS then begin
+    ShowMessage('SSTP Bottle Client\82Í\93ñ\8fd\8bN\93®\82Å\82«\82Ü\82¹\82ñ');
+    CloseHandle(Mutex);
+    Exit;
+  end;
+  {$ENDIF}
+
   Application.Initialize;
   Application.Title := 'SSTP Bottle Client';
   Application.ShowMainForm := true;
@@ -89,7 +105,12 @@ begin
   Application.CreateForm(TfrmLog, frmLog);
   Application.CreateForm(TfrmMessageBox, frmMessageBox);
   Application.CreateForm(TfrmSurfacePreview, frmSurfacePreview);
-  Application.CreateForm(TfrmStrReplaceDialog, frmStrReplaceDialog);
   if not Application.Terminated then frmSender.Show;
   Application.Run;
+
+  {$IFDEF BOTTLEMUTEX}
+  if Mutex > 0 then
+    CloseHandle(Mutex);
+  {$ENDIF}
+
 end.