Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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

 

Topics:

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

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}