🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Problem with shutdown

#4892
From: Tomislav
Date: Thu, 10 Nov 2005 12:45
32 lines
2181 bytes
Thanx Richard I'll try that.


Richard Bradbrook wrote:
> 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: <437340d8$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4373259e@newsgroups.borland.com> <43733b62@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
Date: Thu, 10 Nov 2005 13:45:47 +0100
From: Tomislav <"rif"@net.hr>
Reply-To:  rif@net.hr
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Problem with shutdown
References: <4373259e@newsgroups.borland.com> <43733b62@newsgroups.borland.com>
In-Reply-To: <43733b62@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 83.131.105.19
Message-ID: <437340d8$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1131626712 83.131.105.19 (10 Nov 2005 04:45:12 -0700)
Lines: 32
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail