1,用hook
http://crob.net/delphi/source/dphood.zip
简单的hook源程序2,避免两个实例运行
procedure TForm1.FormCreate(Sender: TObject);
Var Ret:Integer;
b:boolean;
tmpstr: string;
begin
CreateMutex(nil,False,'aaaaaa');
Ret:=GetLastError;
if Ret = ERROR_ALREADY_EXISTS Then begin
Application.MessageBox('已经运行', '重复运行', MB_OK + MB_ICONEXCLAMATION);
Application.Terminate;
end;
end;
http://crob.net/delphi/source/dphood.zip
简单的hook源程序2,避免两个实例运行
procedure TForm1.FormCreate(Sender: TObject);
Var Ret:Integer;
b:boolean;
tmpstr: string;
begin
CreateMutex(nil,False,'aaaaaa');
Ret:=GetLastError;
if Ret = ERROR_ALREADY_EXISTS Then begin
Application.MessageBox('已经运行', '重复运行', MB_OK + MB_ICONEXCLAMATION);
Application.Terminate;
end;
end;
2.给你一个比较简单的防止程序执行两次的方法
implementation
var hnd: THandle;initialization
hnd := CreateMutex(nil, True, 'irgendwaseinmaliges');
if GetLastError = ERROR_ALREADY_EXISTS then Halt;finalization
if hnd <> 0 then CloseHandle(hnd);
end.
2.给你一个比较简单的防止程序执行两次的方法
implementation
var hnd: THandle;initialization
hnd := CreateMutex(nil, True, 'irgendwaseinmaliges');
if GetLastError = ERROR_ALREADY_EXISTS then Halt;finalization
if hnd <> 0 then CloseHandle(hnd);
end.
SystemParametersInfo(SPI_SCREENSAVERRUNNING,1,0,0); //HIDE CLT-ALT-Del