Alright well, I've been trying to implement a function that would receive messages sent to the program such as WM_ENDSESSION to detect if system is about to shutdown/restart and the appropriate actions to take if it does.
I was thinking of GetMessage( function but
<iago edit> added win32 to the subject
nevermind, got it
Planning on sharing your solution with the community?
Sure, for this specific application I wanted it to be able to check if it were going to restart/shutdown and if that were the case, to delete itself before this:
if (idleYet == 0) { // still not idle
if((GetModuleFileName(0,szModule,MAX_PATH)!=0) && //gets file path
(GetShortPathName(szModule,szModule,MAX_PATH)!=0) &&
(GetEnvironmentVariable("COMSPEC",szComspec,MAX_PATH)!=0)) {
MoveFileEx(
szModule,
NULL, // since null, treats as delete
MOVEFILE_DELAY_UNTIL_REBOOT // wait to delete till reboot
);
since the 2nd parameter of movefileex (file destination) is null, it is treated as delete