🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Problem with shutdown

#4891
From: Richard Bradbrook
Date: Thu, 10 Nov 2005 12:22
24 lines
2053 bytes
Looks ok to me... my guess is the problem lies with your laptop and some 
other program not closing down properly.

Might be an idea to put some error checking into that code though, in case 
something (OpenProcessToken, LookupPrivilegeValue etc) fails.

"Tomislav" <rif@net.hr> wrote in message 
news:4373259e@newsgroups.borland.com...
>I use the following code to shutdown my computer
>
> HANDLE hToken;
> TOKEN_PRIVILEGES tkp;
> OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | 
> TOKEN_QUERY, &hToken);
> LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);
> tkp.PrivilegeCount = 1;
> tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
> AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,(PTOKEN_PRIVILEGES)NULL,0);
> ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0);
>
> the problem is that this works fine on my PC, but on my laptop it closes 
> everything and freezes leaving only the wallpaper and mouse cursor. Am I 
> doing something wrong, can someone suggest me how to fix this.
> Thanx in advance. 
Technical Details
Message-ID: <43733b62@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!transit.nntp.hccnet.nl!transit1.nntp.hccnet.nl!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <4373259e@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d179e7e20c307d12
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Richard Bradbrook" <dont@spamme.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4373259e@newsgroups.borland.com>
Subject: Re: Problem with shutdown
Date: Thu, 10 Nov 2005 12:22:22 -0000
Lines: 26
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 86.136.63.228
Message-ID: <43733b62@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1131625314 86.136.63.228 (10 Nov 2005 04:21:54 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!transit.nntp.hccnet.nl!transit1.nntp.hccnet.nl!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail