how to delay shutdown and run a process in window service

前端 未结 5 1009
余生分开走
余生分开走 2020-11-27 21:29

I have to run a process ie a application on windows shutdown, is there any method to delay the windows shutdown and run the application in windows service...



        
5条回答
  •  无人及你
    2020-11-27 22:04

    I have a similar problem, and there is one trick that might work in your case. You can start application in question before shutdown is initiated with CREATE_SUSPENDED flag (see this). This will ensure that the process will be created, but never run. On shutdown you can ResumeThread that process, and it will go on with execution.

    Note, that it might be possible that the process will not be able to initialize and run anyway, since during shutdown some OS functions will fail.

    Another implication is: the process which is supposed to run on shutdown will show in task manager. It would be possible to kill that process.

提交回复
热议问题