linux上完善AppIsRun函数和RunApp函数
This commit is contained in:
parent
6d52429a2a
commit
620189cc07
|
@ -462,7 +462,7 @@ bool AppIsRun()
|
||||||
{
|
{
|
||||||
WCHAR exeFullPath[1024] = { 0 };
|
WCHAR exeFullPath[1024] = { 0 };
|
||||||
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID);
|
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID);
|
||||||
if (NULL != hProcess)
|
if (nullptr != hProcess)
|
||||||
{
|
{
|
||||||
DWORD bufferLen = 1024;
|
DWORD bufferLen = 1024;
|
||||||
::QueryFullProcessImageName(hProcess, 0, exeFullPath, &bufferLen);
|
::QueryFullProcessImageName(hProcess, 0, exeFullPath, &bufferLen);
|
||||||
|
@ -485,7 +485,44 @@ bool AppIsRun()
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
return false;
|
std::string cmd;
|
||||||
|
std::string appPath;
|
||||||
|
#if defined(OEM_HANWANG)
|
||||||
|
cmd = "ps -ef | grep HanvonScan";
|
||||||
|
appPath = "/opt/apps/com.hanvonchina.hanvonscan/files/bin/HanvonScan";
|
||||||
|
#elif defined(OEM_LISICHENG)
|
||||||
|
cmd = "ps -ef | grep LanxumScan";
|
||||||
|
appPath = "/opt/apps/com.lanxumchina.lanxumscan/files/bin/LanxumScan";
|
||||||
|
#else
|
||||||
|
cmd = "ps -ef | grep HuaGoScan";
|
||||||
|
appPath = "/opt/apps/com.huagaochina.huagoscan/files/bin/HuaGoScan";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool ret = false;
|
||||||
|
FILE *fp = popen(cmd.c_str(), "rb");
|
||||||
|
if (nullptr != fp)
|
||||||
|
{
|
||||||
|
fseek(fp, 0, SEEK_END);
|
||||||
|
long size = ftell(fp);
|
||||||
|
fseek(fp, 0, SEEK_SET);
|
||||||
|
|
||||||
|
if (size > 0)
|
||||||
|
{
|
||||||
|
char *data = (char *)malloc(size + 1);
|
||||||
|
if (nullptr != data)
|
||||||
|
{
|
||||||
|
fread(data, 1, size, fp);
|
||||||
|
data[size] = 0;
|
||||||
|
if (nullptr != strstr(data, appPath.c_str()))
|
||||||
|
ret = true;
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -520,10 +557,21 @@ void RunApp()
|
||||||
|
|
||||||
if (!appPath.empty())
|
if (!appPath.empty())
|
||||||
{
|
{
|
||||||
ShellExecuteW(NULL, L"open", appPath.c_str(), NULL, NULL, SW_SHOW);
|
ShellExecuteW(nullptr, L"open", appPath.c_str(), nullptr, nullptr, SW_SHOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
std::string appPath;
|
||||||
|
#if defined(OEM_HANWANG)
|
||||||
|
appPath = "sh /opt/apps/com.hanvonchina.hanvonscan/files/bin/HanvonScan.sh &";
|
||||||
|
#elif defined(OEM_LISICHENG)
|
||||||
|
appPath = "sh /opt/apps/com.lanxumchina.lanxumscan/files/bin/LanxumScan.sh &";
|
||||||
|
#else
|
||||||
|
appPath = "sh /opt/apps/com.huagaochina.huagoscan/files/bin/HuaGoScan.sh &";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
system(appPath);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue