Reputation: 649
How can I pause shutdown long enough for my app? I found an example, but it is for Delphi - I can't translate it to C++.
Upvotes: 1
Views: 1065
Reputation: 596111
Here is a C++Builder VCL translation of the Delphi code:
class TForm1 : public TForm
{
..
protected:
void __fastcall WMQueryEndSession(TWMQueryEndSession &Message);
..
public:
..
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_QUERYENDSESSION, TWMQueryEndSession, WMQueryEndSession)
END_MESSAGE_MAP(TForm)
};
...
void __fastcall TForm1::WMQueryEndSession(TWMQueryEndSession &Message)
{
Message.Result = TRUE;
if ((Message.Unused & ENDSESSION_CRITICAL) == 0)
{
ShutdownBlockReasonCreate(Handle, L"please wait while muting...");
Sleep(45000); // do your work here
ShutdownBlockReasonDestroy(Handle);
}
}
Upvotes: 4