将HGUpgrade中的运行app相关函数挪到HGVersion中
This commit is contained in:
parent
29522a0395
commit
2468a3fa8b
|
@ -1,282 +0,0 @@
|
||||||
#include "HGUpgrade.h"
|
|
||||||
#include "base/HGDef.h"
|
|
||||||
#include "base/HGInc.h"
|
|
||||||
#include "version/HGVersion.h"
|
|
||||||
#if defined(HG_CMP_MSC)
|
|
||||||
#include <shellapi.h>
|
|
||||||
#include <tlhelp32.h>
|
|
||||||
#include <psapi.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool AppIsRun(const HGChar *appName, const HGChar* oemName)
|
|
||||||
{
|
|
||||||
if (0 == strcmp(appName, HGVERSION_APPNAME_SCANNER))
|
|
||||||
{
|
|
||||||
#if defined(HG_CMP_MSC)
|
|
||||||
|
|
||||||
std::wstring appPath;
|
|
||||||
std::wstring regName;
|
|
||||||
|
|
||||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
|
||||||
regName = L"SOFTWARE\\HanvonScan";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
|
||||||
regName = L"SOFTWARE\\LanxumScan";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
|
||||||
regName = L"SOFTWARE\\CumtennScan";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
|
||||||
regName = L"SOFTWARE\\MicrotekScan";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
|
||||||
regName = L"SOFTWARE\\UniScan";
|
|
||||||
else
|
|
||||||
regName = L"SOFTWARE\\HuaGoScan";
|
|
||||||
|
|
||||||
HKEY hKey = nullptr;
|
|
||||||
RegOpenKeyExW(HKEY_LOCAL_MACHINE, regName.c_str(), 0, KEY_QUERY_VALUE, &hKey);
|
|
||||||
if (nullptr != hKey)
|
|
||||||
{
|
|
||||||
WCHAR szData[MAX_PATH] = { 0 };
|
|
||||||
DWORD cbData = MAX_PATH;
|
|
||||||
if (ERROR_SUCCESS == RegQueryValueExW(hKey, L"Application", nullptr, nullptr, (LPBYTE)szData, &cbData))
|
|
||||||
{
|
|
||||||
appPath = szData;
|
|
||||||
}
|
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (appPath.empty())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 };
|
|
||||||
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pe.th32ProcessID);
|
|
||||||
if (nullptr != hProcess)
|
|
||||||
{
|
|
||||||
::GetModuleFileNameExW(hProcess, NULL, exeFullPath, 1024);
|
|
||||||
::CloseHandle(hProcess);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 == wcsicmp(exeFullPath, appPath.c_str()))
|
|
||||||
{
|
|
||||||
ret = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (::Process32Next(hSnapshot, &pe));
|
|
||||||
}
|
|
||||||
|
|
||||||
::CloseHandle(hSnapshot);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
#else
|
|
||||||
std::string cmd;
|
|
||||||
std::string appPath;
|
|
||||||
|
|
||||||
std::string osName;
|
|
||||||
FILE *file = popen("cat /etc/issue | cut -d\' \' -f1", "r");
|
|
||||||
if (NULL != file)
|
|
||||||
{
|
|
||||||
char data[1024] = {0};
|
|
||||||
if (NULL != fgets(data, 1024, file))
|
|
||||||
osName = data;
|
|
||||||
pclose(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("osName=%s\n", osName.c_str());
|
|
||||||
if (osName.find("UnionTech") != std::string::npos)
|
|
||||||
{
|
|
||||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
|
||||||
{
|
|
||||||
cmd = "ps -wef | grep HanvonScan";
|
|
||||||
appPath = "/opt/apps/com.hanvonchina.hanvonscan/files/bin/HanvonScan";
|
|
||||||
}
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
|
||||||
{
|
|
||||||
cmd = "ps -wef | grep LanxumScan";
|
|
||||||
appPath = "/opt/apps/com.lanxumchina.lanxumscan/files/bin/LanxumScan";
|
|
||||||
}
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
|
||||||
{
|
|
||||||
cmd = "ps -wef | grep CumtennScan";
|
|
||||||
appPath = "/opt/apps/com.cumtennchina.cumtennscan/files/bin/CumtennScan";
|
|
||||||
}
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
|
||||||
{
|
|
||||||
cmd = "ps -wef | grep MicrotekScan";
|
|
||||||
appPath = "/opt/apps/com.microtekchina.microtekscan-ex/files/bin/MicrotekScan";
|
|
||||||
}
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
|
||||||
{
|
|
||||||
cmd = "ps -wef | grep UniScan";
|
|
||||||
appPath = "/opt/apps/com.unischina.uniscan/files/bin/UniScan";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd = "ps -wef | grep HuaGoScan";
|
|
||||||
appPath = "/opt/apps/com.huagaochina.huagoscan/files/bin/HuaGoScan";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
|
||||||
{
|
|
||||||
cmd = "ps -wef | grep HanvonScan";
|
|
||||||
appPath = "/opt/apps/scanner-driver-hanvon/bin/HanvonScan";
|
|
||||||
}
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
|
||||||
{
|
|
||||||
cmd = "ps -wef | grep LanxumScan";
|
|
||||||
appPath = "/opt/apps/scanner-driver-lanxum/bin/LanxumScan";
|
|
||||||
}
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
|
||||||
{
|
|
||||||
cmd = "ps -wef | grep CumtennScan";
|
|
||||||
appPath = "/opt/apps/scanner-driver-cumtenn/bin/CumtennScan";
|
|
||||||
}
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
|
||||||
{
|
|
||||||
cmd = "ps -wef | grep MicrotekScan";
|
|
||||||
appPath = "/opt/apps/scanner-driver-microtek-ex/bin/MicrotekScan";
|
|
||||||
}
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
|
||||||
{
|
|
||||||
cmd = "ps -wef | grep UniScan";
|
|
||||||
appPath = "/opt/apps/scanner-driver-unis/bin/UniScan";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd = "ps -wef | grep HuaGoScan";
|
|
||||||
appPath = "/opt/apps/scanner-driver-huagao/bin/HuaGoScan";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ret = false;
|
|
||||||
FILE *fp = popen(cmd.c_str(), "r");
|
|
||||||
if (nullptr != fp)
|
|
||||||
{
|
|
||||||
char data[2048] = {0};
|
|
||||||
while (data == fgets(data, 2048, fp))
|
|
||||||
{
|
|
||||||
if (nullptr != strstr(data, appPath.c_str()))
|
|
||||||
{
|
|
||||||
ret = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pclose(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunApp(const HGChar *appName, const HGChar* oemName)
|
|
||||||
{
|
|
||||||
if (0 == strcmp(appName, HGVERSION_APPNAME_SCANNER))
|
|
||||||
{
|
|
||||||
#if defined(HG_CMP_MSC)
|
|
||||||
|
|
||||||
std::wstring appPath;
|
|
||||||
std::wstring regName;
|
|
||||||
|
|
||||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
|
||||||
regName = L"SOFTWARE\\HanvonScan";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
|
||||||
regName = L"SOFTWARE\\LanxumScan";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
|
||||||
regName = L"SOFTWARE\\CumtennScan";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
|
||||||
regName = L"SOFTWARE\\MicrotekScan";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
|
||||||
regName = L"SOFTWARE\\UniScan";
|
|
||||||
else
|
|
||||||
regName = L"SOFTWARE\\HuaGoScan";
|
|
||||||
|
|
||||||
HKEY hKey = nullptr;
|
|
||||||
RegOpenKeyExW(HKEY_LOCAL_MACHINE, regName.c_str(), 0, KEY_QUERY_VALUE, &hKey);
|
|
||||||
if (nullptr != hKey)
|
|
||||||
{
|
|
||||||
WCHAR szData[MAX_PATH] = { 0 };
|
|
||||||
DWORD cbData = MAX_PATH;
|
|
||||||
if (ERROR_SUCCESS == RegQueryValueExW(hKey, L"Application", nullptr, nullptr, (LPBYTE)szData, &cbData))
|
|
||||||
{
|
|
||||||
appPath = szData;
|
|
||||||
}
|
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!appPath.empty())
|
|
||||||
{
|
|
||||||
ShellExecuteW(nullptr, L"open", appPath.c_str(), nullptr, nullptr, SW_SHOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
std::string appPath;
|
|
||||||
|
|
||||||
std::string osName;
|
|
||||||
FILE *file = popen("cat /etc/issue | cut -d\' \' -f1", "r");
|
|
||||||
if (NULL != file)
|
|
||||||
{
|
|
||||||
char data[1024] = {0};
|
|
||||||
if (NULL != fgets(data, 1024, file))
|
|
||||||
osName = data;
|
|
||||||
pclose(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("osName=%s\n", osName.c_str());
|
|
||||||
if (osName.find("UnionTech") != std::string::npos)
|
|
||||||
{
|
|
||||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
|
||||||
appPath = "sh /opt/apps/com.hanvonchina.hanvonscan/files/bin/HanvonScan.sh &";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
|
||||||
appPath = "sh /opt/apps/com.lanxumchina.lanxumscan/files/bin/LanxumScan.sh &";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
|
||||||
appPath = "sh /opt/apps/com.cumtennchina.cumtennscan/files/bin/CumtennScan.sh &";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
|
||||||
appPath = "sh /opt/apps/com.microtekchina.microtekscan-ex/files/bin/MicrotekScan.sh &";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
|
||||||
appPath = "sh /opt/apps/com.unischina.uniscan/files/bin/UniScan.sh &";
|
|
||||||
else
|
|
||||||
appPath = "sh /opt/apps/com.huagaochina.huagoscan/files/bin/HuaGoScan.sh &";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
|
||||||
appPath = "sh /opt/apps/scanner-driver-hanvon/bin/HanvonScan.sh &";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
|
||||||
appPath = "sh /opt/apps/scanner-driver-lanxum/bin/LanxumScan.sh &";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
|
||||||
appPath = "sh /opt/apps/scanner-driver-cumtenn/bin/CumtennScan.sh &";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
|
||||||
appPath = "sh /opt/apps/scanner-driver-microtek-ex/bin/MicrotekScan.sh &";
|
|
||||||
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
|
||||||
appPath = "sh /opt/apps/scanner-driver-unis/bin/UniScan.sh &";
|
|
||||||
else
|
|
||||||
appPath = "sh /opt/apps/scanner-driver-huagao/bin/HuaGoScan.sh &";
|
|
||||||
}
|
|
||||||
|
|
||||||
system(appPath.c_str());
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
#ifndef __HGUPGRADE_H__
|
|
||||||
#define __HGUPGRADE_H__
|
|
||||||
|
|
||||||
#include "base/HGDef.h"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
// 判断app是否在运行
|
|
||||||
bool AppIsRun(const HGChar *appName, const HGChar* oemName);
|
|
||||||
|
|
||||||
// 运行app
|
|
||||||
void RunApp(const HGChar *appName, const HGChar* oemName);
|
|
||||||
|
|
||||||
#endif /* __HGUPGRADE_H__ */
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include "version/HGVersion.h"
|
#include "version/HGVersion.h"
|
||||||
#include "HGUpgrade.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -66,8 +65,17 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
while (AppIsRun(appName.c_str(), oemName.c_str()))
|
while (1)
|
||||||
|
{
|
||||||
|
HGBool isRun = HGFALSE;
|
||||||
|
HGVersion_GetAppStatus(appName.c_str(), oemName.c_str(), &isRun);
|
||||||
|
if (!isRun)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
QThread::msleep(20);
|
QThread::msleep(20);
|
||||||
|
}
|
||||||
|
|
||||||
QString translator_upgrade_name = ":translation/Upgrade_zh_CN.qm";
|
QString translator_upgrade_name = ":translation/Upgrade_zh_CN.qm";
|
||||||
if (appLang == "english")
|
if (appLang == "english")
|
||||||
|
@ -92,8 +100,12 @@ int main(int argc, char *argv[])
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
msg.exec();
|
msg.exec();
|
||||||
|
|
||||||
if (!AppIsRun(appName.c_str(), oemName.c_str()))
|
HGBool isRun = HGFALSE;
|
||||||
RunApp(appName.c_str(), oemName.c_str());
|
HGVersion_GetAppStatus(appName.c_str(), oemName.c_str(), &isRun);
|
||||||
|
if (!isRun)
|
||||||
|
{
|
||||||
|
HGVersion_RunApp(appName.c_str(), oemName.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,12 +162,10 @@ unix {
|
||||||
}
|
}
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
../../../app/upgrade/HGUpgrade.cpp \
|
|
||||||
../../../app/upgrade/main.cpp \
|
../../../app/upgrade/main.cpp \
|
||||||
../../../app/upgrade/mainwindow.cpp
|
../../../app/upgrade/mainwindow.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
../../../app/upgrade/HGUpgrade.h \
|
|
||||||
../../../app/upgrade/mainwindow.h
|
../../../app/upgrade/mainwindow.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
|
|
|
@ -29,4 +29,6 @@ HGVersion_ReleaseVersionList
|
||||||
HGVersion_GetCurrVersion
|
HGVersion_GetCurrVersion
|
||||||
HGVersion_CompareVersion
|
HGVersion_CompareVersion
|
||||||
HGVersion_BlackListCheck
|
HGVersion_BlackListCheck
|
||||||
|
HGVersion_GetAppStatus
|
||||||
|
HGVersion_RunApp
|
||||||
HGVersion_GetDriverVersionList
|
HGVersion_GetDriverVersionList
|
|
@ -54,7 +54,7 @@ win32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_FILE = HGVersion.def
|
DEF_FILE = HGVersion.def
|
||||||
LIBS += -lgdi32 -lgdiplus -ldbghelp -lws2_32 -lwldap32 -lIphlpapi -ladvapi32
|
LIBS += -lgdi32 -lgdiplus -ldbghelp -lws2_32 -lwldap32 -lIphlpapi -ladvapi32 -lshell32
|
||||||
LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX}Base
|
LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX}Base
|
||||||
INCLUDEPATH += $$PWD/../../../third_party/libcurl/$${MY_OS}/include
|
INCLUDEPATH += $$PWD/../../../third_party/libcurl/$${MY_OS}/include
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
#include <shellapi.h>
|
||||||
|
#include <tlhelp32.h>
|
||||||
|
#include <psapi.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
HGResult HGAPI HGVersion_CreateMgr(HGVersionMgr* mgr)
|
HGResult HGAPI HGVersion_CreateMgr(HGVersionMgr* mgr)
|
||||||
{
|
{
|
||||||
|
@ -330,6 +335,285 @@ HGResult HGAPI HGVersion_BlackListCheck(HGVersionMgr mgr, const HGChar* devSN, H
|
||||||
return versionMgrImpl->BlackListCheck(devSN, inList);
|
return versionMgrImpl->BlackListCheck(devSN, inList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGVersion_GetAppStatus(const HGChar* appName, const HGChar* oemName, HGBool *isRun)
|
||||||
|
{
|
||||||
|
if (NULL == appName || NULL == oemName || NULL == isRun)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
*isRun = HGFALSE;
|
||||||
|
|
||||||
|
if (0 == strcmp(appName, HGVERSION_APPNAME_SCANNER))
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
|
||||||
|
std::wstring appPath;
|
||||||
|
std::wstring regName;
|
||||||
|
|
||||||
|
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||||
|
regName = L"SOFTWARE\\HanvonScan";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
||||||
|
regName = L"SOFTWARE\\LanxumScan";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
||||||
|
regName = L"SOFTWARE\\CumtennScan";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
||||||
|
regName = L"SOFTWARE\\MicrotekScan";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
||||||
|
regName = L"SOFTWARE\\UniScan";
|
||||||
|
else
|
||||||
|
regName = L"SOFTWARE\\HuaGoScan";
|
||||||
|
|
||||||
|
HKEY hKey = nullptr;
|
||||||
|
RegOpenKeyExW(HKEY_LOCAL_MACHINE, regName.c_str(), 0, KEY_QUERY_VALUE, &hKey);
|
||||||
|
if (nullptr != hKey)
|
||||||
|
{
|
||||||
|
WCHAR szData[MAX_PATH] = { 0 };
|
||||||
|
DWORD cbData = MAX_PATH;
|
||||||
|
if (ERROR_SUCCESS == RegQueryValueExW(hKey, L"Application", nullptr, nullptr, (LPBYTE)szData, &cbData))
|
||||||
|
{
|
||||||
|
appPath = szData;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!appPath.empty())
|
||||||
|
{
|
||||||
|
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 };
|
||||||
|
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pe.th32ProcessID);
|
||||||
|
if (nullptr != hProcess)
|
||||||
|
{
|
||||||
|
::GetModuleFileNameExW(hProcess, NULL, exeFullPath, 1024);
|
||||||
|
::CloseHandle(hProcess);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == wcsicmp(exeFullPath, appPath.c_str()))
|
||||||
|
{
|
||||||
|
*isRun = HGTRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (::Process32Next(hSnapshot, &pe));
|
||||||
|
}
|
||||||
|
|
||||||
|
::CloseHandle(hSnapshot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
std::string cmd;
|
||||||
|
std::string appPath;
|
||||||
|
|
||||||
|
std::string osName;
|
||||||
|
FILE *file = popen("cat /etc/issue | cut -d\' \' -f1", "r");
|
||||||
|
if (NULL != file)
|
||||||
|
{
|
||||||
|
char data[1024] = {0};
|
||||||
|
if (NULL != fgets(data, 1024, file))
|
||||||
|
osName = data;
|
||||||
|
pclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("osName=%s\n", osName.c_str());
|
||||||
|
if (osName.find("UnionTech") != std::string::npos)
|
||||||
|
{
|
||||||
|
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||||
|
{
|
||||||
|
cmd = "ps -wef | grep HanvonScan";
|
||||||
|
appPath = "/opt/apps/com.hanvonchina.hanvonscan/files/bin/HanvonScan";
|
||||||
|
}
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
||||||
|
{
|
||||||
|
cmd = "ps -wef | grep LanxumScan";
|
||||||
|
appPath = "/opt/apps/com.lanxumchina.lanxumscan/files/bin/LanxumScan";
|
||||||
|
}
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
||||||
|
{
|
||||||
|
cmd = "ps -wef | grep CumtennScan";
|
||||||
|
appPath = "/opt/apps/com.cumtennchina.cumtennscan/files/bin/CumtennScan";
|
||||||
|
}
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
||||||
|
{
|
||||||
|
cmd = "ps -wef | grep MicrotekScan";
|
||||||
|
appPath = "/opt/apps/com.microtekchina.microtekscan-ex/files/bin/MicrotekScan";
|
||||||
|
}
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
||||||
|
{
|
||||||
|
cmd = "ps -wef | grep UniScan";
|
||||||
|
appPath = "/opt/apps/com.unischina.uniscan/files/bin/UniScan";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmd = "ps -wef | grep HuaGoScan";
|
||||||
|
appPath = "/opt/apps/com.huagaochina.huagoscan/files/bin/HuaGoScan";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||||
|
{
|
||||||
|
cmd = "ps -wef | grep HanvonScan";
|
||||||
|
appPath = "/opt/apps/scanner-driver-hanvon/bin/HanvonScan";
|
||||||
|
}
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
||||||
|
{
|
||||||
|
cmd = "ps -wef | grep LanxumScan";
|
||||||
|
appPath = "/opt/apps/scanner-driver-lanxum/bin/LanxumScan";
|
||||||
|
}
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
||||||
|
{
|
||||||
|
cmd = "ps -wef | grep CumtennScan";
|
||||||
|
appPath = "/opt/apps/scanner-driver-cumtenn/bin/CumtennScan";
|
||||||
|
}
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
||||||
|
{
|
||||||
|
cmd = "ps -wef | grep MicrotekScan";
|
||||||
|
appPath = "/opt/apps/scanner-driver-microtek-ex/bin/MicrotekScan";
|
||||||
|
}
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
||||||
|
{
|
||||||
|
cmd = "ps -wef | grep UniScan";
|
||||||
|
appPath = "/opt/apps/scanner-driver-unis/bin/UniScan";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmd = "ps -wef | grep HuaGoScan";
|
||||||
|
appPath = "/opt/apps/scanner-driver-huagao/bin/HuaGoScan";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE *fp = popen(cmd.c_str(), "r");
|
||||||
|
if (nullptr != fp)
|
||||||
|
{
|
||||||
|
char data[2048] = {0};
|
||||||
|
while (data == fgets(data, 2048, fp))
|
||||||
|
{
|
||||||
|
if (nullptr != strstr(data, appPath.c_str()))
|
||||||
|
{
|
||||||
|
*isRun = HGTRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HGResult HGAPI HGVersion_RunApp(const HGChar* appName, const HGChar* oemName)
|
||||||
|
{
|
||||||
|
if (NULL == appName || NULL == oemName)
|
||||||
|
{
|
||||||
|
return HGBASE_ERR_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == strcmp(appName, HGVERSION_APPNAME_SCANNER))
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
|
||||||
|
std::wstring appPath;
|
||||||
|
std::wstring regName;
|
||||||
|
|
||||||
|
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||||
|
regName = L"SOFTWARE\\HanvonScan";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
||||||
|
regName = L"SOFTWARE\\LanxumScan";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
||||||
|
regName = L"SOFTWARE\\CumtennScan";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
||||||
|
regName = L"SOFTWARE\\MicrotekScan";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
||||||
|
regName = L"SOFTWARE\\UniScan";
|
||||||
|
else
|
||||||
|
regName = L"SOFTWARE\\HuaGoScan";
|
||||||
|
|
||||||
|
HKEY hKey = nullptr;
|
||||||
|
RegOpenKeyExW(HKEY_LOCAL_MACHINE, regName.c_str(), 0, KEY_QUERY_VALUE, &hKey);
|
||||||
|
if (nullptr != hKey)
|
||||||
|
{
|
||||||
|
WCHAR szData[MAX_PATH] = { 0 };
|
||||||
|
DWORD cbData = MAX_PATH;
|
||||||
|
if (ERROR_SUCCESS == RegQueryValueExW(hKey, L"Application", nullptr, nullptr, (LPBYTE)szData, &cbData))
|
||||||
|
{
|
||||||
|
appPath = szData;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!appPath.empty())
|
||||||
|
{
|
||||||
|
ShellExecuteW(nullptr, L"open", appPath.c_str(), nullptr, nullptr, SW_SHOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
std::string appPath;
|
||||||
|
|
||||||
|
std::string osName;
|
||||||
|
FILE *file = popen("cat /etc/issue | cut -d\' \' -f1", "r");
|
||||||
|
if (NULL != file)
|
||||||
|
{
|
||||||
|
char data[1024] = {0};
|
||||||
|
if (NULL != fgets(data, 1024, file))
|
||||||
|
osName = data;
|
||||||
|
pclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("osName=%s\n", osName.c_str());
|
||||||
|
if (osName.find("UnionTech") != std::string::npos)
|
||||||
|
{
|
||||||
|
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||||
|
appPath = "sh /opt/apps/com.hanvonchina.hanvonscan/files/bin/HanvonScan.sh &";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
||||||
|
appPath = "sh /opt/apps/com.lanxumchina.lanxumscan/files/bin/LanxumScan.sh &";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
||||||
|
appPath = "sh /opt/apps/com.cumtennchina.cumtennscan/files/bin/CumtennScan.sh &";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
||||||
|
appPath = "sh /opt/apps/com.microtekchina.microtekscan-ex/files/bin/MicrotekScan.sh &";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
||||||
|
appPath = "sh /opt/apps/com.unischina.uniscan/files/bin/UniScan.sh &";
|
||||||
|
else
|
||||||
|
appPath = "sh /opt/apps/com.huagaochina.huagoscan/files/bin/HuaGoScan.sh &";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (0 == strcmp(oemName, HGVERSION_OEMNAME_HANVON))
|
||||||
|
appPath = "sh /opt/apps/scanner-driver-hanvon/bin/HanvonScan.sh &";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_LANXUM))
|
||||||
|
appPath = "sh /opt/apps/scanner-driver-lanxum/bin/LanxumScan.sh &";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_CUMTENN))
|
||||||
|
appPath = "sh /opt/apps/scanner-driver-cumtenn/bin/CumtennScan.sh &";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_MICROTEK))
|
||||||
|
appPath = "sh /opt/apps/scanner-driver-microtek-ex/bin/MicrotekScan.sh &";
|
||||||
|
else if (0 == strcmp(oemName, HGVERSION_OEMNAME_UNIS))
|
||||||
|
appPath = "sh /opt/apps/scanner-driver-unis/bin/UniScan.sh &";
|
||||||
|
else
|
||||||
|
appPath = "sh /opt/apps/scanner-driver-huagao/bin/HuaGoScan.sh &";
|
||||||
|
}
|
||||||
|
|
||||||
|
system(appPath.c_str());
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return HGBASE_ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
HGResult HGAPI HGVersion_GetDriverVersionList(HGVersionMgr mgr, const HGChar* devType, HGVersionInfo** info, HGUInt* count)
|
HGResult HGAPI HGVersion_GetDriverVersionList(HGVersionMgr mgr, const HGChar* devType, HGVersionInfo** info, HGUInt* count)
|
||||||
{
|
{
|
||||||
if (NULL == mgr)
|
if (NULL == mgr)
|
||||||
|
|
|
@ -93,6 +93,10 @@ HGEXPORT HGResult HGAPI HGVersion_CompareVersion(const HGChar* version1, const H
|
||||||
|
|
||||||
HGEXPORT HGResult HGAPI HGVersion_BlackListCheck(HGVersionMgr mgr, const HGChar* devSN, HGBool *inList);
|
HGEXPORT HGResult HGAPI HGVersion_BlackListCheck(HGVersionMgr mgr, const HGChar* devSN, HGBool *inList);
|
||||||
|
|
||||||
|
// APP
|
||||||
|
HGEXPORT HGResult HGAPI HGVersion_GetAppStatus(const HGChar* appName, const HGChar* oemName, HGBool *isRun);
|
||||||
|
HGEXPORT HGResult HGAPI HGVersion_RunApp(const HGChar* appName, const HGChar* oemName);
|
||||||
|
|
||||||
// 驱动
|
// 驱动
|
||||||
HGEXPORT HGResult HGAPI HGVersion_GetDriverVersionList(HGVersionMgr mgr, const HGChar* devType, HGVersionInfo** info, HGUInt* count);
|
HGEXPORT HGResult HGAPI HGVersion_GetDriverVersionList(HGVersionMgr mgr, const HGChar* devType, HGVersionInfo** info, HGUInt* count);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue