How can I do this in a C# program? I'm pretty sure it should be possible, since various media programs for example do this so the computer doesn't go into stand-by while watching a movie, etc.
So, if I for example create a plain and basic WinForm application, what do I need to do to prevent a laptop from going into Stand-By as long as this application is running?
I think you'll have to P/Invoke. But don't be scared... it's pretty easy.
SetThreadExecutionState is your friend. It's available in the PInvoke project, also available on NuGet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With