Restart Delphi Application Programmatically

前端 未结 9 1459
情深已故
情深已故 2021-02-09 06:58

It should not be possible to run multiple instances of my application. Therefore the project source contains:

CreateMutex (nil, False, PChar (ID));
if (GetLastEr         


        
9条回答
  •  既然无缘
    2021-02-09 07:57

    Include in your ShellExecute some parameter, for example, /WaitForShutDown and create one more mutex. In your program, before the initialization, for example, in its .dpr file, insert something like:

    if (Pos('/WaitForShutDown', CmdLine) <> 0) then WaitForSingleObject(ShutDownMutexHandle, INFINITE);

    Also, in your program, after all the finalizations and releasing your common resources, include something like

    ReleaseMutex(ShutDownMutexHandle);

提交回复
热议问题