Click here to Skip to main content
15,915,019 members
Home / Discussions / C#
   

C#

 
GeneralHINSTANCE Pin
Andrei Matei20-Mar-03 9:29
Andrei Matei20-Mar-03 9:29 
GeneralRe: HINSTANCE Pin
Stephane Rodriguez.20-Mar-03 21:27
Stephane Rodriguez.20-Mar-03 21:27 
GeneralTreeview 3 State checkbox Pin
vlusardi20-Mar-03 9:09
vlusardi20-Mar-03 9:09 
GeneralRe: Treeview 3 State checkbox Pin
Stephane Rodriguez.20-Mar-03 21:35
Stephane Rodriguez.20-Mar-03 21:35 
GeneralRe: Treeview 3 State checkbox Pin
Member 72690920-Mar-04 8:12
Member 72690920-Mar-04 8:12 
GeneralShutting down a W2K computer Pin
converdb20-Mar-03 9:04
converdb20-Mar-03 9:04 
GeneralRe: Shutting down a W2K computer Pin
Mark Conger20-Mar-03 10:14
Mark Conger20-Mar-03 10:14 
GeneralRe: Shutting down a W2K computer Pin
VoidMainVoid30-Mar-03 16:26
VoidMainVoid30-Mar-03 16:26 
You have to get privileges, here is the example for MSVC++, I think it could be easylly maded in C# or you could siply use a dll, here is the code

BOOL MySystemShutdown()<br />
{<br />
   HANDLE hToken; <br />
   TOKEN_PRIVILEGES tkp; <br />
 <br />
   // Get a token for this process. <br />
 <br />
   if (!OpenProcessToken(GetCurrentProcess(), <br />
        TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) <br />
      return( FALSE ); <br />
 <br />
   // Get the LUID for the shutdown privilege. <br />
 <br />
   LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, <br />
        &tkp.Privileges[0].Luid); <br />
 <br />
   tkp.PrivilegeCount = 1;  // one privilege to set    <br />
   tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; <br />
 <br />
   // Get the shutdown privilege for this process. <br />
 <br />
   AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, <br />
        (PTOKEN_PRIVILEGES)NULL, 0); <br />
 <br />
   if (GetLastError() != ERROR_SUCCESS) <br />
      return FALSE; <br />
 <br />
   // Shut down the system and force all applications to close. <br />
 <br />
   if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0)) <br />
      return FALSE; <br />
<br />
   return TRUE;<br />
}<br />


I hope it helps.

You can read more about privileges here.

Signature...
I look for that at home... tomorrow
GeneralRe: Shutting down a W2K computer Pin
converdb2-Apr-03 7:32
converdb2-Apr-03 7:32 
GeneralInter-app communication in C# Pin
Strat61320-Mar-03 7:06
Strat61320-Mar-03 7:06 
GeneralQuestion about methods. Pin
Jon Newman20-Mar-03 6:51
Jon Newman20-Mar-03 6:51 
GeneralRe: Question about methods. Pin
Daniel Turini20-Mar-03 6:59
Daniel Turini20-Mar-03 6:59 
GeneralRe: Question about methods. Pin
Jon Newman20-Mar-03 7:10
Jon Newman20-Mar-03 7:10 
GeneralRe: Question about methods. Pin
leppie20-Mar-03 7:21
leppie20-Mar-03 7:21 
GeneralRe: Question about methods. Pin
Jon Newman20-Mar-03 7:29
Jon Newman20-Mar-03 7:29 
GeneralRe: Question about methods. Pin
Michal Januszczyk21-Mar-03 12:51
sussMichal Januszczyk21-Mar-03 12:51 
GeneralException Management Application Block Pin
Le centriste20-Mar-03 4:23
Le centriste20-Mar-03 4:23 
GeneralRe: Exception Management Application Block Pin
David Stone20-Mar-03 5:56
sitebuilderDavid Stone20-Mar-03 5:56 
GeneralNeed a URL Combo like Combo box Pin
M Hanif20-Mar-03 1:18
M Hanif20-Mar-03 1:18 
GeneralMicrosoft Masked Edit Control Pin
Romeo20-Mar-03 1:02
Romeo20-Mar-03 1:02 
GeneralRe: Microsoft Masked Edit Control Pin
Roger Alsing20-Mar-03 1:31
Roger Alsing20-Mar-03 1:31 
Generalconvert dll call from vb.net to c#.net Pin
Nachte19-Mar-03 22:41
Nachte19-Mar-03 22:41 
GeneralWhy do my applications need >10 MB RAM Pin
j-hannemann19-Mar-03 21:58
j-hannemann19-Mar-03 21:58 
GeneralRe: Why do my applications need >10 MB RAM Pin
Philip Fitzsimons20-Mar-03 2:43
Philip Fitzsimons20-Mar-03 2:43 
GeneralRe: Why do my applications need >10 MB RAM Pin
Big Art21-Mar-03 13:52
Big Art21-Mar-03 13:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.