I spend some time investigating if the Windows shut-down events can be stopped or halted.
Aprantly you can halt or cancel the windows shut-down by stalling the wndproc (see code exampl;e below).
Sadly this is no guarantee. I tried this a few times, sometimes this worked, but other times ffmpeg was already closed and the .mp4 file corrupt. Too bad, I though I was nearly there.
There is a console way of 'detecting' a windows logoff/shutdown/close event about to happen, referenced here:http://msdn.microsoft.com/nl-nl/library ... 85%29.aspx
Example code for console applications here:http://osdir.com/ml/windows.devel.dotne ... 00214.html
I hope this may help.
Best Regards, Michael
protected override void WndProc(ref Message m)
if (m.Msg == WM_QUERYENDSESSION)
SendFFMPEGstopCommand(); // sends 'q' to FFmpeg
Thread.sleep(5000); // allow 5 seconds before windows proceeds to close stuff. This works a few seconds then Windows proceeds anyway.
Edit: I know all examples are c# based, but think the c++ variants should be the same.