Created
May 26, 2023 17:41
-
-
Save puppis42/d8951d56bfd240f0410bd5128d6c799d 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.Linq; | |
using System.Runtime.InteropServices; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
namespace SleepMode | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
[DllImport("Powrprof.dll", CharSet = CharSet.Auto, ExactSpelling = true)] | |
public static extern bool SetSuspendState(bool hiberate, bool forceCritical, bool disableWakeEvent); | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
SetSuspendState(true, true, true); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment