Created
May 27, 2023 23:50
-
-
Save puppis42/9d7d652f14180c0cb1e6ba1d8be2bc5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
namespace DetectShutdown | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private static int WM_QUERYENDSESSION = 0x11; | |
protected override void WndProc(ref System.Windows.Forms.Message m) | |
{ | |
if (m.Msg == WM_QUERYENDSESSION) | |
{ | |
File.WriteAllText(@"C:\Users\uname\Desktop\success.txt", "SUCESS"); | |
Environment.Exit(0); | |
} | |
else | |
{ | |
label1.Text = "Nothing happends for now."; | |
} | |
base.WndProc(ref m); | |
} | |
private void Form1_Load(object sender, EventArgs e) | |
{ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment