Click here to Skip to main content
15,908,834 members
Home / Discussions / C#
   

C#

 
GeneralRe: Closing File Stream ... close calls dispose Pin
S. Senthil Kumar16-Mar-05 18:11
S. Senthil Kumar16-Mar-05 18:11 
GeneralVS 's Installer Pin
zecodela15-Mar-05 15:21
zecodela15-Mar-05 15:21 
GeneralRe: VS 's Installer Pin
Dave Kreskowiak16-Mar-05 14:37
mveDave Kreskowiak16-Mar-05 14:37 
GeneralGDI GradientFill Pin
Mathew Hall15-Mar-05 14:33
Mathew Hall15-Mar-05 14:33 
GeneralRe: GDI GradientFill Pin
Christian Graus15-Mar-05 14:52
protectorChristian Graus15-Mar-05 14:52 
GeneralRe: GDI GradientFill Pin
Mathew Hall15-Mar-05 17:10
Mathew Hall15-Mar-05 17:10 
Generali want to know something Pin
snouto15-Mar-05 12:32
snouto15-Mar-05 12:32 
GeneralRe: i want to know something Pin
Christian Graus15-Mar-05 12:57
protectorChristian Graus15-Mar-05 12:57 
To do stuff like that, you need to interop the C dlls. www.pinvoke.net is the best place online to get info on that stuff. Google the C API calls first, then go there to see how to interop them.

	public class Shutdown<br />
	{<br />
		[StructLayout(LayoutKind.Sequential, Pack=1)]<br />
			internal struct TokPriv1Luid<br />
		{<br />
			public int Count;<br />
			public long Luid;<br />
			public int Attr;<br />
		}<br />
<br />
		[DllImport("kernel32.dll", ExactSpelling=true) ]<br />
		internal static extern IntPtr GetCurrentProcess();<br />
<br />
		[DllImport("advapi32.dll", ExactSpelling=true, SetLastError=true) ]<br />
		internal static extern bool OpenProcessToken( IntPtr h, int acc, ref IntPtr phtok );<br />
<br />
		[DllImport("advapi32.dll", SetLastError=true) ]<br />
		internal static extern bool LookupPrivilegeValue( string host, string name, ref long pluid );<br />
<br />
		[DllImport("advapi32.dll", ExactSpelling=true, SetLastError=true) ]<br />
		internal static extern bool AdjustTokenPrivileges( IntPtr htok, bool disall,<br />
			ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen );<br />
<br />
		[DllImport("user32.dll", ExactSpelling=true, SetLastError=true) ]<br />
		internal static extern bool ExitWindowsEx( int flg, int rea );<br />
<br />
		internal const int SE_PRIVILEGE_ENABLED = 0x00000002;<br />
		internal const int TOKEN_QUERY = 0x00000008;<br />
		internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;<br />
		internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";<br />
		internal const int EWX_LOGOFF = 0x00000000;<br />
		internal const int EWX_SHUTDOWN = 0x00000001;<br />
		internal const int EWX_REBOOT = 0x00000002;<br />
		internal const int EWX_FORCE = 0x00000004;<br />
		internal const int EWX_POWEROFF = 0x00000008;<br />
		internal const int EWX_FORCEIFHUNG = 0x00000010;<br />
<br />
		private static void DoExitWin( int flg )<br />
		{<br />
			bool ok;<br />
			TokPriv1Luid tp;<br />
			IntPtr hproc = GetCurrentProcess();<br />
			IntPtr htok = IntPtr.Zero;<br />
			ok = OpenProcessToken( hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok );<br />
			tp.Count = 1;<br />
			tp.Luid = 0;<br />
			tp.Attr = SE_PRIVILEGE_ENABLED;<br />
			ok = LookupPrivilegeValue( null, SE_SHUTDOWN_NAME, ref tp.Luid );<br />
			ok = AdjustTokenPrivileges( htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero );<br />
			ok = ExitWindowsEx( flg, 0 );<br />
		}<br />
<br />
		public static void ShutDown()<br />
		{<br />
			DoExitWin( EWX_POWEROFF | EWX_FORCE );<br />
		}<br />
	}


That's a class that shuts down windows, I reckon that changing the flags you pass in should log off instead.

Christian

I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
GeneralUsing the update command of the datagrid to alter the data in a dataset Pin
Anonymous15-Mar-05 12:18
Anonymous15-Mar-05 12:18 
GeneralReceiving SMS problem Pin
ccui15-Mar-05 10:18
ccui15-Mar-05 10:18 
GeneralDataGrid TableStyles Pin
dennista15-Mar-05 9:03
dennista15-Mar-05 9:03 
GeneralRe: DataGrid TableStyles Pin
Kodanda Pani15-Mar-05 18:06
Kodanda Pani15-Mar-05 18:06 
GeneralRe: DataGrid TableStyles Pin
dennista16-Mar-05 3:31
dennista16-Mar-05 3:31 
GeneralFile IO in Webservice gives Error Pin
James Poulose15-Mar-05 8:21
James Poulose15-Mar-05 8:21 
GeneralRe: File IO in Webservice gives Error Pin
TylerBrinks15-Mar-05 9:46
TylerBrinks15-Mar-05 9:46 
QuestionHow to create a shallow copy of List&lt;T&gt; ? Pin
Andres Coder15-Mar-05 7:50
Andres Coder15-Mar-05 7:50 
AnswerRe: How to create a shallow copy of List&lt;T&gt; ? Pin
leppie15-Mar-05 8:51
leppie15-Mar-05 8:51 
GeneralSending a web form as parameter Pin
see0715-Mar-05 7:45
see0715-Mar-05 7:45 
GeneralRe: Sending a web form as parameter Pin
Pushkar Pathak15-Mar-05 18:16
Pushkar Pathak15-Mar-05 18:16 
GeneralRe: Sending a web form as parameter Pin
see0716-Mar-05 11:59
see0716-Mar-05 11:59 
GeneralRe: Sending a web form as parameter Pin
see0722-Mar-05 7:00
see0722-Mar-05 7:00 
GeneralRe: Sending a web form as parameter Pin
see0722-Mar-05 12:20
see0722-Mar-05 12:20 
GeneralSystem.Timers problem Pin
sjhart15-Mar-05 7:17
sjhart15-Mar-05 7:17 
GeneralRe: System.Timers problem Pin
TylerBrinks15-Mar-05 8:20
TylerBrinks15-Mar-05 8:20 
GeneralPassing Safearray parameter to WebBrowser COM component Pin
simcho9915-Mar-05 3:45
simcho9915-Mar-05 3:45 

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.