|
@@ -42,7 +42,9 @@
|
|
|
#include <wlanapi.h>
|
|
|
#include <Netlistmgr.h> //网络检测添加
|
|
|
#include <psapi.h>
|
|
|
-#include <tlhelp32.h>
|
|
|
+#include <tlhelp32.h>
|
|
|
+#include <WtsApi32.h>
|
|
|
+#pragma comment(lib, "WtsApi32.lib")
|
|
|
#include "Mmdeviceapi.h"
|
|
|
#include "Propidl.h"
|
|
|
#include "Functiondiscoverykeys_devpkey.h"
|
|
@@ -109,63 +111,7 @@ const char* STRATUP_FILENAME_FROM_SCRIPTS = "spexplorerauto.lnk";
|
|
|
|
|
|
|
|
|
#if defined(RVC_OS_WIN)
|
|
|
-void GetCurUserName(CSimpleStringA& strUserName)
|
|
|
-{
|
|
|
- strUserName.Clear();
|
|
|
- const DWORD INFO_BUFFER_SIZE = 128;
|
|
|
- char infoBuf[INFO_BUFFER_SIZE];
|
|
|
- ZeroMemory(infoBuf, INFO_BUFFER_SIZE);
|
|
|
- DWORD bufCharCount = INFO_BUFFER_SIZE;
|
|
|
- if (!GetUserName(infoBuf, &bufCharCount)) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetUserName failed, GLE=%u", GetLastError());
|
|
|
- }
|
|
|
- else {
|
|
|
- strUserName = infoBuf;
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("User name:%s", strUserName.GetData());
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-static void GetUserDesktopDirectory(CSimpleStringA& outDir)
|
|
|
-{
|
|
|
- LPITEMIDLIST lp;
|
|
|
- HRESULT hr = SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, &lp);
|
|
|
- if (hr == S_OK) {
|
|
|
- CHAR lstr[128] = "";
|
|
|
- SHGetPathFromIDListA(lp, lstr);
|
|
|
- outDir = lstr;
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("GetUserDesktopDirectory1:%s", outDir.GetData());
|
|
|
- }
|
|
|
- else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("SHGetSpecialFolderLocation failed:%d", hr);
|
|
|
- outDir.Clear();
|
|
|
- }
|
|
|
-
|
|
|
- CSimpleStringA strUserName(true);
|
|
|
- GetCurUserName(strUserName);
|
|
|
- if (!strUserName.IsNullOrEmpty()) {
|
|
|
- CSimpleStringA desktopFullPath = CSimpleStringA::Format("C:\\Users\\%s\\Desktop", strUserName.GetData());
|
|
|
- if (desktopFullPath.Compare(outDir, true) != 0) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetUserDesktopDirectoryDiff:%s,%s", outDir.GetData(), desktopFullPath.GetData());
|
|
|
- outDir = desktopFullPath;
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("GetUserDesktopDirectory2:%s", outDir.GetData());
|
|
|
- }
|
|
|
- }
|
|
|
- return;
|
|
|
-}
|
|
|
-
|
|
|
-bool IsDesktopIconExist(CSimpleStringA& strPath)
|
|
|
-{
|
|
|
- CSimpleStringA s(true);
|
|
|
- GetUserDesktopDirectory(s);
|
|
|
- if (!s.IsNullOrEmpty()) {
|
|
|
- s += "\\可视柜台.lnk";
|
|
|
- strPath = s.GetData();
|
|
|
- return !!ExistsFileA(s);
|
|
|
- }
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
-void GetAutoStartFile(std::string& userDirPath, std::vector<std::string>& userDirFiles, std::string& pubDirPath, std::vector<std::string>& pubDirFiles)
|
|
|
+void ResourceWatcherFSM::GetAutoStartFile(std::string& userDirPath, std::vector<std::string>& userDirFiles, std::string& pubDirPath, std::vector<std::string>& pubDirFiles)
|
|
|
{
|
|
|
CSimpleStringA startMenuPublicPath(STARTUP_DIR_FULL_PATH);
|
|
|
auto arr = fileutil_get_sub_files(startMenuPublicPath);
|
|
@@ -181,10 +127,9 @@ void GetAutoStartFile(std::string& userDirPath, std::vector<std::string>& userDi
|
|
|
}
|
|
|
toolkit_array_free2(arr);
|
|
|
}
|
|
|
- CSimpleStringA strUserName(true);
|
|
|
- GetCurUserName(strUserName);
|
|
|
- if (!strUserName.IsNullOrEmpty()) {
|
|
|
- CSimpleStringA startMenuFullPath = CSimpleStringA::Format("C:\\Users\\%s\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup", strUserName.GetData());
|
|
|
+ CSimpleStringA startMenuFullPath(true);
|
|
|
+ GetUserStartupDirectory(startMenuFullPath);
|
|
|
+ if (!startMenuFullPath.IsNullOrEmpty()) {
|
|
|
arr = fileutil_get_sub_files(startMenuFullPath);
|
|
|
userDirPath = startMenuFullPath.GetData();
|
|
|
if (arr != NULL) {
|
|
@@ -231,12 +176,11 @@ ResourceWatcherFSM::ResourceWatcherFSM(void)
|
|
|
:m_strTerminalNo(true),
|
|
|
m_bFirstRunAfterBoot(FALSE),
|
|
|
m_cpuTop(0), flag4DeleteKeyAutoStartFile(false), flag4DoAutoStartTaskIgnoreBoot(FALSE), m_skipDesktopDetect(FALSE)
|
|
|
+ , m_strCurrentUserName(true), m_strLoginedUserName(true)
|
|
|
{
|
|
|
#ifdef RVC_OS_WIN
|
|
|
- m_forceStartupWithExeFlag = 0;
|
|
|
m_iNonSignedTotal = 0;
|
|
|
m_bNeedForceDiskCheck = false;
|
|
|
- m_DoneDetectAutostart = true;
|
|
|
#endif // RVC_OS_WIN
|
|
|
}
|
|
|
|
|
@@ -458,8 +402,9 @@ ErrorCodeEnum ResourceWatcherFSM::OnInit()
|
|
|
if (m_bFirstRunAfterBoot) {
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("First time to run after system boot.");
|
|
|
}
|
|
|
- if (m_bFirstRunAfterBoot) {
|
|
|
+
|
|
|
#if defined(RVC_OS_WIN)
|
|
|
+ if (m_bFirstRunAfterBoot) {
|
|
|
//GetSystemMetrics (SM_CMONITORS) 计数仅显示可见的显示器
|
|
|
const int screenNums = GetSystemMetrics(SM_CMONITORS);
|
|
|
const int aimScreenNums4Stand2S = 2;
|
|
@@ -474,8 +419,10 @@ ErrorCodeEnum ResourceWatcherFSM::OnInit()
|
|
|
, CSimpleStringA::Format("{\"subject\":\"screen_count\",\"machine_type\":\"%s\",\"expect\":%d,\"actual\":%d}"
|
|
|
, m_RvcSysinfo.strMachineType.GetData(), aimScreenNums4Other, screenNums));
|
|
|
}
|
|
|
-#endif //RVC_OS_WIN
|
|
|
}
|
|
|
+
|
|
|
+#endif //RVC_OS_WIN
|
|
|
+
|
|
|
spCtSettingConfig->ReadConfigValueInt(m_pEntity->GetEntityName(), "DisplayCnt", m_iNonSignedDisplay);
|
|
|
if (m_iNonSignedDisplay <= 0)
|
|
|
m_iNonSignedDisplay = 10;
|
|
@@ -490,7 +437,6 @@ ErrorCodeEnum ResourceWatcherFSM::OnInit()
|
|
|
m_skipDesktopDetect = TRUE;
|
|
|
}
|
|
|
spRunConfig->ReadConfigValueInt("WarnRecord", "disk", m_diskLastWarnHour);
|
|
|
-
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
|
|
@@ -505,7 +451,7 @@ ErrorCodeEnum ResourceWatcherFSM::OnExit()
|
|
|
void ResourceWatcherFSM::AfterInit()
|
|
|
{
|
|
|
#if defined(RVC_OS_WIN)
|
|
|
-
|
|
|
+ InitUserInfo();
|
|
|
if (m_bFirstRunAfterBoot) {
|
|
|
InitCustomAutoStartFileSheet();
|
|
|
AggerateAutoStatTask* task = new AggerateAutoStatTask(this);
|
|
@@ -1629,50 +1575,23 @@ ErrorCodeEnum ResourceWatcherFSM::CreateLink(int nType, const CSimpleStringA& ex
|
|
|
CHAR lstr[MAX_PATH] = "";
|
|
|
if (nType == 0) {
|
|
|
CSimpleStringA s(true);
|
|
|
- GetUserDesktopDirectory(s);
|
|
|
- if (!s.IsNullOrEmpty()) {
|
|
|
- s += "\\可视柜台.lnk";
|
|
|
+ const bool exist = IsDesktopIconExist(s);
|
|
|
+ if (!s.IsNullOrEmpty()) {
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to create %s", s.GetData());
|
|
|
if (Error_Succeed != (result = CreateLinkFile(exePath, "", s, icoPath))) {
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Create link file for DESKTOP fail");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if (nType == 1) {
|
|
|
- /** 这个函数会被拦截吗? [Gifur@20241028]*/
|
|
|
- HRESULT hr = SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &lp);
|
|
|
- if (SUCCEEDED(hr)) {
|
|
|
- memset(lstr, 0, strlen(lstr));
|
|
|
- SHGetPathFromIDListA(lp, lstr);
|
|
|
- CSimpleStringA s = lstr;
|
|
|
- s += "\\可视柜台.lnk";
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to create %s", s.GetData());
|
|
|
- if (Error_Succeed != (result = CreateLinkFile(exePath, "", s, icoPath)))
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Create link file for PROGRAMS fail");
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SHGetSpecialFolderLocation failed %d", hr);
|
|
|
- }
|
|
|
- }
|
|
|
else if (nType == 2) {
|
|
|
- HRESULT hr = SHGetSpecialFolderLocation(0, CSIDL_STARTUP /*CSIDL_COMMON_STARTUP*/, &lp);
|
|
|
- if (SUCCEEDED(hr)) {
|
|
|
- memset(lstr, 0, strlen(lstr));
|
|
|
- SHGetPathFromIDListA(lp, lstr);
|
|
|
- CSimpleStringA s = lstr;
|
|
|
- s += "\\";
|
|
|
- s += STRATUP_FILENAME_FROM_SCRIPTS;
|
|
|
+ CSimpleStringA s(true);
|
|
|
+ const bool exist = IsStartupIconExist(s);
|
|
|
+ if (!s.IsNullOrEmpty()) {
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to create %s", s.GetData());
|
|
|
- if (Error_Succeed != (result = CreateLinkFile(exePath, "", s, icoPath)))
|
|
|
- {
|
|
|
+ if (Error_Succeed != (result = CreateLinkFile(exePath, "", s, icoPath))) {
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Create link file for STARTUP fail");
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SHGetSpecialFolderLocation failed %d", hr);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("cannot support link create type: %d", nType);
|
|
@@ -1780,7 +1699,6 @@ bool ResourceWatcherFSM::GetRegValue(HKEY hKey, LPCTSTR lpcszParam, CSimpleStrin
|
|
|
void ResourceWatcherFSM::DetectAutoStartupCover()
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
-
|
|
|
CSimpleStringA strStartupPath(true);
|
|
|
const int nStartupType = DetectAutoStartupType(strStartupPath);
|
|
|
ErrorCodeEnum rc = Error_InvalidState;
|
|
@@ -1957,10 +1875,10 @@ int ResourceWatcherFSM::DetectAutoStartupType(CSimpleStringA& strValue)
|
|
|
memset(szValue, '\0', MAX_PATH + 1);
|
|
|
lResult = RegQueryValueExA(hKey, "Shell", NULL, &dwType, (LPBYTE)szValue, &dwSize);
|
|
|
if (lResult == ERROR_SUCCESS) {
|
|
|
- std::string strValue(szValue);
|
|
|
+ std::string sValue(szValue);
|
|
|
regeditValue = szValue;
|
|
|
- strValue = SP::Utility::ToLower(strValue);
|
|
|
- CSimpleStringA value(strValue.c_str());
|
|
|
+ sValue = SP::Utility::ToLower(sValue);
|
|
|
+ CSimpleStringA value(sValue.c_str());
|
|
|
if (value.IsStartWith("wscript", true) && value.IsEndWith(".vbs", true)) {
|
|
|
LogWarn(Severity_Low, Error_Debug, LOG_WARN_AUTO_STARTUP_FROM_REGIST, regeditValue);
|
|
|
vbsType = 1;
|
|
@@ -2102,6 +2020,7 @@ void ResourceWatcherFSM::DeleteDuplicateAutoStartFile(bool toDeleteLastLegity)
|
|
|
autolist.push_back(CMB_LINK_FILE_NAME);
|
|
|
GetAutoStartFile(userPath, userlist, pubPath, publist);
|
|
|
if (!keyPublist.empty() || !keyUserlist.empty()) {
|
|
|
+ /** 移除集中配置中配置的文件(用户目录下) [Gifur@20241031]*/
|
|
|
for (auto it = userlist.cbegin(); keyUserlist.size() > 0 && it != userlist.cend(); ++it) {
|
|
|
for (auto kt = keyUserlist.cbegin(); kt != keyUserlist.cend(); ++kt) {
|
|
|
CSimpleStringA strfilename(it->c_str());
|
|
@@ -2116,6 +2035,7 @@ void ResourceWatcherFSM::DeleteDuplicateAutoStartFile(bool toDeleteLastLegity)
|
|
|
}
|
|
|
}
|
|
|
if (toDeleteLastLegity) {
|
|
|
+ /** 移除正规的文件(用户目录下) [Gifur@20241031]*/
|
|
|
for (auto kt = autolist.cbegin(); kt != autolist.cend(); ++kt) {
|
|
|
CSimpleStringA strfilename(it->c_str());
|
|
|
if (strfilename.Compare(kt->c_str()) == 0) {
|
|
@@ -2130,6 +2050,7 @@ void ResourceWatcherFSM::DeleteDuplicateAutoStartFile(bool toDeleteLastLegity)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ /** 移除集中配置中配置的文件(公共目录下) [Gifur@20241031]*/
|
|
|
for (auto it = publist.cbegin(); keyPublist.size() > 0 && it != publist.cend(); ++it) {
|
|
|
for (auto kt = keyPublist.cbegin(); kt != keyPublist.cend(); ++kt) {
|
|
|
CSimpleStringA strfilename(it->c_str());
|
|
@@ -2144,6 +2065,7 @@ void ResourceWatcherFSM::DeleteDuplicateAutoStartFile(bool toDeleteLastLegity)
|
|
|
}
|
|
|
}
|
|
|
if (toDeleteLastLegity) {
|
|
|
+ /** 移除正规的文件(公共目录下) [Gifur@20241031]*/
|
|
|
for (auto kt = autolist.cbegin(); kt != autolist.cend(); ++kt) {
|
|
|
CSimpleStringA strfilename(it->c_str());
|
|
|
if (strfilename.Compare(kt->c_str()) == 0) {
|
|
@@ -2171,7 +2093,7 @@ BOOL ResourceWatcherFSM::IsHasSetAutoStartupByFolder(CSimpleStringA& strPath, in
|
|
|
std::string userPath(""), pubPath("");
|
|
|
GetAutoStartFile(userPath, userlist, pubPath, publist);
|
|
|
|
|
|
- //检查是否由用户自定义的开机自启动快捷键
|
|
|
+ //检查是否有由用户自定义的开机自启动快捷键
|
|
|
if (!result && (!keyPublist.empty() || !keyUserlist.empty())) {
|
|
|
for (auto it = userlist.cbegin(); !result && keyUserlist.size() > 0 && it != userlist.cend(); ++it) {
|
|
|
for (auto kt = keyUserlist.cbegin(); kt != keyUserlist.cend(); ++kt) {
|
|
@@ -2213,7 +2135,7 @@ BOOL ResourceWatcherFSM::IsHasSetAutoStartupByFolder(CSimpleStringA& strPath, in
|
|
|
}
|
|
|
}
|
|
|
if (!result) {
|
|
|
- //检查是否旧安装向导安装的脚本
|
|
|
+ //检查是否有由旧安装向导安装的脚本
|
|
|
for (auto it = publist.cbegin(); !result && it != publist.cend(); ++it) {
|
|
|
CSimpleStringA strfilename(it->c_str());
|
|
|
const int tmpType = (strfilename.Compare(CMB_LINK_FILE_NAME) == 0 || (strfilename.IsStartWith("招商银行可视柜台") && strfilename.IsEndWith(".lnk"))) ? 0 : -1;
|
|
@@ -2252,7 +2174,7 @@ BOOL ResourceWatcherFSM::IsHasSetAutoStartupByFolder(CSimpleStringA& strPath, in
|
|
|
}
|
|
|
}
|
|
|
if (!result) {
|
|
|
- //最终再检查是否由安装脚本执行的安装向导
|
|
|
+ //最终再检查是否有由安装脚本执行的安装向导
|
|
|
for (auto it = publist.cbegin(); !result && it != publist.cend(); ++it) {
|
|
|
CSimpleStringA strfilename(it->c_str());
|
|
|
if (strfilename.Compare(STRATUP_FILENAME_FROM_SCRIPTS) == 0) {
|
|
@@ -2349,12 +2271,10 @@ void ResourceWatcherFSM::DetectVersionHasChangedAndWarn()
|
|
|
|
|
|
void ResourceWatcherFSM::DetectDestopFileAndWarn(bool bClear, CSimpleStringA& strFileSaveList)
|
|
|
{
|
|
|
- CSimpleStringA strUserName(true);
|
|
|
- GetCurUserName(strUserName);
|
|
|
- if (!strUserName.IsNullOrEmpty()) {
|
|
|
+ if (!m_strLoginedUserName.IsNullOrEmpty()) {
|
|
|
CSimpleStringA filelist(true);
|
|
|
int dirCount(0), fileCount(0);
|
|
|
- CSimpleStringA desktopFullPath = CSimpleStringA::Format("C:\\Users\\%s\\Desktop", strUserName.GetData());
|
|
|
+ CSimpleStringA desktopFullPath = CSimpleStringA::Format("C:\\Users\\%s\\Desktop", m_strLoginedUserName.GetData());
|
|
|
CSimpleStringA desktopPublicPath("C:\\Users\\Public\\Desktop");
|
|
|
CAutoArray<CSimpleStringA> desktopPaths;
|
|
|
desktopPaths.Init(2);
|
|
@@ -2430,7 +2350,7 @@ void ResourceWatcherFSM::DetectDestopFileAndWarn(bool bClear, CSimpleStringA& st
|
|
|
}
|
|
|
LogWarn(Severity_Low, Error_Debug, LOG_INFO_DESKTOP_FILESTATUS
|
|
|
,CSimpleStringA::Format("{\"subject\":\"desktop_file\",\"clear_flag\":\"%d\",\"username\":\"%s\",\"file_count\":%d,\"dir_count\":%d,\"content\":\"%s\"}"
|
|
|
- , bClear ? 1 : 0, strUserName.GetData(), fileCount, dirCount, filelist.GetLength() < 950 ? filelist.GetData() : (filelist.SubString(0, 950) + "....").GetData()));
|
|
|
+ , bClear ? 1 : 0, m_strLoginedUserName.GetData(), fileCount, dirCount, filelist.GetLength() < 950 ? filelist.GetData() : (filelist.SubString(0, 950) + "....").GetData()));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2855,19 +2775,6 @@ bool ResourceWatcherFSM::RegOperation4LnkFile()
|
|
|
return bRet;
|
|
|
}
|
|
|
|
|
|
-bool ResourceWatcherFSM::UpdateExe()
|
|
|
-{
|
|
|
- int updateExe = 0;
|
|
|
- CSmartPointer<IConfigInfo> spCtSettingConfig;
|
|
|
- GetEntityBase()->GetFunction()->OpenConfig(Config_CenterSetting, spCtSettingConfig);
|
|
|
- spCtSettingConfig->ReadConfigValueInt("NonExclusive", "UpdateExe", updateExe);
|
|
|
-
|
|
|
- if (updateExe == 1)
|
|
|
- return true;
|
|
|
-
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
bool ResourceWatcherFSM::GetRegValueInt(HKEY hKey, LPCTSTR lpcszParam, DWORD& dwValue)
|
|
|
{
|
|
|
DWORD dwType = REG_DWORD;
|
|
@@ -3780,7 +3687,7 @@ void ResourceWatcherFSM::GetSystemCPUStatus()
|
|
|
|
|
|
// 转换为百分比
|
|
|
double tRatio = 100.0 * (newProcessTime[tPid] - oldProcessTime[tPid]) / (kernel + user);
|
|
|
- if (tRatio > 0.0);
|
|
|
+ if (tRatio > 0.0)
|
|
|
{
|
|
|
processCpu[tPid] = tRatio;
|
|
|
}
|
|
@@ -4173,6 +4080,150 @@ void ResourceWatcherFSM::InitCustomAutoStartFileSheet()
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
+void ResourceWatcherFSM::InitUserInfo()
|
|
|
+{
|
|
|
+ if (m_bFirstRunAfterBoot) {
|
|
|
+ LPITEMIDLIST lp;
|
|
|
+ CHAR lstr[MAX_PATH] = "";
|
|
|
+ HRESULT hr = SHGetSpecialFolderLocation(0, CSIDL_COMMON_STARTUP, &lp);
|
|
|
+ if (SUCCEEDED(hr)) {
|
|
|
+ memset(lstr, 0, strlen(lstr));
|
|
|
+ SHGetPathFromIDListA(lp, lstr);
|
|
|
+ CSimpleStringA s = lstr;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_COMMON_STARTUP: %s", s.GetData());
|
|
|
+ }
|
|
|
+ hr = SHGetSpecialFolderLocation(0, CSIDL_COMMON_DESKTOPDIRECTORY, &lp);
|
|
|
+ if (SUCCEEDED(hr)) {
|
|
|
+ memset(lstr, 0, strlen(lstr));
|
|
|
+ SHGetPathFromIDListA(lp, lstr);
|
|
|
+ CSimpleStringA s = lstr;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_COMMON_DESKTOPDIRECTORY: %s", s.GetData());
|
|
|
+ }
|
|
|
+
|
|
|
+ hr = SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, &lp);
|
|
|
+ if (SUCCEEDED(hr)) {
|
|
|
+ memset(lstr, 0, strlen(lstr));
|
|
|
+ SHGetPathFromIDListA(lp, lstr);
|
|
|
+ CSimpleStringA s = lstr;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_DESKTOP: %s", s.GetData());
|
|
|
+ }
|
|
|
+
|
|
|
+ hr = SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, &lp);
|
|
|
+ if (SUCCEEDED(hr)) {
|
|
|
+ memset(lstr, 0, strlen(lstr));
|
|
|
+ SHGetPathFromIDListA(lp, lstr);
|
|
|
+ CSimpleStringA s = lstr;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_DESKTOPDIRECTORY: %s", s.GetData());
|
|
|
+ }
|
|
|
+
|
|
|
+ CSimpleStringA desktopParentPath = "C:\\Users";
|
|
|
+ auto arr = fileutil_get_sub_dirs(desktopParentPath);
|
|
|
+ if (arr != NULL) {
|
|
|
+ for (int i = 0; i < arr->nelts; ++i) {
|
|
|
+ char* dir = ARRAY_IDX(arr, i, char*);
|
|
|
+ char* dirname = strrchr(dir, '\\');
|
|
|
+ if (dirname != NULL) { dirname += 1; }
|
|
|
+ else { dirname = dir; }
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("dir name:%s", dirname);
|
|
|
+ }
|
|
|
+ toolkit_array_free2(arr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const DWORD INFO_BUFFER_SIZE = 128;
|
|
|
+ char infoBuf[INFO_BUFFER_SIZE];
|
|
|
+ ZeroMemory(infoBuf, INFO_BUFFER_SIZE);
|
|
|
+ DWORD bufCharCount = INFO_BUFFER_SIZE;
|
|
|
+ if (!GetUserName(infoBuf, &bufCharCount)) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetUserName failed, GLE=%u", GetLastError());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ m_strCurrentUserName = infoBuf;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Current user name:%s", m_strCurrentUserName.GetData());
|
|
|
+ }
|
|
|
+
|
|
|
+ DWORD dwSessionId = WTSGetActiveConsoleSessionId();
|
|
|
+ LPTSTR pBuffer = NULL;
|
|
|
+ DWORD dwBufferLen;
|
|
|
+ BOOL bRes = WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, dwSessionId, WTSUserName, &pBuffer, &dwBufferLen);
|
|
|
+ if (bRes)
|
|
|
+ {
|
|
|
+ m_strLoginedUserName = pBuffer;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Current logined user name:%s", m_strLoginedUserName.GetData());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("WTSQuerySessionInformation failed, GLE=%u", GetLastError());
|
|
|
+ }
|
|
|
+ if (pBuffer) {
|
|
|
+ WTSFreeMemory(pBuffer);
|
|
|
+ }
|
|
|
+ const int diff_flag = IsUserSameName() ? 1 : 0;
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_INFO_USRNAME_INFO, CSimpleStringA::Format("{\"subject\":\"user_info\",\"username\":\"%s\",\"login_username\":\"%s\",\"diff\":%d}"
|
|
|
+ ,m_strCurrentUserName.GetData(), m_strLoginedUserName.GetData(), diff_flag));
|
|
|
+}
|
|
|
+
|
|
|
+void ResourceWatcherFSM::GetUserDesktopDirectory(CSimpleStringA& outDir)
|
|
|
+{
|
|
|
+ outDir.Clear();
|
|
|
+ if (!m_strLoginedUserName.IsNullOrEmpty()) {
|
|
|
+ CSimpleStringA desktopFullPath = CSimpleStringA::Format("C:\\Users\\%s\\Desktop", m_strLoginedUserName.GetData());
|
|
|
+ outDir = desktopFullPath;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("LoginedUserName is empty.");
|
|
|
+ }
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+bool ResourceWatcherFSM::IsDesktopIconExist(CSimpleStringA& strPath)
|
|
|
+{
|
|
|
+ CSimpleStringA s(true);
|
|
|
+ GetUserDesktopDirectory(s);
|
|
|
+ if (!s.IsNullOrEmpty()) {
|
|
|
+ s += "\\可视柜台.lnk";
|
|
|
+ strPath = s.GetData();
|
|
|
+ return !!ExistsFileA(s);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+void ResourceWatcherFSM::GetUserStartupDirectory(CSimpleStringA& outDir)
|
|
|
+{
|
|
|
+ outDir.Clear();
|
|
|
+ //LPITEMIDLIST lp;
|
|
|
+ //HRESULT hr = SHGetSpecialFolderLocation(0, CSIDL_COMMON_STARTUP, &lp);
|
|
|
+ //if (SUCCEEDED(hr)) {
|
|
|
+ // CHAR lstr[MAX_PATH];
|
|
|
+ // memset(lstr, 0, strlen(lstr));
|
|
|
+ // SHGetPathFromIDListA(lp, lstr);
|
|
|
+ // CSimpleStringA desktopFullPath = lstr;
|
|
|
+ // DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CSIDL_COMMON_STARTUP: %s", desktopFullPath.GetData());
|
|
|
+ // outDir = desktopFullPath;
|
|
|
+ //}
|
|
|
+
|
|
|
+ if (!m_strLoginedUserName.IsNullOrEmpty()) {
|
|
|
+ CSimpleStringA startMenuFullPath = CSimpleStringA::Format("C:\\Users\\%s\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup", m_strLoginedUserName.GetData());
|
|
|
+ outDir = startMenuFullPath;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("LoginedUserName is empty.");
|
|
|
+ }
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+bool ResourceWatcherFSM::IsStartupIconExist(CSimpleStringA& strPath)
|
|
|
+{
|
|
|
+ CSimpleStringA s(true);
|
|
|
+ GetUserStartupDirectory(s);
|
|
|
+ if (!s.IsNullOrEmpty()) {
|
|
|
+ s += "\\";
|
|
|
+ s += STRATUP_FILENAME_FROM_SCRIPTS;
|
|
|
+ strPath = s.GetData();
|
|
|
+ return !!ExistsFileA(s);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
#endif // _MSC_VER end硬件资源监控相关系统功能 CPU、内存、硬盘、网络wifi
|
|
|
|
|
|
#ifdef RVC_OS_LINUX
|