Quest: Getting Info if the user/programs tried to shutdown/restart...

I have a project that handles CWnd::OnQueryEndSession() and my handler was 
taking to long and the force program to exit dlgbox appeared so I decided to 
start timer and return false to CWnd::OnQueryEndSession() and do the work I 
need to do in the timer handler(kill timer quickly) and then 
shutdown/restart the system and letting CWnd::OnQueryEndSession() return 
true...

This works fine except when I call ExitWindowsEx(...) I don't know which 
param to pass(shutdown/restart) cause my code doesn't know if I Start -> 
Turn off computer -> Shutdown or if I Start -> Turn off computer -> 
Restart...

Is there some Win32API function I missing to get this info...

Any help.... 


0
6/15/2005 10:11:58 PM
vc.mfc 33608 articles. 0 followers. Follow

6 Replies
395 Views

Similar Articles

[PageSpeed] 46

I tend to worry about programs that try to reboot the machine...and you also can't tell if
it is just a logoff request that wouldn't require a reboot.

Why a timer? Why not just PostMessage to yourself?
				joe


On Wed, 15 Jun 2005 15:11:58 -0700, "bj7lewis" <bj7lewis@rio.com> wrote:

>I have a project that handles CWnd::OnQueryEndSession() and my handler was 
>taking to long and the force program to exit dlgbox appeared so I decided to 
>start timer and return false to CWnd::OnQueryEndSession() and do the work I 
>need to do in the timer handler(kill timer quickly) and then 
>shutdown/restart the system and letting CWnd::OnQueryEndSession() return 
>true...
>
>This works fine except when I call ExitWindowsEx(...) I don't know which 
>param to pass(shutdown/restart) cause my code doesn't know if I Start -> 
>Turn off computer -> Shutdown or if I Start -> Turn off computer -> 
>Restart...
>
>Is there some Win32API function I missing to get this info...
>
>Any help.... 
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
6/16/2005 3:09:58 AM
>I tend to worry about programs that try to reboot the machine...and you 
>also can't tell if
> it is just a logoff request that wouldn't require a reboot.
Thanks... I have the same worry but this is only a personal app and will 
never be public. However if this was an app intended to be public(you 
worry), the systems is already in pending shutdown mode and sending the 
WM_QUERYENDSESSION msgs to all process and I am only the shutdown request 
cold and do my stuff then resend the shutdown request... Also I don't ever 
log-off on my system just shutdown or restart it...

> Why a timer? Why not just PostMessage to yourself?
Try to stay out of reg/sending werid msgs and the timer is a simple MFC CWnd 
timer...

Any more help... 


0
6/16/2005 4:34:44 AM
Actually, sending a user-defined message is not "weird", it is quite normal. Using a timer
is what is weird...
				joe

On Wed, 15 Jun 2005 21:34:44 -0700, "bj7lewis" <bj7lewis@rio.com> wrote:

>>I tend to worry about programs that try to reboot the machine...and you 
>>also can't tell if
>> it is just a logoff request that wouldn't require a reboot.
>Thanks... I have the same worry but this is only a personal app and will 
>never be public. However if this was an app intended to be public(you 
>worry), the systems is already in pending shutdown mode and sending the 
>WM_QUERYENDSESSION msgs to all process and I am only the shutdown request 
>cold and do my stuff then resend the shutdown request... Also I don't ever 
>log-off on my system just shutdown or restart it...
>
>> Why a timer? Why not just PostMessage to yourself?
>Try to stay out of reg/sending werid msgs and the timer is a simple MFC CWnd 
>timer...
>
>Any more help... 
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
6/16/2005 4:56:07 AM
> Actually, sending a user-defined message is not "weird", it is quite 
> normal. Using a timer
> is what is weird...
Don't know about you, but I once reg/post custom msgs in a threaded app(but 
the app was lost in a HDD format accident) and that was werid to me but a 
timer is quick to me and is working...

Getting back to my problem is getting info if the user/programs tried to 
shutdown/restart...

Any more help... 


0
6/16/2005 6:33:18 AM
Well, it may seem weird if you did it only once. I can't recall a serious program I've
written in the last dozen years or more that didn't use custom messages.

I don't think there is any way to tell what the reason for the restart is...
				joe

On Wed, 15 Jun 2005 23:33:18 -0700, "bj7lewis" <bj7lewis@rio.com> wrote:

>> Actually, sending a user-defined message is not "weird", it is quite 
>> normal. Using a timer
>> is what is weird...
>Don't know about you, but I once reg/post custom msgs in a threaded app(but 
>the app was lost in a HDD format accident) and that was werid to me but a 
>timer is quick to me and is working...
>
>Getting back to my problem is getting info if the user/programs tried to 
>shutdown/restart...
>
>Any more help... 
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
6/16/2005 7:05:41 AM
> Well, it may seem weird if you did it only once. I can't recall a serious 
> program I've
> written in the last dozen years or more that didn't use custom messages.
Well that was a seriously coded app with alot features & alot of man hour - 
shame I lost it and am planning on building it again one day but I have 
other project before and this shutdown handler is one of them. Though it is 
not very seriously pieced together cause I need it ASP and I can start on my 
next seriously coded app that I an looking for to the time and effort...

> I don't think there is any way to tell what the reason for the restart 
> is...
OK... Thanks for coming back here... I am going to fix this by adding two 
simple button(Shutdown/Restart) that their handlers call ExitWindowsEx(...) 
with the respected param...

Thanks again... 


0
6/16/2005 2:54:18 PM
Reply:

Similar Artilces:

how to get unrepresented categories to show up in an xtab query
hello: I have set up a db that creates several cross-tab queries in the end that I want to export to Excel to an existing template that has all of the analyses I need in it - that part I've done, but I'm having problems with something seemingly simple - in the crosstabs, if a group is not represented, it is dropped out - this is fine in Access, but the moment it is exported into Excel, the data aren't analysed correctly. so for example, w/ the following age groups in my student data Under 20 21-25 26-30 31-35 36-40 41-45 46-50 51-55 56-60 60-65 66+ many times, the last three g...

how do i get excel to automatically compute cell values
I need to know how to get excel to automatically compute the cell values when i'm changing it to a different number ex: My point threshold is 400, i cahnge it to 350, how do i make excel automatically convert the right average when any number is changed It's unclear from your post what you are trying to do. if you are calculating the average of a list of numbers, when you change a number in the list, the average calculated by the formula changes. Go to Tools | Options & select the Calculation tab. Make sure either Automatic or Automatic except tables is selected - not M...

User rights to access mailbox size
Hi, I created a vbscript which enumerates users with mailboxes in AD, retrieves the mailbox size for each user (as described in MS KB 320071 using WebDAV) and writes these values in a SQL database. Right now I can only retrieve mailbox size values for users I have "Full Mailbox Access" to their mailboxes. Before giving myself "Full Mailbox Access" on all users, I'd like to know the minimum user rights I need to access this info. TIA, Wouter send as should do the trick Cheers oz -- Best regards, Good Luck Oz Ozugurlu MCSE 2003 messaging, Security "Wouter&quo...

Getting a subform control to requery
Main Form : F_BU Subform1: F_BU_Cat2 SubForm2: F_BU_Cat3 When I click on one of the records in subform1 (field BillCat) the OnClick event uses the value in the field as a criteria in a query that is used in the combox (cbxCat3) in Subform 2. Here is the code I was trying to use: Me.Parent!F_BU_Cat3.Form!cbxCat3.Requery It was working for a while but now not when I click on the "BillCat" field in Subform 1 I get: Method: Form" of Object ' _Subform' Failed. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-form...

Getting SUM to return null
Hi, I know the normal behavior of SUM is to eliminate null values from the set before doing the sum, but I have a case where I actually want the result to be null if any of the input set is null. Can I get Sql Server 2005 to do this? Or will I have to do something else? Thanks Andy "Andy" <andy.johnstone@med-associates.com> wrote in message news:61c80731-711d-4e2e-ab75-2adbe2e2f701@37g2000vbn.googlegroups.com... > Hi, > > I know the normal behavior of SUM is to eliminate null values from the > set before doing the sum, but I have a case where I...

Weiterleiten an Windows MailExport QUEST
ich schicke und weiterleiten an euch von KarlFutterer@yahoo,comsmsung,de ...

DPM 2007: Expired recovery points not getting deleted completely
Hi, I have a DPM 2007 server running in my environment. It's being used to take the backup of the File servers. The DPM server has already been updated to SP1. The problem that I am having is I'm constantly running out of space on the recovery points volume. Though the recovery points are getting deleted fine according to the retention range that's been set and even after deleting them manually, i still don't see any change in the free space of the storage pool attached to the DPM server. Please note that I have already applied the following patch: http://s...

Office Programs Won't Open?
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel I just installed Microsoft Office 2008, and then it checked for updates so I installed the most recent update. Then I tried to open word, excel, and powerpoint and a message pops up for all of them saying that they can't open. I tried restarting and it didn't fix anything. I followed all directions for the installation too. Microsoft Messenger and Entourage open though? Help! On 12/3/09 7:02 PM, in article 59bae1ee.-1@webcrossing.JaKIaxP2ac0, "cieciura@officeformac.com" <cieciura@officefo...

How to get Guid
Hi! I am currently buiding an ASP.NET web page to retrieve some records from CRM. The code looks like below. Now I want to delete some of the records retrieved and I need the Guid of these records. How can I get them? Anyone knows? Thanks in advance. // Put user code to initialize the page here CrmService service = new CrmService(); service.Credentials = System.Net.CredentialCache.DefaultCredentials; ColumnSet columns = new ColumnSet(); columns.Attributes = new string[] {"name", "accountid"}; QueryExpression query = new QueryExpression(); query.EntityName = EntityNa...

Get child window HWND
Hi! I`m opening new MDI child window with CDocTemplate::OpenDocumentFile(NULL). I want �� send messages to this window, but I don`t know its HWND. How can I get it. (i) The MDIChildFrame is a child of the MDI Client area. So you can do a GetWindow(GW_CHILD) to get the child frame handle. (ii) OpenDocumentFile() returns CDocument *. So you can query the document for active frame. -SM On Sep 4, 5:21 am, quee...@gmail.com wrote: > Hi! > I`m opening new MDI child window with > CDocTemplate::OpenDocumentFile(NULL). I want =C5=DD send messages to this > window, but I don`t know i...

Business Portal User Profile Properties
I am integrating BP 4 with MOSS and I am receiving errors such as this in the event log: Microsoft.Office.Server.UserProfiles.PropertyNotDefinedException: Property Not Defined: CompanyKeyID. I am also getting this error: The following error occurred when attempting to set containment using the Microsoft.Dynamics.GP.BusinessPortal.Containment.OfficeServer.OfficeServerContainmentProvider provider: Which if I traverse far enough down the call stack, also has to do with user profiles. I have installed the GP web service on the server and enetered the path during installation hand I see t...

Automatic Shutdown Before the Next Day
I’m trying to figure out how to get an access database to shutdown automatically every day sometime before midnight. Before shutdown a message prompt should appear… “This program will automatically shutdown in… ( show countdown from 7:00…6: 59…6:58…to…0:00 minutes). It should appear, with a “cancel” button option, so the user can override the timeout operation if they’re using the program at that moment. If the user doesn’t respond to the message, the program should just shutdown. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access/20...

Empty outbox but Outlook tries to send
Hi NG, When I press send/receive Outlook shows in its status bar that it works on sending emails (Sending messages 1 of 4) but there is not mail in outbox. As a result I currently cannot send any other mails since Outlook keeps working on the 4 emails I don't see. Any ideas, I am clueless? - Thanks a lot for any help!!!! Dirk ...

Microsoft Publisher 101
http://office.microsoft.com/en-us/assistance/HP030710631033.aspx Never assume someone knows how to put text on the page! This "how to" explains exactly why Publisher can be more flexible than Word. -- Brian Kvalheim Microsoft Publisher MVP http://www.publishermvps.com ~pay it forward~ This posting is provided "AS IS" with no warranties, and confers no rights. ...

Quest: Source Revision Systems...
I am working on a OS(no more talk about that here) project that I am developementing with VC++ .NET on my lab top and on my desktop system and I don't want to copy the file over manually in Window Explorer... So I want to find a free program like Visual SafeSource or maybe a LAN network batch file copier. If I cant find anything I will build my own batch file copier client/server app... Any help... ...

Getting rid of an old pst
I have outlook 2007 on both desktop and notebook. I did a search and deleted all pst files on the notebook and copied the pst from the desktop back to the notebook. Notebook pst with all emails, ect remain. Can't figure out what to do next. Would like to regularly sinc the two, but have not been successful. Any help would be appreciated Jerry What happens when you start notebook Outlook, does it not give an err.msg? "Jerry" <jerry@home.home> wrote in message news:%23M$UXYpkJHA.5732@TK2MSFTNGP05.phx.gbl... >I have outlook 2007 on both desktop and notebook. I did...

How to get userform Cancel button to invoke Exit Sub in calling macro?
I have a userform that is called from inside a sub in a module of a workbook. In order to keep most of the code inside the module, the userform only sets variables in the sub. Here is the code in the sub: 'create and initialize variables Dim Bkp,XSub as Boolean Dim BkpSfx as String Bkp = True XSub = False 'call options box BackupOptionsBox.Show 'Set main subroutine variables Bkp = BackupOptionsBox.YesOption BkpSfx = "_" & BackupOptionsBox.SfxBox.Value ...

how do i get outlook to open with microsoft exchange in windows 7
i just got Windows 7 , and tried to install my microsoft office ...it works...exept for outlook if i dont put my exchange account in its ok...if i do.. the system tells me it cant open at all....anybody can help me with this??? i need my microsoft exchange account to work. What is the error message you are getting? Mobius73 wrote: >i just got Windows 7 , and tried to install my microsoft office ...it >works...exept for outlook if i dont put my exchange account in its ok...if i >do.. the system tells me it cant open at all....anybody can help me with >this??? >...

Format did not get sorted
I've a spreadsheet when I've formatted certain cells with fills and borders. But when I sort, the formatting stays and did not move with the cells. Is it possible to sort the cells such that the formatting doesn't get messed up? Thanks. Hi see your other post -- Regards Frank Kabel Frankfurt, Germany "Derrick" <Derrick@discussions.microsoft.com> schrieb im Newsbeitrag news:3498C631-710C-4DFA-A4D4-0EB9803035E7@microsoft.com... > I've a spreadsheet when I've formatted certain cells with fills and borders. > > But when I sort, the formatting stay...

cannot get IMF to update
This is a multi-part message in MIME format. ------=_NextPart_000_0009_01C683EE.9571B4F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I'm running exchange 2k3, sp2. I've verified that SP2 is installed. I = created the registry entry to enable updates for IMF, but every time I = go to windows update, there are none for IMF on that server. I also = checked the update folder in program files and only the original update = is there. The only thing about my install that isn't standard is that I = have my exchange program files i...

OWA 2003
I have Exchange 2003 on win2k3 server. If I connect to "http://server/Exchange" all the icons in OWA show up as red x's. If I connect to "http://localhost/Exchange" everything works fine. I've checked the directory permissions on all the folders in c:\exchsrvr\exchweb\* and they are set appropriately. I've also followed the advice I've found in other posts on this list and nothing is working. TIA. -Scott When you look at the properties of the red X normally you can see a path, fully qualified or otherwise, is this a valid path for the browser and do...

Need Money ? Get it now...
Need Money ? Get it now... www.loansuwant.com ...

Can't get rid of 2nd "personal folders" file
I have a second "personal folders" file that seems to have been created. If I click on it or try to close it, I get an error message saying that it couldn't be opened. It does not appear in Data File Management. Scanpst.exe doesn't get rid of it. Single computer. XP. - SP 2. Office 2003. Thoughts? "its_my_dime" <its_my_dime@yahoo.com.spam (hold the spam)> wrote in message news:OjJmM%23GaGHA.5108@TK2MSFTNGP05.phx.gbl... >I have a second "personal folders" file that seems to have been created. >If I click on it or try to close it...

why am I getting this
Yesterday I started getting emails asking to be removed from a mailing list. I did not send them to these people why am I getting the "remove me' emails and how can I stop them. "crodad14" <anonymous@discussions.microsoft.com> wrote in message news:10d8d01c3f3d7$c0831480$a501280a@phx.gbl... > Yesterday I started getting emails asking to be removed > from a mailing list. I did not send them to these people > why am I getting the "remove me' emails and how can I > stop them. Your e-mail address is being quoted in spam e-mails as the origin of s...

Getting Excel error when trying to hide columns. Why?
Since you don't take time to offer the error message I will assume it is this one. http://support.microsoft.com/default.aspx?scid=kb;en-us;211769 Gord Dibben Excel MVP On Thu, 28 Apr 2005 12:18:19 -0700, MClark <MClark@discussions.microsoft.com> wrote: ...