Click here to Skip to main content
15,911,715 members
Home / Discussions / C#
   

C#

 
GeneralSerialization Pin
Large Data File14-Apr-04 23:46
Large Data File14-Apr-04 23:46 
GeneralRe: Serialization Pin
Heath Stewart15-Apr-04 5:11
protectorHeath Stewart15-Apr-04 5:11 
GeneralRe: Serialization Pin
Large Data File15-Apr-04 5:47
Large Data File15-Apr-04 5:47 
GeneralRe: Serialization Pin
Heath Stewart15-Apr-04 5:50
protectorHeath Stewart15-Apr-04 5:50 
GeneralRe: Serialization Pin
Large Data File15-Apr-04 6:20
Large Data File15-Apr-04 6:20 
GeneralRe: Serialization Pin
Heath Stewart15-Apr-04 6:28
protectorHeath Stewart15-Apr-04 6:28 
GeneralAbout ShutDown in XP Pin
lajiyo14-Apr-04 23:02
lajiyo14-Apr-04 23:02 
GeneralRe: About ShutDown in XP Pin
Heath Stewart15-Apr-04 4:59
protectorHeath Stewart15-Apr-04 4:59 
ExitWindows can only log-off the current user if declared correctly. You must P/Invoke ExitWindowsEx in order to specify any shutdown parameters, like the following sample shows:
using System;
using System.Runtime.InteropServices;

public class Test2
{
  static void Main()
  {
    ExitWindowsEx(ConvertFlags(ShutdownFlags.Logoff), 0);
  }

  [DllImport("user32.dll")]
  private static extern bool ExitWindowsEx(
    [MarshalAs(UnmanagedType.SysUInt)] IntPtr flags,
    [MarshalAs(UnmanagedType.U4)] int reason);

  private static IntPtr ConvertFlags(ShutdownFlags flags)
  {
    return new IntPtr((int)flags);
  }

  [Flags]
  private enum ShutdownFlags
  {
    Logoff = 0,
    Shutdown = 1,
    Reboot = 2,
    Force = 4,
    Poweroff = 8,
    ForceIfHung = 16
  }
}
You'll notice that the first parameter is declared as an IntPtr. This is because UINT is an unsigned int, which is architecture-dependent. On 32-bit operating systems, this is a 32-bit unsigned int. On 64-bit operating systems, this is a 64-bit unsigned integer. It's marshaled as an UnmanagedType.SysUInt for portability.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: About ShutDown in XP Pin
lajiyo18-Apr-04 15:19
lajiyo18-Apr-04 15:19 
GeneralRe: About ShutDown in XP Pin
Heath Stewart19-Apr-04 2:17
protectorHeath Stewart19-Apr-04 2:17 
GeneralRe: About ShutDown in XP Pin
lajiyo20-Apr-04 0:37
lajiyo20-Apr-04 0:37 
GeneralRe: About ShutDown in XP Pin
Heath Stewart20-Apr-04 3:55
protectorHeath Stewart20-Apr-04 3:55 
GeneralRe: About ShutDown in XP Pin
lajiyo21-Apr-04 5:14
lajiyo21-Apr-04 5:14 
GeneralRe: About ShutDown in XP Pin
Heath Stewart21-Apr-04 6:46
protectorHeath Stewart21-Apr-04 6:46 
GeneralAccessing C++ classes from within C# .NET Pin
Vini Deep14-Apr-04 22:53
Vini Deep14-Apr-04 22:53 
GeneralRe: Accessing C++ classes from within C# .NET Pin
lajiyo14-Apr-04 23:10
lajiyo14-Apr-04 23:10 
GeneralRe: Accessing C++ classes from within C# .NET Pin
Vini Deep14-Apr-04 23:24
Vini Deep14-Apr-04 23:24 
GeneralRe: Accessing C++ classes from within C# .NET Pin
Andy Wieberneit15-Apr-04 3:27
Andy Wieberneit15-Apr-04 3:27 
Generaldatagrid hide rowheader Pin
robmays14-Apr-04 22:43
robmays14-Apr-04 22:43 
GeneralRe: datagrid hide rowheader Pin
Heath Stewart15-Apr-04 4:20
protectorHeath Stewart15-Apr-04 4:20 
GeneralRe: datagrid hide rowheader Pin
robmays15-Apr-04 4:59
robmays15-Apr-04 4:59 
GeneralRe: datagrid hide rowheader Pin
Heath Stewart15-Apr-04 5:04
protectorHeath Stewart15-Apr-04 5:04 
GeneralRe: datagrid hide rowheader Pin
robmays15-Apr-04 7:37
robmays15-Apr-04 7:37 
QuestionHow to set the string for cell(rowNumber, colNumber) Pin
DucLinh14-Apr-04 21:50
DucLinh14-Apr-04 21:50 
AnswerRe: How to set the string for cell(rowNumber, colNumber) Pin
Heath Stewart15-Apr-04 4:17
protectorHeath Stewart15-Apr-04 4:17 

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.