How to Log off Windows programmatically using C# ?

How to Log off from Windows programmatically using C# ?

Below is a simple program that lets you to Log off Windows programmatically using C# .

The P/Invoke’s ExitWindowsEx method is used to Log off from Windows using C# .

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);
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

No Responses

Leave a Reply


Interesting BlogPosts to read

How to get an Enumerator from range of elements from ArrayList in C# ?
The code snippet shown in this blog post demonstrates how you can get the enumeraor from a range of ...
How to check for the column name in an SqlDataReader Object in C# ?
When working in ADO.NET for data access , there are times when you want to check to see if a column ...
Download - Pokemon Go for for Windows 10 (Third Party app)
Pokemon Go is one of the popular AR games for android and iOS devices and now , the game is made ava...