🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Windows Shutting Down.

#17667
From: Farmazon
Date: Sun, 09 Mar 2003 01:57
32 lines
2050 bytes
"Safari" <Safari@alloymail.com> �������/�������� � �������� ���������:
news:3e4caeb2@newsgroups.borland.com...
> Thanks Darren Stone,
> I found this code from http://msdn.microsoft.com but not to work! Why?
>
> BOOL __fastcall SystemShuting()
> {
>    HANDLE hHandle;
>    TOKEN_PRIVILEGES hToken;
>    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES |
>    TOKEN_QUERY, &hHandle));
>    return (FALSE);
>    LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&hToken.Privileges[0].Luid);
>    hToken.PrivilegeCount = 1;
>    hToken.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
>    AdjustTokenPrivileges(hHandle, FALSE, &hToken, 0,
> (PTOKEN_PRIVILEGES)NULL, 0);
>    if (GetLastError() != ERROR_SUCCESS) return FALSE;
>    if (!ExitWindowsEx(EWX_REBOOT, 0))
>    return FALSE;
> }
>
> Thanks again,
> Safari
>
>

You need handle message WM_QUERYENDSESSION and WM_ENDSESSION or close
application after call
ExitWindowsEx.
Technical Details
Message-ID: <3e6aa36a@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3e49fc34@newsgroups.borland.com> <3e4b2176$1@newsgroups.borland.com> <3e4caeb2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10cc67,41fe1fef80a12519,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-03-08 18:16:39 PST
From: "Farmazon" <farmazon@ukrpost.net>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3e49fc34@newsgroups.borland.com> <3e4b2176$1@newsgroups.borland.com> <3e4caeb2@newsgroups.borland.com>
Subject: Re: Windows Shutting Down.
Date: Sun, 9 Mar 2003 03:57:08 +0200
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 212.68.163.219
Message-ID: <3e6aa36a@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1047176042 212.68.163.219 (8 Mar 2003 18:14:02 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail