How to Log Off Windows Programmatically Using C#
A simple program that lets you log off Windows programmatically using C#, with the P/Invoke’s ExitWindowsEx method.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static extern bool ExitWindowsEx(uint uFlags, uint dwReason);
static void Main(string[] args)
{
ExitWindowsEx(0, 0);
}
}
}
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)
Tags:




