Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > C++ Programm - Shutdown win2k

Reply
Thread Tools

C++ Programm - Shutdown win2k

 
 
Andreas Horneff
Guest
Posts: n/a
 
      08-16-2004
Hi at all,

I've got this function (written in BC++)

bool TShutdown::MySystemShutdown()
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;

// Get a token for this process.

if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
return( FALSE );

// Get the LUID for the shutdown privilege.

LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid);

tkp.PrivilegeCount = 1; // one privilege to set
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

// Get the shutdown privilege for this process.

AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES)NULL, 0);

if (GetLastError() != ERROR_SUCCESS)
return FALSE;

// Shut down the system and force all applications to close.

if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0))
return FALSE;

return TRUE;
}

Now my problem. When I execute this funtion on my Laptop, running with
WinXP, my Laptop shuts
down and switchs off.

On my other system, running with win2k, win2k shut down, but the PC didn't
switch off. My Mainboard
supports this function. When I click at 'Start', 'Shutdown', the PC switchs
off, after shutdown. Why
dosen't it switch off, when I run my Function?! Can anyone help me?
Or can anyone tell me an other way, to realize that?!

THX a lot!!!

(The function isn't written by myself, I found it at the WWW)

Sorry for my bad english...

Andreas


 
Reply With Quote
 
 
 
 
lallous
Guest
Posts: n/a
 
      08-16-2004
"Andreas Horneff" <> wrote in message
news:cfq172$f6r$02$...
> Hi at all,
>
> I've got this function (written in BC++)
>
> bool TShutdown::MySystemShutdown()
> {
> HANDLE hToken;
> TOKEN_PRIVILEGES tkp;
>
> // Get a token for this process.
>
> if (!OpenProcessToken(GetCurrentProcess(),
> TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
> return( FALSE );
>
> // Get the LUID for the shutdown privilege.
>
> LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
> &tkp.Privileges[0].Luid);
>
> tkp.PrivilegeCount = 1; // one privilege to set
> tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
>
> // Get the shutdown privilege for this process.
>
> AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
> (PTOKEN_PRIVILEGES)NULL, 0);
>
> if (GetLastError() != ERROR_SUCCESS)
> return FALSE;
>
> // Shut down the system and force all applications to close.
>
> if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0))
> return FALSE;
>
> return TRUE;
> }
>
> Now my problem. When I execute this funtion on my Laptop, running with
> WinXP, my Laptop shuts
> down and switchs off.
>
> On my other system, running with win2k, win2k shut down, but the PC didn't
> switch off. My Mainboard
> supports this function. When I click at 'Start', 'Shutdown', the PC

switchs
> off, after shutdown. Why
> dosen't it switch off, when I run my Function?! Can anyone help me?
> Or can anyone tell me an other way, to realize that?!
>
> THX a lot!!!
>
> (The function isn't written by myself, I found it at the WWW)
>
> Sorry for my bad english...
>
> Andreas
>
>


Hello Andreas,

I would suggest that you re-post this question to
microsoft.public.win32.programmer.kernel.

Here C++ (not related to OS) topics are discussed.

--
Elias


 
Reply With Quote
 
 
 
 
Jack Klein
Guest
Posts: n/a
 
      08-17-2004
On Mon, 16 Aug 2004 12:10:40 +0200, "Andreas Horneff"
<> wrote in comp.lang.c++:

The fastest way to shut down any version of Windows is to open email
in Outlook Express.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Win2k shutdown =?ISO-8859-1?Q?Brian_H=B9=A9?= Computer Support 6 10-06-2006 03:57 PM
ie6 sudden auto shutdown in win2k pro ... f f Computer Support 13 02-06-2006 04:39 AM
Win2k Slow Shutdown dakine Computer Support 2 08-26-2004 02:46 AM
win98 on c:, win2k on d: boot.ini only shows win2k thing NZ Computing 3 08-15-2004 06:47 PM
Virus causing Win2k to come up with shutdown window ? Ed Computer Support 3 07-14-2004 04:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57