让程序只运行一个实例
var
hMutex: HWND;
begin
//hMutex := CreateMutex(nil,True,'_MingTest');
hMutex := CreateEvent(nil,False,False,'_MingTest');
if GetLastError = ERROR_ALREADY_EXISTS then
begin
MessageBox(0,'This program has executed!','Error!',0);
Exit;
end;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

浙公网安备 33010602011771号