How to Log Off Windows Programmatically Using C#
Join the DZone community and get the full member experience.
Join For FreeA 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);
}
}
}
csharp
Published at DZone with permission of Senthil Kumar. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments