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)
|
|
|
|
|
{
|
|
|
|
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
|
|
|
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
|
|
|
|
|
|
|
|
|
CStringA strAppGuid, strAppName;
|
|
|
|
|
#if defined(OEM_HANWANG)
|
|
|
|
|
strAppGuid = "{4486975C-CBCF-430B-BED1-427866D1738E}_is1";
|
|
|
|
|
strAppName = "HanvonScan.exe";
|
|
|
|
|
#elif defined(OEM_LISICHENG)
|
|
|
|
|
strAppGuid = "{F2890F43-A51C-4379-BB79-992616B1D6BD}_is1";
|
|
|
|
|
strAppName = "LanxumScan.exe";
|
|
|
|
|
#else
|
|
|
|
|
strAppGuid = "{7076DC53-5C2F-4216-9783-2A6F954FEB3E}_is1";
|
|
|
|
|
strAppName = "HuaGoScan.exe";
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (AppIsRun(strAppGuid, strAppName))
|
|
|
|
|
{
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|