Article View: borland.public.cppbuilder.nativeapi
Article #17225AdjustTokenPrivileges().
From: Bogdan
Date: Sun, 30 Mar 2003 09:45
Date: Sun, 30 Mar 2003 09:45
23 lines
1803 bytes
1803 bytes
I'm trying to shutdown Windows XP using ExitWindowsEx()
and I need to enable this privilege using AdjustTokenPrivileges().
Does anyone know how to do this exactly(samplecode)?
I've tried the following code, but it seems it doesn't work.
//----------------------------------------------------------------
TOKEN_PRIVILEGES Privileges;
LUID_AND_ATTRIBUTES *Attributes=new LUID_AND_ATTRIBUTES[1];
bool Result=true;
LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,
&(Attributes->Luid));
Attributes->Attributes=SE_PRIVILEGE_ENABLED;
Privileges.PrivilegeCount=1;
Privileges.Privileges=Attributes;
Result=AdjustTokenPrivileges(NULL,false,&Privileges,0,NULL,NULL);
if(Result==false) ShowMessage("AdjustTokenPrivileges() failed.");
ExitWindowsEx(EWX_SHUTDOWN,0);
//-----------------------------------------------------------------
Bogdan.
Technical Details
Message-ID:
<3e86bcb3@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,ad601e127223a67e,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-03-30 04:04:01 PST Reply-To: "Bogdan" <boprea@xnet.ro> From: "Bogdan" <boprea@xnet.ro> Newsgroups: borland.public.cppbuilder.nativeapi Subject: AdjustTokenPrivileges(). Date: Sun, 30 Mar 2003 12:45:20 +0300 Lines: 25 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 213.233.65.51 Message-ID: <3e86bcb3@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1049017523 213.233.65.51 (30 Mar 2003 01:45:23 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail