怎么样防止自己的程序运行多遍?

解决方案 »

  1.   

    互斥元,原子标记什么的
    方法多的是就不会自己去Google找么??_____________________
    http://lysoft.7u7.net
      

  2.   

    implementation 
    var hnd: THandle;initialization
        hnd := CreateMutex(nil, True, 'Application name');
        if GetLastError = ERROR_ALREADY_EXISTS then Halt;finalization
        if hnd <> 0 then CloseHandle(hnd);
    end.
    在工程文件中使用
      

  3.   

    Var
    hMutex:HWND;
    Ret:Integer;
    begin
    Application.Initialize;
    Application.Title := ’aaaaaa’;
    hMutex:=CreateMutex(nil,False,’aaaaaa’);
    Ret:=GetLastError;
    If Ret<>ERROR_ALREADY_EXISTS Then 
    Begin
    Application.CreateForm(TForm1, Form1);
    Application.Run;
    End
    Else
    Application.MessageBox(’Run Twice!’,’Notes!’,MB_OK);
    ReleaseMutex(hMutex);
    end.