掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
二重起動を防止するには? (ID:11913)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
こうなるかな。 program Project1; uses Windows, Forms, Unit1 in 'Unit1.pas' ; {$R *.res} const MutexName = 'myMutex'; WindowClass = 'TForm1'; var hMutex: THANDLE; Wnd: HWnd; AppWnd: HWND; WindowTitle: String; begin WindowTitle := 'myMainFormTitle'; hMutex := CreateMutex(nil, False, MutexName); if hMutex = 0 then Exit; if GetLastError() = ERROR_ALREADY_EXISTS then begin Wnd := FindWindow(PChar(WindowClass), PChar(WindowTitle)); if Wnd <> 0 then begin AppWnd := GetWindowLong(Wnd, GWL_HWNDPARENT); if AppWnd = 0 then AppWnd := Wnd; {二重起動時の動作} end; Exit; end; Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; ReleaseMutex(hMutex); end.
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.