Article View: borland.public.cppbuilder.nativeapi
Article #5219Re: Reset and restarting
From: Nerio
Date: Tue, 30 Aug 2005 10:10
Date: Tue, 30 Aug 2005 10:10
50 lines
2705 bytes
2705 bytes
"Nerio" <ne_serzanti@tin.it> ha scritto nel messaggio
news:4312e8e4@newsgroups.borland.com...
> "Remy Lebeau (TeamB)" <no.spam@no.spam.com> ha scritto nel messaggio
> news:431212ad$1@newsgroups.borland.com...
>>
>> "Nerio" <ne_serzanti@tin.it> wrote in message
>> news:4310fd3c@newsgroups.borland.com...
>>
>>> Sorry for trouble, but why ExitWindowsEx(EWX_FORCE or EWX_LOGOFF
>>> or EWX_SHUTDOWN, 0) go fine and ....(EWX_REBOOT or EWX_POWEROFF,
>>> 0) seem do nothing?
>>
>> Did you read the documentation for ExitWindows() yet? Did you adjust
>> your
>> program's privileges to allow rebooting in the first place?
>>
>>
>> Gambit
>>
> Really I am not able to change priviliges!
> My listing is : ...........
> Nerio
>
The point is not my structures knowledge (or not only) but particularly my
manifest ignorance of Windows.
Searching in Googles I found this listing (adapted for my use) :
------
{ HANDLE hToken;
TOKEN_PRIVILEGES newTp, oldTp;
unsigned long dwSize = sizeof(TOKEN_PRIVILEGES);
LUID luid;
if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES |
TOKEN_QUERY,
&hToken))
{ ShowMessage("Error opening ProcessToken"); return; }
if(!LookupPrivilegeValue(0, SE_SHUTDOWN_NAME, &luid))
{ ShowMessage("Error reading PrivilegeValue"); return; }
newTp.PrivilegeCount = 1;
newTp.Privileges[0].Luid = luid;
newTp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if(!AdjustTokenPrivileges(hToken, false, &newTp, sizeof(TOKEN_PRIVILEGES),
&oldTp, &dwSize))
{ ShowMessage("Error on AdjustToken - (enabling)"); CloseHandle(hToken);
return; }
ExitWindowsEx(EWX_REBOOT, 0);
}
------
Many thanks again for help
Nerio
Technical Details
Message-ID:
<4314307c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder.xsnews.nl!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4310fd3c@newsgroups.borland.com> <431212ad$1@newsgroups.borland.com> <4312e8e4@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,1b699533025a4e6b X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Nerio" <ne_serzanti@tin.it> Newsgroups: borland.public.cppbuilder.nativeapi References: <4310fd3c@newsgroups.borland.com> <431212ad$1@newsgroups.borland.com> <4312e8e4@newsgroups.borland.com> Subject: Re: Reset and restarting Date: Tue, 30 Aug 2005 12:10:49 +0200 Lines: 52 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 82.53.152.38 Message-ID: <4314307c$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1125396604 82.53.152.38 (30 Aug 2005 03:10:04 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder.xsnews.nl!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail