Showing posts with label 【Visual Studio Visual Csharp】OS function logoff. Show all posts
Showing posts with label 【Visual Studio Visual Csharp】OS function logoff. Show all posts

Monday, May 31, 2021

【Visual Studio Visual Csharp】OS function logoff,restart,shutdoen the system

 using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Runtime.InteropServices; // make sure that using System.Runtime.InteropServices; is included using System.Diagnostics; // make sure that using System.Diagnostics; is included namespace osfunctionC { public partial class Form1 : Form { public Form1() { InitializeComponent(); } [DllImport("user32.dll")] public static extern int ExitWindowsEx(int operationFlag, int operationReason); private void button1_Click(object sender, EventArgs e) { // Log off the System ExitWindowsEx(0, 0); } private void button2_Click(object sender, EventArgs e) { // Restart the System ExitWindowsEx(2, 0); } private void button3_Click(object sender, EventArgs e) { // Shut Down the System ExitWindowsEx(1, 0); } } }

How to Launch a D2C Startup?

Discover why successful D2C startups validate identity before building products and how paid pilots can prove demand before an MVP exists...