using SystemRuntimeInteropServices;[Flags]public enum ExitWindows : uint{LogOff = x //注销 ShutDown = x //关机 Reboot = x //重启 Force = xPowerOff = xForceIfHung = x}[Flags]public enum ShutdownReason : uint{MajorApplication = xMajorHardware = xMajorLegacyApi = xMajorOperatingSystem = xMajorOther = xMajorPower = xMajorSoftware = xMajorSystem = xMinorBlueScreen = xFMinorCordUnplugged = xbMinorDisk = xMinorEnvironment = xcMinorHardwareDriver = xdMinorHotfix = xMinorHung = xMinorInstallation = xMinorMaintenance = xMinorMMC = xMinorNetworkConnectivity = xMinorNetworkCard = xMinorOther = xMinorOtherDriver = xeMinorPowerSupply = xaMinorProcessor = xMinorReconfig = xMinorSecurity = xMinorSecurityFix = xMinorSecurityFixUninstall = xMinorServicePack = xMinorServicePackUninstall = xMinorTermSrv = xMinorUnstable = xMinorUpgrade = xMinorWMI = xFlagUserDefined = xFlagPlanned = x}[DllImport(userdll)]static extern bool ExitWindowsEx(ExitWindows uFlags ShutdownReason dwReason);[STAThread]static void Main(string[] args){ExitWindowsEx(ExitWindowsLogOff ShutdownReasonMajorOther & ShutdownReasonMinorOther);//这个语句将实现计算机注销操作 }