Clan x86

Technical (Development, Security, etc.) => General Programming => Topic started by: ink on March 08, 2006, 02:01:59 pm

Title: [win32] C++ Issue
Post by: ink on March 08, 2006, 02:01:59 pm
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
Title: Re: [win32] C++ Issue
Post by: ink on March 08, 2006, 07:10:48 pm
nevermind, got it
Title: Re: [win32] C++ Issue
Post by: MyndFyre on March 09, 2006, 12:40:18 am
Planning on sharing your solution with the community?
Title: Re: [win32] C++ Issue
Post by: ink on March 23, 2006, 01:10:49 pm
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:

Code: [Select]
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