Over a million developers have joined DZone.

How to Log Off Windows Programmatically Using C#

DZone's Guide to

How to Log Off Windows Programmatically Using C#

Free Resource

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);



Published at DZone with permission of Senthil Kumar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}