Delphi防止程序重复运行(互斥方式)

procedure TForm1.FormCreate(Sender: TObject);

begin
    CreateMutex(nil,False,'Form1');
    if GetLastError=ERROR_ALREADY_EXISTS then
    begin
       ShowMessage('程序已运行,请勿执行多个程序实例');
      Halt(0);
    end;
end;