델파이 초보자라서 SetForegroundWindow 적용이 안되는 부분 해결을 못했다. ㅜㅜ
적용전
program HttpDown;
uses Forms, FmHDMain in 'FmHDMain.pas' {Form1};
{$R *.res}
begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end.
|
적용후
program HttpDown;
uses Forms, SysUtils, Windows, Mutex in 'Mutex.pas', FmHDMain in 'FmHDMain.pas' {Form1};
{$R *.res}
const MutexName = 'JmLaunch';
var hMutex: HWND; ClassNames: array[0..0] of PAnsiChar = ( 'TFrmLMain' );
begin if Mutex.CheckMutex(MutexName) then begin Mutex.SetActiveWindows(ClassNames, SizeOf(ClassNames) div 4); Exit; end;
try hMutex := Mutex.CreateSecurityMutex(MutexName); if hMutex = 0 then begin raise Exception.Create('Mutex 생성 실패'); end;
try Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; finally ReleaseMutex(hMutex); end; except on E: Exception do Application.ShowException(E); end; end.
| |