在delphi中如何禁止程序多次启动(包括本身程序,外部的程序)

解决方案 »

  1.   

    建一个互斥对象,在应用程序开始时:
    var hnd:Handle;  
      hnd := CreateMutex(nil, True, '{631BCE72-D32A-42B9-9F70-FAB5106F5630}');
      if GetLastError = ERROR_ALREADY_EXISTS then Halt;
      

  2.   

    var hnd: THandle;initializationhnd := CreateMutex(nil, True, 'irgendwaseinmaliges');if GetLastError = ERROR_ALREADY_EXISTS then Halt;finalizationif hnd <> 0 then CloseHandle(hnd);end.
    这个还用解释啊?
    CreateMutex创建一个对象,如果创建出错则这个对象已经有了,就说明已经有程序运行了,
      

  3.   

    http://218.56.11.178:8000/web/TheDown.aspx?ID=12