可以修改.dpr文件,举个例子:
program IETool;
uses
Forms,
Windows,
Main in 'Main.pas' {frmMain};
var
hMutex:hwnd;
ret:integer;
{$R *.res}
begin
Application.Initialize;
// run only once---------------------------------------
hMutex:=CreateMutex(nil,false,'project1');
ret:=GetLastError;
if ret=ERROR_ALREADY_EXISTS then
begin
ReleaseMutex(hMutex);
MessageBox(Application.Handle,'抱歉,本程序已经在运行!','收藏伴侣' ,
MB_OK + MB_DEFBUTTON1 + MB_ICONEXCLAMATION);
exit;
end;
//-----------------------------------------------------
Application.CreateForm(TfrmMain, frmMain);
Application.Run;
end.