mirror of
https://github.com/moonlight-stream/Internet-Hosting-Tool.git
synced 2025-07-01 23:35:27 +00:00
Check sleep and hibernation settings
This commit is contained in:
parent
9d3ef0a215
commit
87fd3ad8e2
@ -7,6 +7,7 @@
|
|||||||
#include <objbase.h>
|
#include <objbase.h>
|
||||||
#include <WinInet.h>
|
#include <WinInet.h>
|
||||||
#include <wtsapi32.h>
|
#include <wtsapi32.h>
|
||||||
|
#include <powerbase.h>
|
||||||
|
|
||||||
#pragma comment(lib, "miniupnpc.lib")
|
#pragma comment(lib, "miniupnpc.lib")
|
||||||
#pragma comment(lib, "libnatpmp.lib")
|
#pragma comment(lib, "libnatpmp.lib")
|
||||||
@ -14,6 +15,7 @@
|
|||||||
#pragma comment(lib, "iphlpapi.lib")
|
#pragma comment(lib, "iphlpapi.lib")
|
||||||
#pragma comment(lib, "wininet.lib")
|
#pragma comment(lib, "wininet.lib")
|
||||||
#pragma comment(lib, "wtsapi32.lib")
|
#pragma comment(lib, "wtsapi32.lib")
|
||||||
|
#pragma comment(lib, "powrprof.lib")
|
||||||
|
|
||||||
#define MINIUPNP_STATICLIB
|
#define MINIUPNP_STATICLIB
|
||||||
#include <miniupnpc/miniupnpc.h>
|
#include <miniupnpc/miniupnpc.h>
|
||||||
@ -298,6 +300,28 @@ bool IsConsoleSessionActive()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsSleepEnabled()
|
||||||
|
{
|
||||||
|
SYSTEM_POWER_POLICY powerPolicy;
|
||||||
|
|
||||||
|
if (CallNtPowerInformation(SystemPowerPolicyAc, NULL, 0, &powerPolicy, sizeof(powerPolicy)) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return powerPolicy.IdleTimeout != 0 && powerPolicy.Idle.Action == PowerActionSleep;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsHibernationEnabled()
|
||||||
|
{
|
||||||
|
SYSTEM_POWER_POLICY powerPolicy;
|
||||||
|
|
||||||
|
if (CallNtPowerInformation(SystemPowerPolicyAc, NULL, 0, &powerPolicy, sizeof(powerPolicy)) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return powerPolicy.DozeS4Timeout != 0 || (powerPolicy.IdleTimeout != 0 && powerPolicy.Idle.Action == PowerActionHibernate);
|
||||||
|
}
|
||||||
|
|
||||||
bool IsZeroTierInstalled()
|
bool IsZeroTierInstalled()
|
||||||
{
|
{
|
||||||
DWORD error;
|
DWORD error;
|
||||||
@ -1030,6 +1054,20 @@ int main(int argc, char* argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf(CONSOLE_OUT, "Checking power settings...\n");
|
||||||
|
|
||||||
|
if (IsSleepEnabled()) {
|
||||||
|
DisplayMessage("This computer has sleep mode enabled. Sleep mode may prevent this PC from being available for streaming.\n\n"
|
||||||
|
"Please ensure sleep is disabled in Power Options so this PC is always ready for streaming.",
|
||||||
|
"https://github.com/moonlight-stream/moonlight-docs/wiki/Troubleshooting", MpWarn, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsHibernationEnabled()) {
|
||||||
|
DisplayMessage("This computer has hibernation enabled. Hibernation may prevent this PC from being available for streaming.\n\n"
|
||||||
|
"Please ensure hibernation is disabled in Power Options so this PC is always ready for streaming.",
|
||||||
|
"https://github.com/moonlight-stream/moonlight-docs/wiki/Troubleshooting", MpWarn, false);
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(CONSOLE_OUT, "Checking for anti-virus and firewall software...\n");
|
fprintf(CONSOLE_OUT, "Checking for anti-virus and firewall software...\n");
|
||||||
|
|
||||||
char wmicBuf[8192];
|
char wmicBuf[8192];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user