Z
zqw0117
Unregistered / Unconfirmed
GUEST, unregistred user!
我想让我的程序只启动一次(保证内存中只有一个副本),下面是我的代码,请问有无
问题?
program WaitForSingleObject_app;
uses
Forms,
Windows,
Dialogs,
WaitForSingleObject_func in 'WaitForSingleObject_func.pas' {Form1};
{$R *.res}
begin
if WaitForSingleObject(CreateMutex(nil, False, 'MyProgramsMutexName'),0)<>WAIT_OBJECT_0 then
begin
Exit;
end;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
问题?
program WaitForSingleObject_app;
uses
Forms,
Windows,
Dialogs,
WaitForSingleObject_func in 'WaitForSingleObject_func.pas' {Form1};
{$R *.res}
begin
if WaitForSingleObject(CreateMutex(nil, False, 'MyProgramsMutexName'),0)<>WAIT_OBJECT_0 then
begin
Exit;
end;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.