2022-08-09 02:14:40 +00:00
|
|
|
|
#include <Windows.h>
|
|
|
|
|
#include <atlstr.h>
|
|
|
|
|
#include <tlhelp32.h>
|
2022-08-22 07:27:58 +00:00
|
|
|
|
#include <psapi.h>
|
2022-08-09 02:14:40 +00:00
|
|
|
|
|
|
|
|
|
static CStringA GetInstallLocation(const CStringA& guid)
|
|
|
|
|
{
|
|
|
|
|
CStringA strInstallLoc;
|
|
|
|
|
|
|
|
|
|
HKEY hKey = NULL;
|
|
|
|
|
CStringA strSubKey;
|
|
|
|
|
strSubKey.Format("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s", (LPCSTR)guid);
|
|
|
|
|
RegOpenKeyExA(HKEY_LOCAL_MACHINE, strSubKey, 0, KEY_QUERY_VALUE, &hKey);
|
|
|
|
|
if (NULL != hKey)
|
|
|
|
|
{
|
|
|
|
|
CHAR szData[MAX_PATH] = { 0 };
|
|
|
|
|
DWORD cbData = MAX_PATH;
|
|
|
|
|
if (ERROR_SUCCESS == RegQueryValueExA(hKey, "InstallLocation", NULL, NULL, (LPBYTE)szData, &cbData))
|
|
|
|
|
{
|
|
|
|
|
strInstallLoc = szData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return strInstallLoc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool AppIsRun(const CStringA& guid, const CStringA& appName)
|
|
|
|
|
{
|
|
|
|
|
CStringA strInstallLoc = GetInstallLocation(guid);
|
|
|
|
|
if (strInstallLoc.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CStringW strAppPath2(strInstallLoc);
|
|
|
|
|
CStringW strAppName2(appName);
|
|
|
|
|
|
|
|
|
|
bool ret = false;
|
|
|
|
|
HANDLE hSnapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
|
|
|
|
if (hSnapshot != INVALID_HANDLE_VALUE)
|
|
|
|
|
{
|
|
|
|
|
PROCESSENTRY32 pe;
|
|
|
|
|
pe.dwSize = sizeof(PROCESSENTRY32);
|
|
|
|
|
BOOL bFindFirstProcess = ::Process32First(hSnapshot, &pe);
|
|
|
|
|
if (bFindFirstProcess)
|
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
WCHAR exeFullPath[1024] = { 0 };
|
2022-08-22 07:27:58 +00:00
|
|
|
|
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pe.th32ProcessID);
|
2022-08-09 02:14:40 +00:00
|
|
|
|
if (NULL != hProcess)
|
|
|
|
|
{
|
2022-08-22 07:27:58 +00:00
|
|
|
|
::GetModuleFileNameExW(hProcess, NULL, exeFullPath, 1024);
|
2022-08-09 02:14:40 +00:00
|
|
|
|
::CloseHandle(hProcess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CStringW strExeFullPath(exeFullPath);
|
|
|
|
|
int pos = strExeFullPath.ReverseFind('\\');
|
|
|
|
|
if (-1 != pos)
|
|
|
|
|
{
|
|
|
|
|
CStringW strExeName = strExeFullPath.Right(strExeFullPath.GetLength() - pos - 1);
|
|
|
|
|
|
|
|
|
|
strExeFullPath.MakeLower();
|
|
|
|
|
strAppPath2.MakeLower();
|
|
|
|
|
if (0 == _wcsicmp(strExeName, strAppName2) && NULL != wcsstr(strExeFullPath, strAppPath2))
|
|
|
|
|
{
|
|
|
|
|
ret = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} while (::Process32Next(hSnapshot, &pe));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::CloseHandle(hSnapshot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
|
|
|
|
_In_opt_ HINSTANCE hPrevInstance,
|
|
|
|
|
_In_ LPWSTR lpCmdLine,
|
|
|
|
|
_In_ int nCmdShow)
|
|
|
|
|
{
|
2023-04-18 06:20:12 +00:00
|
|
|
|
CStringW strCmdLine(lpCmdLine);
|
2022-08-09 02:14:40 +00:00
|
|
|
|
|
|
|
|
|
CStringA strAppGuid, strAppName;
|
2023-04-18 06:20:12 +00:00
|
|
|
|
if (-1 != strCmdLine.Find(L"OEM_HANWANG"))
|
|
|
|
|
{
|
|
|
|
|
strAppGuid = "{4486975C-CBCF-430B-BED1-427866D1738E}_is1";
|
|
|
|
|
strAppName = "HanvonScan.exe";
|
|
|
|
|
}
|
|
|
|
|
else if (-1 != strCmdLine.Find(L"OEM_LISICHENG"))
|
|
|
|
|
{
|
|
|
|
|
strAppGuid = "{F2890F43-A51C-4379-BB79-992616B1D6BD}_is1";
|
|
|
|
|
strAppName = "LanxumScan.exe";
|
|
|
|
|
}
|
|
|
|
|
else if (-1 != strCmdLine.Find(L"OEM_CANGTIAN"))
|
|
|
|
|
{
|
|
|
|
|
strAppGuid = "{ADE66CB2-15FD-4BF8-BFA7-ED3E239C9ACE}_is1";
|
|
|
|
|
strAppName = "CumtennScan.exe";
|
|
|
|
|
}
|
|
|
|
|
else if (-1 != strCmdLine.Find(L"OEM_ZHONGJING"))
|
|
|
|
|
{
|
|
|
|
|
strAppGuid = "{36868C39-B195-498B-BFAE-36125D55305E}_is1";
|
|
|
|
|
strAppName = "MicrotekScan.exe";
|
|
|
|
|
}
|
|
|
|
|
else if (-1 != strCmdLine.Find(L"OEM_ZIGUANG"))
|
|
|
|
|
{
|
|
|
|
|
strAppGuid = "{6512BEFD-F0E0-495F-8E12-4D07B5B3BE87}_is1";
|
|
|
|
|
strAppName = "UniscanScan.exe";
|
|
|
|
|
}
|
|
|
|
|
else if (-1 != strCmdLine.Find(L"OEM_HUAGAO_NEU"))
|
|
|
|
|
{
|
|
|
|
|
strAppGuid = "{05E346E5-D4F2-410C-A2AB-62E416E13996}_is1";
|
|
|
|
|
strAppName = "HGScan.exe";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strAppGuid = "{7076DC53-5C2F-4216-9783-2A6F954FEB3E}_is1";
|
|
|
|
|
strAppName = "HuaGoScan.exe";
|
|
|
|
|
}
|
2022-08-09 02:14:40 +00:00
|
|
|
|
|
|
|
|
|
if (AppIsRun(strAppGuid, strAppName))
|
|
|
|
|
{
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|