Author Topic: [win32] C++ Issue  (Read 4237 times)

0 Members and 1 Guest are viewing this topic.

Offline ink

  • Newbie
  • *
  • Posts: 74
    • View Profile
[win32] C++ Issue
« 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
« Last Edit: March 08, 2006, 04:06:25 pm by iago »

Offline ink

  • Newbie
  • *
  • Posts: 74
    • View Profile
Re: [win32] C++ Issue
« Reply #1 on: March 08, 2006, 07:10:48 pm »
nevermind, got it

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: [win32] C++ Issue
« Reply #2 on: March 09, 2006, 12:40:18 am »
Planning on sharing your solution with the community?
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline ink

  • Newbie
  • *
  • Posts: 74
    • View Profile
Re: [win32] C++ Issue
« Reply #3 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