refact: win, virtual display (#7767)

* refact: win, virtual display

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* Update flutter-build.yml

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
Co-authored-by: RustDesk <71636191+rustdesk@users.noreply.github.com>
This commit is contained in:
fufesou
2024-04-19 11:31:52 +08:00
committed by GitHub
parent a3c0911529
commit e83c28bf54
61 changed files with 1113 additions and 290 deletions

View File

@@ -669,4 +669,48 @@ extern "C"
AllocConsole();
freopen("CONOUT$", "w", stdout);
}
bool is_service_running_w(LPCWSTR serviceName)
{
SC_HANDLE hSCManager = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT);
if (hSCManager == NULL) {
return false;
}
SC_HANDLE hService = OpenServiceW(hSCManager, serviceName, SERVICE_QUERY_STATUS);
if (hService == NULL) {
CloseServiceHandle(hSCManager);
return false;
}
SERVICE_STATUS_PROCESS serviceStatus;
DWORD bytesNeeded;
if (!QueryServiceStatusEx(hService, SC_STATUS_PROCESS_INFO, reinterpret_cast<LPBYTE>(&serviceStatus), sizeof(serviceStatus), &bytesNeeded)) {
CloseServiceHandle(hService);
CloseServiceHandle(hSCManager);
return false;
}
bool isRunning = (serviceStatus.dwCurrentState == SERVICE_RUNNING);
CloseServiceHandle(hService);
CloseServiceHandle(hSCManager);
return isRunning;
}
} // end of extern "C"
extern "C"
{
int get_native_machine()
{
USHORT processMachine = 0;
USHORT nativeMachine = 0;
BOOL res = IsWow64Process2(GetCurrentProcess(), &processMachine, &nativeMachine);
if (res == TRUE) {
return (int)nativeMachine;
} else {
return -1;
}
}
}