如果用CreateMutex已经运行该程序了,请教如何激活该程序?
var
hMutex:HWND; //程序互斥对象句柄
Ret:Integer; //返回的错误句柄
begin
Application.Initialize;
Application.Title := 'aaaaa';
hMutex := CreateMutex(nil,False,'aaaaa');
Ret:=GetLastError;
if Ret<>ERROR_ALREADY_EXISTS then
Begin
Application.CreateForm(TForm1, Form1);
Application.Run;
End
else
//Application.MessageBox('程序已经运行!','提示!',MB_OK);
EnableWindow(hMutex,true);
ReleaseMutex(hMutex);
end.