.net - Log off user from Win XP programmatically in C# -


How do I start a Windows XP user from a C # app? The action of my app should generate similar results by clicking "Logoff" in the XP Start menu - it's OK if the system asks for a confirmation.

Is there a net or an unmanaged API for this?

You can exit / exitWindowsEx:

By dragging it together:

  Use the system. Runtime.InteropServices; Class 1 ({DllImport ("user32.dll")) Stable External Bull ExitWindowsEx (UIT UFFags, UIT dwReason); [STAThread] Static Zero Main (string [] ARG) {ExitWindowsEx (ExitWindows.Logoff, shutdown region.majorassary | shutdown region.mainer other); }} [Flags] Public Reward ExitWindows: uint one of the following five: LogOff = 0x00, shutdown = 0x01, reboot = 0x02, poweroff = 0x08, restart APPS = 0x40, // plus one of the following two Major = 0x04, Forsifhang = 0x10,} [Flags] NM shutdownsion: UIT {Major Application = 0x00040000, MajorHardware = 0x00010000, Major Legacy API = 0x00070000, Major Operating System = 0x00020000, MajorOper = 0x00000000, MajorPower = 0x00060000, Major Software = 0x00030000, MajorSystem = 0x00050000, MinorBuscreen = 0x0000000F, M Inorkrduँpluggd = 0x0000000b, Minordisk = 0x00000007, Minorenvironment = 0x0000000c, Minorhrdwaredriver = 0x0000000d, Minorhotfiks = 0x00000011, Minorhung = 0x00000005, Minorinstoltion = 0x00000002, Minormantenans = 0x00000001, Minormns = 0x00000019, Minornetvrksonnektivity = 0x00000014, Minornetvrkkard = 0x00000009, Minorother = 0x00000000, Minorotherdriver = 0x0000000e, Minorpoversuppli = 0x0000000a, Minorprosessor = 0x00000008, Minorrekfig = 0x00000004, Minorsekyurity = 0x00000013, Minorsekyuritifaiks = 0x00000012, Minorsekyuritifaiksuninstll = 0x00000018, Minorsrvisepak = 0x00000010, Minorsrvisepakuninstll = 0x00000016, Minorternsrw = 0x00000020, Minorunstble = 0x00000006, Minorupgrede = 0x00000003, Minorwmi = 0x00000015, FlagUserDefined = 0x40000000, FlagPlanned = 0x80000000}  

Comments