mirror of
https://github.com/moonlight-stream/Internet-Hosting-Tool.git
synced 2026-06-20 07:31:22 +00:00
Don't allow testing while a stream is active
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#include <wtsapi32.h>
|
#include <wtsapi32.h>
|
||||||
#include <powerbase.h>
|
#include <powerbase.h>
|
||||||
#include <VersionHelpers.h>
|
#include <VersionHelpers.h>
|
||||||
|
#include <tlhelp32.h>
|
||||||
|
|
||||||
#pragma comment(lib, "miniupnpc.lib")
|
#pragma comment(lib, "miniupnpc.lib")
|
||||||
#pragma comment(lib, "libnatpmp.lib")
|
#pragma comment(lib, "libnatpmp.lib")
|
||||||
@@ -268,6 +269,28 @@ bool IsGameStreamEnabled()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsCurrentlyStreaming()
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
HANDLE processSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||||
|
|
||||||
|
PROCESSENTRY32 procEntry;
|
||||||
|
procEntry.dwSize = sizeof(procEntry);
|
||||||
|
Process32First(processSnapshot, &procEntry);
|
||||||
|
|
||||||
|
do {
|
||||||
|
// If we find nvstreamer.exe running, we're currently streaming
|
||||||
|
if (_stricmp(procEntry.szExeFile, "nvstreamer.exe") == 0) {
|
||||||
|
ret = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (Process32Next(processSnapshot, &procEntry));
|
||||||
|
|
||||||
|
CloseHandle(processSnapshot);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsConsoleSessionActive()
|
bool IsConsoleSessionActive()
|
||||||
{
|
{
|
||||||
PWTS_SESSION_INFO_1 sessionInfo;
|
PWTS_SESSION_INFO_1 sessionInfo;
|
||||||
@@ -1203,6 +1226,12 @@ int main(int argc, char* argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsCurrentlyStreaming()) {
|
||||||
|
DisplayMessage("The test cannot proceed because a GameStream session is currently running on this PC.\n\n"
|
||||||
|
"Quit the currently running app on this host within Moonlight, or reboot your PC.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsConsoleSessionActive()) {
|
if (!IsConsoleSessionActive()) {
|
||||||
DisplayMessage("The system display is currently locked. You must sign in to your PC again to use GameStream.\n\n"
|
DisplayMessage("The system display is currently locked. You must sign in to your PC again to use GameStream.\n\n"
|
||||||
"This is most often due to Microsoft Remote Desktop locking the screen. Use an alternate GameStream-compatible remote desktop solution like Chrome Remote Desktop or TeamViewer to unlock the PC and prevent this error in the future.",
|
"This is most often due to Microsoft Remote Desktop locking the screen. Use an alternate GameStream-compatible remote desktop solution like Chrome Remote Desktop or TeamViewer to unlock the PC and prevent this error in the future.",
|
||||||
|
|||||||
Reference in New Issue
Block a user