抛弃GdCpp*.dll/pdb历史重新建库。libhv和Sqlite的dll保留

This commit is contained in:
Zhang Jianjun
2026-02-02 16:09:02 +08:00
parent f148ca49e3
commit 4a2a284ac0
292 changed files with 350450 additions and 0 deletions

52
include/ProcessHelper.h Normal file
View File

@@ -0,0 +1,52 @@
#pragma once
GDCPP_API struct sProcessInfo {
std::wstring name;
DWORD pid;
sProcessInfo(const std::wstring& n=L"", DWORD p = 0)
: name(n), pid(p) {
}
// 复制构造函数
sProcessInfo(const sProcessInfo& other)
: name(other.name), pid(other.pid) {
}
// 赋值运算符
sProcessInfo& operator=(const sProcessInfo& other) {
if (this != &other) {
name = other.name;
pid = other.pid;
}
return *this;
}
};
// 查找正在运行的目标进程,返回数量,并将找到的进程写入 outFoundProcs。
// 输入outFoundProcs如果为空则查找结果以追加方式写入
// 如果outFoundProcs大小与targetProcs相同则将找到的进程写入对应位置。
// 示例
//std::vector<std::wstring> MonitorAppName = { L"GdCamExpert", L"GoodVision" };
//std::vector<sProcessInfo> MonitorAppStatus;
//MonitorAppStatus.resize(MonitorAppName.size());
//int runningCount = FindRunningProcesses_BeginWith(MonitorAppName, MonitorAppStatus);
// 两个版本:
// 1. FindRunningProcesses_BeginWith查找进程名以目标字符串开头的进程
// 2. FindRunningProcesses_Exact查找进程名完全匹配目标字符串的进程
// 都不区分大小写。
GDCPP_API int FindRunningProcesses_BeginWith(const std::vector<std::wstring>& targetProcs, std::vector<sProcessInfo>& outFoundProcs);
GDCPP_API int FindRunningProcesses_Exact(const std::vector<std::wstring>& targetProcs, std::vector<sProcessInfo>& outFoundProcs);
// 请求关机或重启EWX_SHUTDOWN、EWX_REBOOT
// cmd: EWX_SHUTDOWN, EWX_REBOOT, EWX_POWEROFF 等
// reason: SHTDN_REASON_MAJOR_OPERATINGSYSTEM, SHTDN_REASON_MINOR_OTHER 等
GDCPP_API void DoShutdown(uint32_t cmd = EWX_SHUTDOWN, DWORD reason = SHTDN_REASON_MAJOR_OPERATINGSYSTEM);
GDCPP_API BOOL IsProcessRunning(LPCTSTR pszProcName, LPTSTR pFoundName, DWORD dwFoundLen);
GDCPP_API bool StartProcessAndGetPid(const fs::path& exePath, DWORD* outPid);
GDCPP_API bool StartProcessIndependently(const fs::path& exePath);
GDCPP_API bool NotifyProcessToExit(DWORD pid, DWORD timeoutMs = 1000);