[delphi] 프로그램 중복 실행 방지

반응형
반응형

뮤텍스(Mutex)로  프로그램 중복 실행 방지...

 

프로젝트 dpr 안에  프로그램 중복 실행 방지 코드 입력으로 간단히 처리

 

 

 소스

program Project2;
uses
Forms,
Windows,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
Var
Mutex: THandle;
begin
Mutex := CreateMutex(nil, True, '중복실행 방지');
if (Mutex > 0) and (GetLastError = 0) then
begin
try
Application.Initialize;
Application.Title := '중복실행 방지';
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
except
Application.Terminate;
end;
if Mutex > 0 then
CloseHandle(Mutex);
end;
end.

 마무리

Delphi7 또는 XE10.3 에서도 정상 작동 됩니다.

반응형

댓글