News:

Happy New Year! Yes, the current one, not a previous one; this is a new post, we swear!

Main Menu

[win32] C++ Issue

Started by ink, March 08, 2006, 02:01:59 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

ink

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

ink


MyndFyre

Planning on sharing your solution with the community?
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

ink

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