델파이
프로그램 중복실행방지
미스터몽키
2011. 10. 14. 12:40
dpr파일에 uses절에 windows추가 후
var
mHandle : THandle;
begin
Application.Initialize;
mHandle := CreateMutex(nil, True, PChar('noDuplicate'));
if GetLastError = ERROR_ALREADY_EXISTS then
begin
MessageBox(0, PChar('프로그램이 이미 실행중... ㅎㅎ'), '중복실행에러', MB_OK or MB_ICONINFORMATION);
halt;
end;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
if mHandle <> 0 then
CloseHandle(mHandle)
end.