🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10352

Re: Custom Shutdown

#10352
From: Malcolm Smith
Date: Tue, 20 Apr 2004 03:27
96 lines
4044 bytes
Thanks for this this extra information.  Much appreciated.

-- 
Malcolm Smith
MJ Freelancing
http://www.mjfreelancing.com



"Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> wrote in message
news:4084916b$1@newsgroups.borland.com...
>
> "Malcolm Smith" <m.smith@comvision.net.au> wrote in message
> news:4084732e@newsgroups.borland.com...
>
> > how do I tell it which entry from the registry I want logged
> > in the event viewer.
>
> By passing the actual custom codes as the reason when calling
> ExitWindowsEx(), ie:
>
>     // reason codes are laid out as follows:
>     // 0xAABBCCCC
>     // AA = 8-bit flags
>     // BB = 8-bit major code
>     // CCCC = 16-bit minor code
>
>     // name these whatever you want...
>     #define MY_MAJOR_REASON_CODE        0x00400000 // 64 left-shifted 16
> bits
>     #define MY_MINOR_REASON_CODE_0    0x00000000
>     #define MY_MINOR_REASON_CODE_1    0x00000001
>     #define MY_MINOR_REASON_CODE_2    0x00000002
>
>     ExitWindowsEx(
>         EWX_REBOOT,
>         SHTDN_REASON_FLAG_USER_DEFINED |
>             SHTDN_REASON_FLAG_PLANNED |
>             MY_MAJOR_REASON_CODE |
>             MY_MINOR_REASON_CODE_0);
>
> To help make the code a little more readable, you can define some helper
> macros that will generate a reason code from values you provide it:
>
>     #define MAKE_REASON_FLAGS(flags) \
>         (((DWORD)((BYTE)(flags))) << 24)
>
>     #define MAKE_REASON_MAJOR(major) \
>         (((DWORD)((BYTE)(major))) << 16)
>
>     #define MAKE_REASON_MINOR(minor) \
>         ((DWORD)((WORD)(minor)))
>
>     #define MAKE_REASON_CODE(flags, major, minor)    \
>         (MAKE_REASON_FLAGS(flags) | \
>         MAKE_REASON_MAJOR(major) | \
>         MAKE_REASON_MINOR(minor))
>
> Then you can call it with hard-coded values:
>
>     ExitWindowsEx(
>         EWX_REBOOT,
>         MAKE_REASON_CODE(
>             SHTDN_REASON_FLAG_USER_DEFINED |
>                 SHTDN_REASON_FLAG_PLANNED,
>             64,
>             0)
>     );
>
> or use defines for the custom codes:
>
>     #define MY_MAJOR_REASON_CODE        64 // <-- not hex like above
>     #define MY_MINOR_REASON_CODE_0    0
>     #define MY_MINOR_REASON_CODE_1    1
>     #define MY_MINOR_REASON_CODE_2    2
>
>     ExitWindowsEx(
>         EWX_REBOOT,
>         MAKE_REASON_CODE(
>             SHTDN_REASON_FLAG_USER_DEFINED |
>                 SHTDN_REASON_FLAG_PLANNED,
>             MY_MAJOR_REASON_CODE,
>             MY_MINOR_REASON_CODE_0)
>     );
>
> As for the Registry, the only purpose of the Registry values is to set up
> dialog flags and title/description information for the event loggers.
When
> you specify a reason code, ExitWindowsEx() decyphers what the specified
> major and minor codes are and then looks up their cooresponding values in
> the Registry for display/logging.
>
>
> Gambit
>
>
Technical Details
Message-ID: <408493ca@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!newsfeed.esat.net!newsfeed.wirehub.nl!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4084732e@newsgroups.borland.com> <4084916b$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,362cd189c238eed0
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-04-19 20:09:34 PST
Reply-To: "Malcolm Smith" <m.smith@comvision.net.au>
From: "Malcolm Smith" <m.smith@comvision.net.au>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4084732e@newsgroups.borland.com> <4084916b$1@newsgroups.borland.com>
Subject: Re: Custom Shutdown
Date: Tue, 20 Apr 2004 13:27:59 +1000
Lines: 98
Organization: Comvision Pty Ltd
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 144.137.108.190
Message-ID: <408493ca@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1082430410 144.137.108.190 (19 Apr 2004 20:06:50 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!newsfeed.esat.net!newsfeed.wirehub.nl!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail