1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516 |
- #include "stdafx.h"
- #include "RvcInitalBase.h"
- #include "logfile.h"
- #include "EnvironmentConfig.h"
- CLogFile* m_log;
- HMODULE g_hDll = NULL;
- LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(_T("kernel32")), "IsWow64Process");
- BOOL IsWow64()
- {
- BOOL bIsWow64 = FALSE;
- if (NULL != fnIsWow64Process)
- {
- if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
- {
- // handle error
- MessageBox(NULL, _T("判断当前操作系统是否是64位系统失败"), NULL, 0);
- }
- }
- return bIsWow64;
- }
- BOOL StrEqualNoCase(const char *s1, const char *s2, int len)
- {
- if (strlen(s1) != strlen(s2))
- return FALSE;
- for (int i = 0; i < len; ++i)
- {
- if (toupper(s1[i]) != toupper(s2[i]))
- return FALSE;
- }
- return TRUE;
- }
- BOOL StrEqual(const char *s1, const char *s2, int len)
- {
- for (int i = 0; i < len; ++i)
- {
- if (toupper(s1[i]) != toupper(s2[i]))
- return FALSE;
- }
- return TRUE;
- }
- BOOL ReadRootConfig(char** pcMachineType, char** pcSite)
- {
- if (NULL == pcMachineType
- || NULL == pcSite)
- {
- return FALSE;
- }
- ifstream is;
- string line = "";
- long curr = 0, end = 0;
- BOOL bFindSec = FALSE;
- BOOL bFindMachineType = FALSE;
- BOOL bFindSite = FALSE;
- char exePath[MAX_PATH];
- if (GetCurrentDirectoryA(MAX_PATH, exePath))
- strcat_s(exePath, "..\\..\\..\\hardwarecfg\\root.ini");
- is.open(ROOT_INI_PATH_C, ios::binary);
- if (!is.is_open())
- is.open(ROOT_INI_PATH_D, ios::binary);
- if (!is.is_open())
- is.open(exePath, ios::binary);
- if (!is.is_open())
- {
- MessageBoxA(NULL, (LPCSTR)("打开root.ini配置失败,请分行维护人员确认此RVC终端是否安装业务应用!"), NULL, 0);
- return FALSE;
- }
-
- is.seekg(0, ios_base::end);
- end = is.tellg();
- is.seekg(0, ios_base::beg);
- do
- {
- if (bFindMachineType && bFindSite)
- {
- is.close();
- return TRUE;
- }
- getline(is, line);
- cout << line << endl;
- if (line[0] == '[')
- {
- size_t secEnd = line.find(']', 1);
- if (secEnd != string::npos)
- {
- string strSec = line.substr(1, secEnd - 1);
- if (StrEqualNoCase(strSec.c_str(), "Terminal", strSec.length()))
- {
- bFindSec = TRUE;
- curr = is.tellg();
- continue;
- }
- }
- }
- else if (((unsigned)(line[0] + 1) > 256) || line[0] == ';')
- {//Chinese and other...
- curr = is.tellg();
- continue;
- }
- else if (isalpha(line[0]))
- {
- if (!bFindSec)
- {
- //没有找到section,继续查找下一行
- curr = is.tellg();
- continue;
- }
- size_t keyPos = line.find('=', 0);
- if (keyPos != string::npos)
- {
- string keyName = line.substr(0, keyPos);
- string keyValue = line.substr(keyPos + 1, line.length() - 1);
- if (StrEqualNoCase(keyName.c_str(), "MachineType", keyName.length()))
- {
- bFindMachineType = TRUE;
- //strcpy((char*)strMachineType.c_str(), keyValue.c_str());
- //memcpy(*pcMachineType, keyValue.c_str(), keyValue.length());
- memcpy(*pcMachineType, keyValue.c_str(), 24);
- cout << keyValue << endl;
- cout << *pcMachineType << endl;
- //cout<<
- curr = is.tellg();
- continue;
- }
- if (StrEqualNoCase(keyName.c_str(), "Site", keyName.length()))
- {
- bFindSite = TRUE;
- //memcpy(*pcSite, keyValue.c_str(), keyValue.length());
- memcpy(*pcSite, keyValue.c_str(), 24);
- curr = is.tellg();
- continue;
- }
- }
- }
- curr = is.tellg();
- } while (curr < end);
- is.close();
- if (!bFindMachineType)
- {
- MessageBoxA(NULL, (LPCSTR)("从root.ini读取MachineType配置项失败,请确认终端是否正确配置!"), NULL, 0);
- return FALSE;
- }
- if (!bFindSite)
- {
- MessageBoxA(NULL, (LPCSTR)("从root.ini读取Site配置项失败,请确认终端是否正确配置!"), NULL, 0);
- return FALSE;
- }
- return TRUE;
- }
- BOOL Execute(TCHAR* szExeName, TCHAR* szCommandLine)
- {
- TCHAR szModule[MAX_PATH] = { 0 };
- GetModuleFileName(NULL, szModule, sizeof(szModule));
- _tcscpy(_tcsrchr(szModule, '\\') + 1, szExeName);
- LPTSTR lpOp;
- lpOp = _T("runas");
- //lpOp = _T("open");
- //HINSTANCE hInst = ShellExecute(NULL, lpOp, szModule, szCommandLine , NULL, SW_HIDE);
- HINSTANCE hInst = ShellExecute(NULL, lpOp, szExeName, szCommandLine, NULL, SW_HIDE);
- if ((DWORD)hInst <= 32)
- {
- CString msg;
- msg.Format(_T("执行%s:%s失败,错误码:%d"), szExeName, szCommandLine, hInst);
- MessageBox(NULL, msg, NULL, 0);
- return FALSE;
- }
- return TRUE;
- }
- RvcInitBase::RvcInitBase()
- :processPath(_T(""))
- {
- m_log = new CLogFile();
- }
- RvcInitBase::RvcInitBase(char *logPath)
- :processPath(_T(""))
- {
- setLogPath(logPath);
-
- }
- void RvcInitBase::setLogPath(const char *logPath)
- {
- char dirpath[300] = "";
- strncpy_s(dirpath, logPath, strlen(logPath));
- for (int i = strlen(logPath) - 1; i > 0; i--)
- {
- if (dirpath[i] == '\\')
- {
- dirpath[i] = '\0';
- break;
- }
- }
- if (!checkDirExist(CString(dirpath)))
- return;
- if (!m_log)
- m_log = new CLogFile(logPath);
- else
- m_log->reset(logPath);
- }
- CString RvcInitBase::getInitError()
- {
- return lastErr;
- }
- BOOL RvcInitBase::isSystem_x64()
- {
- return m_bIsWow64;
- }
- BOOL RvcInitBase::readSysType()
- {
- TCHAR Path[1024] = _T("");
- if (0 == GetCurrentDirectory(1024, Path))
- return FALSE;
- else
- processPath = Path;
- char* pcMachineType, *pcSite;
- string strMachineType, strSite;
- BOOL bRet;
- pcMachineType = new char[24];
- pcSite = new char[24];
- memset(pcMachineType, 0, 24);
- memset(pcSite, 0, 24);
- bRet = ReadRootConfig(&pcMachineType, &pcSite);
- if (!bRet)
- {
- m_log->LOGERROR("从root.ini读取机型和场所失败!");
- delete pcMachineType;
- delete pcSite;
- return FALSE;
- }
- else
- {
- //机型判断
- strMachineType = pcMachineType;
- m_bPad = StrEqual(strMachineType.c_str(), MACHINE_TYPE_PAD, 7);
- //场所判断
- strSite = pcSite;
- m_bFlb = StrEqual(strSite.c_str(), SITE_FLB, 7);
- m_log->LOGERROR("机型:%s, 场所:%s", pcMachineType, pcSite);
- }
- delete pcMachineType;
- delete pcSite;
-
- return TRUE;
- }
- SYSTEM_TYPE RvcInitBase::getSysType()
- {
- if (m_bPad && m_bFlb)
- return PAD_FLB;
- else if (m_bPad && (!m_bFlb))
- return PAD_LIB;
- else if ((!m_bPad) && (!m_bFlb))
- return CMB_LIB;
- else if ((!m_bPad) && m_bFlb)
- return CMB_FLB;
- return ERROR_TYPE;
- }
- BOOL RvcInitBase::softwareInit(char *dirPath)
- {
- m_log->LOGERROR("Begin SoftwareInit");
- if (NULL == m_log)
- {
- lastErr = CString(_T("无法读取Log文件"));
- return FALSE;
- }
- if (!readSysType())
- {
- lastErr = CString(_T("读取root.ini文件失败"));
- return FALSE;
- }
- //创建库文件目录
- DWORD dwAttr = GetFileAttributes(RVC_DIR);
- if (dwAttr == 0xFFFFFFFF) //目录不存在则创建
- {
- if (!CreateDirectory(RVC_DIR, NULL))
- {
- lastErr = CString(_T("创建RVC目录失败!"));
- m_log->LOGERROR("创建RVC目录失败!");
- return FALSE;
- }
-
- }
- dwAttr = GetFileAttributes(_T(IINT_DIR));
- if (dwAttr == 0xFFFFFFFF) //目录不存在则创建
- {
- if (!CreateDirectory(_T(IINT_DIR), NULL))
- {
- lastErr = CString(_T("创建SystemInit目录失败!"));
- m_log->LOGERROR("创建SystemInit目录失败!");
- return FALSE;
- }
-
- }
- m_bIsWow64 = IsWow64();
- //停止系统服务
- KillSystemService();
- //拷贝库文件
- if (!CopyAllDll(dirPath))
- {
- lastErr = CString(_T("Dll文件拷贝失败"));
- m_log->LOGERROR("Dll文件拷贝失败");
- return FALSE;
- }
- else
- m_log->LOGERROR("所有Dll文件拷贝成功");
- //加载库文件
- for (int i = 0; i < 40; i++)
- {
- Sleep(100);
- if (NULL != (g_hDll = LoadLibrary(DLL_FILE)))
- break;
- }
- if (g_hDll == NULL)
- {
- lastErr = CString(_T("LoadLibrary C:\\RVC\\SystemInit\\CmbPadDll.dll 失败!"));
- m_log->LOGERROR("LoadLibrary C:\\RVC\\SystemInit\\CmbPadDll.dll 失败!");
- return FALSE;
- }
- return TRUE;
-
- }
- RvcInitBase::~RvcInitBase()
- {
- if (m_log)
- {
- delete m_log;
- m_log = NULL;
- }
- }
- BOOL RvcInitBase::checkSystemLogon()
- {
- LONG lRet;
- HKEY logonKey;
- TCHAR szKeyPath[MAX_PATH] = _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\Credential Providers\\{75A22DF0-B81D-46ed-B119-CD30507BD615}");
- if (ERROR_SUCCESS != (lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, CString(szKeyPath), 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, &logonKey)))
- {
- m_log->LOGERROR("打开注册表HKEY_LOCAL_MACHINE\\%s失败,错误码:%d", szKeyPath, lRet);
- return FALSE;
- }
- else
- {
- m_log->LOGERROR("删除祖册表HKEY_LOCAL_MACHINE\\%s成功", szKeyPath);
- }
- return TRUE;
- }
- BOOL RvcInitBase::SetSystemLogon()
- {
- HKEY hKey;
- LONG lRet;
- DWORD dwDisposition;
- TCHAR szKeyPath[MAX_PATH] = _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\Credential Providers\\{75A22DF0-B81D-46ed-B119-CD30507BD615}");
- lRet = ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKeyPath, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS | KEY_WOW64_64KEY, NULL, &hKey, &dwDisposition);
- if (ERROR_SUCCESS != lRet)
- {
- m_log->LOGERROR("添加注册表HKEY_LOCAL_MACHINE\\%s失败,错误码:%d", szKeyPath, lRet);
- return FALSE;
- }
- else
- {
- TCHAR szKeyValue[MAX_PATH] = _T("SampleHardwareEventCredentialProvider");
- lRet = RegSetValueEx(hKey, NULL, 0, REG_SZ, (BYTE*)szKeyValue, _tcslen(szKeyValue) * sizeof(TCHAR) + 1);
- if (ERROR_SUCCESS != lRet)
- {
- m_log->LOGERROR("添加注册表HKEY_LOCAL_MACHINE\\%s失败,错误码:%d", szKeyValue, lRet);
- return FALSE;
- }
- }
- RegCloseKey(hKey);
- TCHAR szKeyPath2[MAX_PATH] = _T("CLSID\\{75A22DF0-B81D-46ed-B119-CD30507BD615}");
- lRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, szKeyPath2, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS | KEY_WOW64_64KEY, NULL, &hKey, &dwDisposition);
- if (ERROR_SUCCESS != lRet)
- {
- m_log->LOGERROR("添加注册表HKEY_CLASSES_ROOT\\%s失败,错误码:%d", szKeyPath2, lRet);
- return FALSE;
- }
- else
- {
- TCHAR szKeyValue[MAX_PATH] = _T("SampleHardwareEventCredentialProvider");
- lRet = RegSetValueEx(hKey, NULL, 0, REG_SZ, (BYTE*)szKeyValue, _tcslen(szKeyValue) * sizeof(TCHAR) + 1);
- if (ERROR_SUCCESS != lRet)
- {
- m_log->LOGERROR("写注册表HKEY_CLASSES_ROOT\\%s键值失败,错误码:%d", szKeyValue, lRet);
- return FALSE;
- }
- }
- RegCloseKey(hKey);
- TCHAR szKeyPath3[MAX_PATH] = _T("CLSID\\{75A22DF0-B81D-46ed-B119-CD30507BD615}\\InprocServer32");
- lRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, szKeyPath3, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS | KEY_WOW64_64KEY, NULL, &hKey, &dwDisposition);
- if (ERROR_SUCCESS != lRet)
- {
- m_log->LOGERROR("添加注册表HKEY_CLASSES_ROOT\\%s失败,错误码:%d", szKeyPath3, lRet);
- return FALSE;
- }
- else
- {
- TCHAR szKeyValue[MAX_PATH] = _T("SampleHardwareEventCredentialProvider.dll");
- //lRet = RegSetValueEx(hKey, NULL, 0, REG_SZ, (BYTE*)szKeyValue, sizeof(szKeyValue));
- lRet = RegSetValueEx(hKey, NULL, 0, REG_SZ, (BYTE*)szKeyValue, _tcslen(szKeyValue) * sizeof(TCHAR) + 1);
- if (ERROR_SUCCESS != lRet)
- {
- m_log->LOGERROR("写注册表HKEY_CLASSES_ROOT\\%s键值失败,错误码:%d", szKeyValue, lRet);
- return FALSE;
- }
- TCHAR szKeyValue2[MAX_PATH] = _T("Apartment");
- //lRet = RegSetValueEx(hKey, "ThreadingModel", 0, REG_SZ, (BYTE*)szKeyValue2, sizeof(szKeyValue2));
- lRet = RegSetValueEx(hKey, _T("ThreadingModel"), 0, REG_SZ, (BYTE*)szKeyValue2, _tcslen(szKeyValue2) * sizeof(TCHAR) + 1);
- if (ERROR_SUCCESS != lRet)
- {
- m_log->LOGERROR("写注册表HKEY_CLASSES_ROOT\\%s键值失败,错误码:%d", szKeyValue2, lRet);
- return FALSE;
- }
- }
- RegCloseKey(hKey);
- return TRUE;
- }
- BOOL RvcInitBase::DisableSystemLogon()
- {
- HKEY logonKey, startKey = NULL;
- LONG lRet;
- TCHAR szKeyPath[MAX_PATH] = _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\Credential Providers\\{75A22DF0-B81D-46ed-B119-CD30507BD615}");
- if (ERROR_SUCCESS != (lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKeyPath, 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, &startKey)))
- m_log->LOGERROR("打开HKEY_LOCAL_MACHINE\\%s失败,错误码:%d", szKeyPath, lRet);
- else
- {
- RegCloseKey(startKey);
- if (ERROR_SUCCESS != (lRet = ::RegDeleteKeyEx(HKEY_LOCAL_MACHINE, szKeyPath, KEY_ALL_ACCESS | KEY_WOW64_64KEY, 0)))
- {
- m_log->LOGERROR("删除注册表HKEY_LOCAL_MACHINE\\%s失败,错误码:%d", szKeyPath, lRet);
- return FALSE;
- }
- else
- {
- m_log->LOGERROR("删除祖册表HKEY_LOCAL_MACHINE\\%s成功", szKeyPath);
- }
- }
-
-
- TCHAR logonPath[MAX_PATH] = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon");
- TCHAR logonStr[MAX_PATH] = _T("explorer.exe");
-
- if (ERROR_SUCCESS != (lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, logonPath, 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, &logonKey)))
- {
- m_log->LOGERROR("打开HKEY_LOCAL_MACHINE\\%s失败,错误码:%d", logonKey, lRet);
- return FALSE;
- }
- if (ERROR_SUCCESS != (lRet = ::RegSetValueEx(logonKey, _T("Shell"), 0, REG_SZ, (BYTE*)logonStr, _tcslen(logonStr) * sizeof(TCHAR) + 1)))
- {
- m_log->LOGERROR("写注册表HKEY_LOCAL_MACHINE\\%s\\%s键值失败,错误码:%d", logonKey, logonStr, lRet);
- return FALSE;
- }
- RegCloseKey(logonKey);
- return TRUE;
- }
- BOOL RvcInitBase::SetSystemStart()
- {
- CString strExePath(IINT_DIR);
- strExePath += CString(_T("\\InstallServer.exe"));
- //BOOL bRet = Execute(_T("InstallServer.exe"),NULL);
- BOOL bRet = Execute(strExePath.GetBuffer(), NULL);
- if (!bRet)
- {
- m_log->LOGERROR("安装CmbService系统服务失败.");
- return FALSE;
- }
- return TRUE;
- }
- BOOL RvcInitBase::DisableSystemStart()
- {
- if (isServiceExist(_T("CmbRvcInitialService")))
- {
- int iRet = system("sc delete CmbRvcInitialService");
- if (ERROR_SUCCESS != iRet)
- m_log->LOGERROR("删除CmbRvcInitialService系统服务失败");
- else
- m_log->LOGERROR("删除CmbRvcInitialService系统服务成功");
- }
-
- pDisableKeyboard DisableKeyboard = (pDisableKeyboard)GetProcAddress(g_hDll, "DisableKeyboard");
- if (NULL != DisableKeyboard)
- {
- DisableKeyboard(FALSE);
- m_log->LOGERROR("启用键盘成功");
- }
- else
- {
- m_log->LOGERROR("启用键盘失败");
- }
- pWlanConnect WlanConnect = (pWlanConnect)GetProcAddress(g_hDll, "WlanConnect");
- if (NULL != WlanConnect)
- {
- DWORD dwRet = WlanConnect(TRUE, NET_TYPE_ETHERNET);
- if (ERROR_SUCCESS != dwRet)
- {
- m_log->LOGERROR("启用ethernet 失败, errcode= %d", dwRet);
- }
- else
- {
- m_log->LOGERROR("启用ethernet 成功");
- }
- dwRet = WlanConnect(TRUE, NET_TYPE_WIRELESS);
- if (ERROR_SUCCESS != dwRet)
- {
- m_log->LOGERROR("启用wireless 失败, errcode= %d", dwRet);
- }
- else
- {
- m_log->LOGERROR("启用wireless 成功");
- }
- dwRet = WlanConnect(TRUE, NET_TYPE_3G);
- if (ERROR_SUCCESS != dwRet)
- {
- m_log->LOGERROR("启用3G network 失败, errcode= %d", dwRet);
- }
- else
- {
- m_log->LOGERROR("启用3G network 成功");
- }
- dwRet = WlanConnect(TRUE, NET_TYPE_4G);
- if (ERROR_SUCCESS != dwRet)
- {
- m_log->LOGERROR("启用4G network 失败, errcode= %d", dwRet);
- }
- else
- {
- m_log->LOGERROR("启用4G network成功");
- }
- pDisableBluetooth DisableBluetooth = (pDisableBluetooth)GetProcAddress(g_hDll, "DisableBluetooth");
- if (NULL == DisableBluetooth)
- {
- m_log->LOGERROR("GetProcAddress DisableBluetooth failed");
- }
- else
- {
- dwRet = DisableBluetooth(FALSE);
- if (ERROR_SUCCESS != dwRet)
- {
- m_log->LOGERROR("启用Bluetooth失败, errcode= %d", dwRet);
- }
- else
- {
- m_log->LOGERROR("启用Bluetooth成功");
- }
- }
- }
- else
- {
- m_log->LOGERROR("GetProcAddress WlanConnect from CmbPadDll.dll失败");
- }
- return TRUE;
- }
- BOOL RvcInitBase::KillSystemService()
- {
- int iRet = SYSTEM_ON(CString(_T("sc stop CmbRvcInitialService")));
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("停止CmbRvcInitialService系统服务失败");
- }
- else
- {
- m_log->LOGERROR("停止CmbRvcInitialService系统服务成功");
- }
- return TRUE;
- }
- BOOL RvcInitBase::FileCopy(const char* pcSourceFile, const char* pcDestDir)
- {
- if (NULL == pcSourceFile || NULL == pcDestDir)
- return FALSE;
- PVOID OldValue = NULL;
- CString logMsg;
- string tempFilePath, tempFileName;
- CString srcFile, dstDir;
- MultiByteToCString(const_cast<char*>(pcSourceFile), strlen(pcSourceFile) + 1, srcFile);
- MultiByteToCString(const_cast<char*>(pcDestDir), strlen(pcDestDir) + 1, dstDir);
- if (!checkFileExist(srcFile) || !checkDirExist(dstDir))//对于源文件,只需要读权限
- {
- logMsg.Format(_T("%s文件不存在"), srcFile);
- char tempStr[1024];
- CStringToMultiByte(logMsg, tempStr, logMsg.GetLength() + 1);
- m_log->LOGERROR(tempStr);
- return FALSE;
- }
- tempFilePath = string(pcSourceFile);
- int pos = tempFilePath.find_last_of('\\');
- tempFileName = string(tempFilePath.substr(pos + 1));
- CString desFilePath = dstDir + CString("\\") + CString(tempFileName.data());
- if (checkFileExist(desFilePath) && !checkFileOcuppy(desFilePath))//对于目的文件,需要读写权限
- {
- logMsg.Format(_T("%s文件已存在,且文件被占用"), desFilePath);
- char tempStr[1024];
- CStringToMultiByte(logMsg, tempStr, logMsg.GetLength() + 1);
- m_log->LOGERROR(tempStr);
- return TRUE;
- }
- //如果是64位系统,需取消文件的重定向,并在完成指定功能后恢复程序文件重定向
- //否则,会被重定向到Syswow64目录下(比如想拷贝文件到system32时,会自动拷贝到Syswow64目录下)
- if (m_bIsWow64)
- {
- if (!Wow64DisableWow64FsRedirection(&OldValue))
- {
- m_log->LOGERROR("64位系统时,调用Wow64DisableWow64FsRedirection文件重定向失败");
- return FALSE;
- }
- }
- CString strCmd = _T("copy /y ") + CString(pcSourceFile) + CString(" ") + desFilePath;
- int iRet = SYSTEM_ON(strCmd);
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("%s拷贝到%s失败", pcSourceFile, pcDestDir);
- return FALSE;
- }
- else
- {
- m_log->LOGERROR("%s拷贝到%s成功", pcSourceFile, pcDestDir);
- }
- if (m_bIsWow64)
- {
- if (FALSE == Wow64RevertWow64FsRedirection(OldValue))
- {
- m_log->LOGERROR("64位系统时,调用Wow64RevertWow64FsRedirection恢复文件重定向失败");
- return FALSE;
- }
- }
- return TRUE;
- }
- BOOL RvcInitBase::DirCopy(const char* pcSourceDir, const char* pcDestDir)
- {
- PVOID OldValue = NULL;
- //如果是64位系统,需取消文件的重定向,并在完成指定功能后恢复程序文件重定向
- //否则,会被重定向到Syswow64目录下(比如想拷贝文件到system32时,会自动拷贝到Syswow64目录下)
- if (m_bIsWow64)
- {
- if (!Wow64DisableWow64FsRedirection(&OldValue))
- {
- m_log->LOGERROR("64位系统时,调用Wow64DisableWow64FsRedirection文件重定向失败");
- return FALSE;
- }
- }
- CStringA strCmd("xcopy /E /I /y ");
- strCmd += pcSourceDir;
- strCmd += " ";
- strCmd += pcDestDir;
- int iRet = SYSTEM_ON(strCmd);
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("%s拷贝到%s失败", pcSourceDir, pcDestDir);
- return FALSE;
- }
- else
- {
- m_log->LOGERROR("%s拷贝到%s成功", pcSourceDir, pcDestDir);
- }
- if (m_bIsWow64)
- {
- if (FALSE == Wow64RevertWow64FsRedirection(OldValue))
- {
- m_log->LOGERROR("64位系统时,调用Wow64RevertWow64FsRedirection恢复文件重定向失败");
- return FALSE;
- }
- }
- return TRUE;
- }
- /* 大机版接口 begin */
- //设置shell脚本运行权限
- BOOL RvcInitBase::EnableShell()
- {
- int iRet = system("powershell Set-ExecutionPolicy RemoteSigned");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("设置shell脚本运行权限失败");
- return FALSE;
- }
- return TRUE;
- }
- //启用/禁用F8进入安全模式
- BOOL RvcInitBase::EnableF8()
- {
- int iRet = system("bcdedit.exe -set {globalsettings} advancedoptions ture");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("启用F8进入安全模式失败");
- return FALSE;
- }
- return TRUE;
- }
- BOOL RvcInitBase::DisableF8()
- {
- int iRet = system("bcdedit.exe -set {globalsettings} advancedoptions FALSE");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("禁用F8进入安全模式失败");
- return FALSE;
- }
- return TRUE;
- }
- //开启/关闭EmbeddedLockdown服务
- BOOL RvcInitBase::EnableELM()
- {
- int iRet = system("Dism /online /Enable-Feature /FeatureName:ISKU-EmbeddedLockdown /all");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("开启EmbeddedLockdown失败");
- return FALSE;
- }
- return TRUE;
- }
- BOOL RvcInitBase::DisableELM()
- {
- int iRet = system("Dism /online /Disable-Feature /FeatureName:ISKU-EmbeddedLockdown");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("关闭EmbeddedLockdown失败");
- return FALSE;
- }
- return TRUE;
- }
- //开启/关闭键盘过滤服务
- BOOL RvcInitBase::EnableKeyBoardFilter()
- {
- int iRet = system("Dism /online /Enable-Feature /FeatureName:ISKU-KeyboardFilter /all");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("开启键盘过滤失败");
- return FALSE;
- }
- return TRUE;
- }
- BOOL RvcInitBase::DisableKeyBoardFilter()
- {
- int iRet = system("Dism /online /Disable-Feature /FeatureName:ISKU-KeyboardFilter");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("关闭键盘过滤失败");
- return FALSE;
- }
- return TRUE;
- }
- //启用/屏蔽特殊按键,除了数字和字母键外的其它所有按键
- BOOL RvcInitBase::EnableKey()
- {
- return TRUE;
- }
- BOOL RvcInitBase::DisableKey()
- {
- return TRUE;
- }
- //开启/关闭shellLauncher服务
- BOOL RvcInitBase::EnableShellLauncher()
- {
- int iRet = system("Dism /online /Enable-Feature /FeatureName:ISKU-Shell-Launcher /all");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("开启shellLauncher服务失败");
- return FALSE;
- }
- return TRUE;
- }
- BOOL RvcInitBase::DisableShellLauncher()
- {
- int iRet = system("Dism /online /Disable-Feature /FeatureName:ISKU-Shell-Launcher");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("关闭shellLauncher服务失败");
- return FALSE;
- }
- return TRUE;
- }
- //设置启动程序
- BOOL RvcInitBase::SetCustomerShell()
- {
- return TRUE;
- }
- //开启/关闭磁盘保护服务
- BOOL RvcInitBase::EnableUWF()
- {
- int iRet = system("Dism /online /Enable-Feature /FeatureName:ISKU-UnifiedWriteFilter /all");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("开启磁盘保护服务失败");
- return FALSE;
- }
- return TRUE;
- }
- BOOL RvcInitBase::DisableUWF()
- {
- int iRet = system("Dism /online /Disable-Feature /FeatureName:ISKU-UnifiedWriteFilter");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("关闭磁盘保护服务失败");
- return FALSE;
- }
- return TRUE;
- }
- //开启/关闭C盘保护
- BOOL RvcInitBase::EnableProtectC()
- {
- int iRet = system("uwfmgr.exe filter enable");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("开启硬盘保护失败");
- return FALSE;
- }
- iRet = system("uwfmgr.exe volume protect c:");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("开启C盘保护失败");
- return FALSE;
- }
- return TRUE;
- }
- BOOL RvcInitBase::DisableProtectC()
- {
- int iRet = system("uwfmgr.exe volume Unprotect c:");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("关闭C盘保护失败");
- return FALSE;
- }
- iRet = system("uwfmgr.exe filter disable");
- if (ERROR_SUCCESS != iRet)
- {
- m_log->LOGERROR("关闭硬盘保护失败");
- return FALSE;
- }
- return TRUE;
- }
- BOOL RvcInitBase::SetEvn()
- {
- return DisableF8() && EnableELM() && EnableKeyBoardFilter() && EnableShellLauncher();
- }
- //设置组策略
- BOOL RvcInitBase::EnablePolicy()
- {
- PVOID OldValue = NULL;
- if (m_bIsWow64)
- {
- if (!Wow64DisableWow64FsRedirection(&OldValue))
- {
- m_log->LOGERROR("64位系统时,调用Wow64DisableWow64FsRedirection文件重定向失败");
- return FALSE;
- }
- }
- //调用设置组策略脚本
- HINSTANCE hNewExe = ShellExecuteA(NULL, "runas", "C:\\RVC\\SystemInit\\EnablePolicy.bat", NULL, NULL, SW_SHOW);
- if ((DWORD)hNewExe <= 32)
- {
- m_log->LOGERROR("组策略设置失败");
- return FALSE;
- }
- if (m_bIsWow64)
- {
- if (FALSE == Wow64RevertWow64FsRedirection(OldValue))
- {
- m_log->LOGERROR("64位系统时,调用Wow64RevertWow64FsRedirection恢复文件重定向失败");
- return FALSE;
- }
- }
- return TRUE;
- }
- BOOL RvcInitBase::DisblePolicy()
- {
- PVOID OldValue = NULL;
- if (m_bIsWow64)
- {
- if (!Wow64DisableWow64FsRedirection(&OldValue))
- {
- m_log->LOGERROR("64位系统时,调用Wow64DisableWow64FsRedirection文件重定向失败");
- return FALSE;
- }
- }
- //调用删除组策略脚本
- HINSTANCE hNewExe = ShellExecuteA(NULL, "runas", "C:\\RVC\\SystemInit\\DisablePolicy.bat", NULL, NULL, SW_SHOW);
- if ((DWORD)hNewExe <= 32)
- {
- m_log->LOGERROR("取消组策略失败");
- return FALSE;
- }
- if (m_bIsWow64)
- {
- if (FALSE == Wow64RevertWow64FsRedirection(OldValue))
- {
- m_log->LOGERROR("64位系统时,调用Wow64RevertWow64FsRedirection恢复文件重定向失败");
- return FALSE;
- }
- }
- return TRUE;
- }
- BOOL RvcInitBase::CopyAllDll(char *dirPath)
- {
- PVOID OldValue = NULL;
- BOOL bRet = FALSE;
- char pcExePath[2000];
- //如果是64位系统,需取消文件的重定向,并在完成指定功能后恢复程序文件重定向
- //否则,会被重定向到Syswow64目录下(比如_access检测文件是否存在,会检测到Syswow64目录,拷贝文件也如此)
- if (m_bIsWow64)
- {
- if (!Wow64DisableWow64FsRedirection(&OldValue))
- {
- m_log->LOGERROR("64位系统时,调用Wow64DisableWow64FsRedirection文件重定向失败");
- return FALSE;
- }
- }
- //得到当前的工作路径
- if (NULL == dirPath)
- {
- if (0 == GetCurrentDirectoryA(2000, pcExePath))
- {
- m_log->LOGERROR("_getcwderror");
- return FALSE;
- }
- }
- else
- memcpy(pcExePath, dirPath, strlen(dirPath) + 1);
-
- CStringA strExePath(pcExePath);
- CStringA strFilePath(strExePath);
- checkDirExist(CString(_T("C:\\RVC")));
- //拷贝系统登陆模块相关库文件,需要区分32/64位
- CStringA headDir = "RvcInit";
- if (!m_bIsWow64)
- {
- //32位系统
- strFilePath += "\\" + headDir + "\\32\\msvcr100.dll";
- bRet = FileCopy(strFilePath.GetBuffer(), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\32\\msvcr100d.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
-
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\32\\msvcp100d.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\32\\libeay32.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\32\\VerifyCertificate.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\32\\USBKeyAPI.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\32\\WinSystemLogon.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\32\\SampleHardwareEventCredentialProvider.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\32\\lsrunas.exe";
- bRet = FileCopy(strFilePath.GetBuffer(0), EXE_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\32\\devcon.exe";
- bRet = FileCopy(strFilePath.GetBuffer(0), strExePath.GetBuffer(0));
- if (!bRet)
- return FALSE;
- bRet = FileCopy(strFilePath.GetBuffer(0), IINT_DIR);
- if (!bRet)
- return FALSE;
- }
- else
- {
- //64位系统
- strFilePath += "\\" + headDir + "\\64\\msvcr100.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\64\\msvcr100d.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\64\\msvcp100d.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\64\\libeay32.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\64\\VerifyCertificate.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\64\\USBKeyAPI.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\64\\WinSystemLogon.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\64\\SampleHardwareEventCredentialProvider.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), DLL_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\64\\lsrunas.exe";
- bRet = FileCopy(strFilePath.GetBuffer(0), EXE_PATH);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\64\\devcon.exe";
- bRet = FileCopy(strFilePath.GetBuffer(0), IINT_DIR);
- if (!bRet)
- return FALSE;
- bRet = FileCopy(strFilePath.GetBuffer(0), strExePath.GetBuffer(0));
- if (!bRet)
- return FALSE;
- }
- //拷贝系统服务相关库文件和配置文件
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\InstallServer.exe";
- bRet = FileCopy(strFilePath.GetBuffer(0), IINT_DIR);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\WinServer.exe";
- bRet = FileCopy(strFilePath.GetBuffer(0), IINT_DIR);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\CmbPadDll.dll";
- bRet = FileCopy(strFilePath.GetBuffer(0), IINT_DIR);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\Register.reg";
- bRet = FileCopy(strFilePath.GetBuffer(0), IINT_DIR);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\Unregister.reg";
- bRet = FileCopy(strFilePath.GetBuffer(0), IINT_DIR);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\AutoStartSpshell.exe";
- bRet = FileCopy(strFilePath.GetBuffer(0), IINT_DIR);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\version.txt";
- bRet = FileCopy(strFilePath.GetBuffer(0), IINT_DIR);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\EnablePolicy.bat";
- bRet = FileCopy(strFilePath.GetBuffer(0), IINT_DIR);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\DisablePolicy.bat";
- bRet = FileCopy(strFilePath.GetBuffer(0), IINT_DIR);
- if (!bRet)
- return FALSE;
- strFilePath = strExePath;
- strFilePath += "\\" + headDir + "\\UserPolicy";
- bRet = DirCopy(strFilePath.GetBuffer(0), IINT_DIR);
- if (!bRet)
- return FALSE;
- if (m_bIsWow64)
- {
- if (FALSE == Wow64RevertWow64FsRedirection(OldValue))
- {
- m_log->LOGERROR("64位系统时,调用Wow64RevertWow64FsRedirection恢复文件重定向失败");
- return FALSE;
- }
- }
- return TRUE;
- }
- BOOL RvcInitBase::Initial_RVC(CString &lastErr)
- {
- //设置组策略
- BOOL bRet = EnablePolicy();
- if (!bRet)
- {
- lastErr = CString(_T("组策略设置失败"));
- m_log->LOGERROR("组策略设置失败");
- return FALSE;
- }
- else
- m_log->LOGERROR("设置组策略成功");
- if (g_hDll != NULL)
- {
- //禁用休眠
- pSetSleep SetSleep = (pSetSleep)GetProcAddress(g_hDll, "SetSleep");
- if (NULL != SetSleep)
- {
- SetSleep(0);
- m_log->LOGERROR("禁用休眠成功");
- }
- //禁用屏保
- pSetScrnsaver SetScrnsaver = (pSetScrnsaver)GetProcAddress(g_hDll, "SetScrnsaver");
- if (NULL != SetScrnsaver)
- {
- SetScrnsaver(9999999);
- m_log->LOGERROR("禁用屏保成功");
- }
- //IE缓存清理
- pIEDeleteHistory IEDeleteHistory = (pIEDeleteHistory)GetProcAddress(g_hDll, "IEDeleteHistory");
- if (NULL != IEDeleteHistory)
- {
- IEDeleteHistory(TRUE);
- m_log->LOGERROR("IE缓存自动清理成功");
- }
- //开机启动设置
- bRet = SetSystemStart();
- if (!bRet)
- {
- lastErr = CString(_T("开机以超级用户启动spshell设置失败"));
- m_log->LOGERROR("开机以超级用户启动spshell设置失败");
- return FALSE;
- }
- else
- m_log->LOGERROR("开机以超级用户启动spshell设置成功");
- //系统登陆设置
- bRet = SetSystemLogon();
- if (!bRet)
- {
- lastErr = CString(_T("系统登陆设置失败"));
- m_log->LOGERROR("系统登陆设置失败");
- return FALSE;
- }
- else
- m_log->LOGERROR("系统登陆设置成功");
- }
- else
- {
- lastErr = CString(_T("加载CmbPadDll.dll失败"));
- m_log->LOGERROR("加载CmbPadDll.dll失败");
- return FALSE;
- }
- return TRUE;
- }
- //行内大机
- BOOL RvcInitBase::InitialBig_Lib(CString &lastErr)
- {
- m_log->LOGERROR("开始系统初始化. 机型:大机, 使用场所:LIB(行内)");
- return Initial_RVC(lastErr);
- }
- BOOL RvcInitBase::DisableInitialBig_Lib()
- {
- BOOL bRet = FALSE;
- if (g_hDll != NULL)
- {
- //禁用休眠
- pSetSleep SetSleep = (pSetSleep)GetProcAddress(g_hDll, "SetSleep");
- if (NULL != SetSleep)
- SetSleep(0);
- else
- return FALSE;
- //禁用屏保
- pSetScrnsaver SetScrnsaver = (pSetScrnsaver)GetProcAddress(g_hDll, "SetScrnsaver");
- if (NULL != SetScrnsaver)
- SetScrnsaver(9999999);
- else
- return FALSE;
- //IE缓存清理
- pIEDeleteHistory IEDeleteHistory = (pIEDeleteHistory)GetProcAddress(g_hDll, "IEDeleteHistory");
- if (NULL != IEDeleteHistory)
- IEDeleteHistory(FALSE);
- else
- return FALSE;
- }
- //取消开机启动
- if (!DisableSystemStart())
- return FALSE;
- //取消系统登陆
- if (!DisableSystemLogon())
- return FALSE;
- return TRUE;
- }
- BOOL RvcInitBase::testFun()
- {
- return SetSystemLogon();
- }
- //行内PAD
- BOOL RvcInitBase::InitialPad_Lib(CString &lastErr)
- {
- m_log->LOGERROR("开始系统初始化. 机型:Pad, 使用场所:LIB(行内)");
- return Initial_RVC(lastErr);
- }
- BOOL RvcInitBase::DisableInitialPad_Lib()
- {
- BOOL bRet = FALSE;
- if (g_hDll != NULL)
- {
- //禁用休眠
- pSetSleep SetSleep = (pSetSleep)GetProcAddress(g_hDll, "SetSleep");
- if (NULL != SetSleep)
- SetSleep(0);
- else
- return FALSE;
- //禁用屏保
- pSetScrnsaver SetScrnsaver = (pSetScrnsaver)GetProcAddress(g_hDll, "SetScrnsaver");
- if (NULL != SetScrnsaver)
- SetScrnsaver(9999999);
- else
- return FALSE;
- //IE缓存清理
- pIEDeleteHistory IEDeleteHistory = (pIEDeleteHistory)GetProcAddress(g_hDll, "IEDeleteHistory");
- if (NULL != IEDeleteHistory)
- IEDeleteHistory(FALSE);
- else
- return FALSE;
- }
- //取消开机启动
- if (!DisableSystemStart())
- return FALSE;
- //取消系统登陆
- if (!DisableSystemLogon())
- return FALSE;
- return TRUE;
- }
- //外携PAD
- BOOL RvcInitBase::InitialPad_Flb(CString &lastErr)
- {
- m_log->LOGERROR("开始系统初始化. 机型:Pad, 使用场所:FLB(行外)");
- return Initial_RVC(lastErr);
- }
- BOOL RvcInitBase::DisableInitialPad_Flb()
- {
- BOOL bRet = FALSE;
- if (g_hDll != NULL)
- {
- //取消休眠
- pSetSleep SetSleep = (pSetSleep)GetProcAddress(g_hDll, "SetSleep");
- if (NULL != SetSleep)
- {
- SetSleep(0);
- m_log->LOGERROR("取消自动休眠成功");
- }
- else
- m_log->LOGERROR("取消自动休眠失败");
- //禁用屏保
- pSetScrnsaver SetScrnsaver = (pSetScrnsaver)GetProcAddress(g_hDll, "SetScrnsaver");
- if (NULL != SetScrnsaver)
- {
- SetScrnsaver(9999999);
- m_log->LOGERROR("取消自动屏保成功");
- }
- else
- m_log->LOGERROR("取消自动屏保失败");
- //IE缓存清理
- pIEDeleteHistory IEDeleteHistory = (pIEDeleteHistory)GetProcAddress(g_hDll, "IEDeleteHistory");
- if (NULL != IEDeleteHistory)
- {
- IEDeleteHistory(FALSE);
- m_log->LOGERROR("取消IE缓存清理成功");
- }
- else
- m_log->LOGERROR("取消IE缓存清理失败");
- }
- //取消开机启动
- if (!DisableSystemStart())
- return FALSE;
- //取消系统登陆
- if (!DisableSystemLogon())
- return FALSE;
- return TRUE;
- }
- BOOL RvcInitBase::checkInitByType(TCHAR *lastErr)
- {
- BOOL result = FALSE;
- switch (getSysType())
- {
- case PAD_FLB:
- case PAD_LIB:
- case CMB_LIB:
- result = checkSystemLogon();
- if (!result) _tcscpy(lastErr, _T("系统未进行主框架初始化"));
- return result;
- case CMB_FLB:
- _tcscpy(lastErr, _T("当前版本不支持主框架初始化"));
- return FALSE;
- default:
- _tcscpy(lastErr, _T("未知终端类型"));
- return FALSE;
- }
- }
- void getVersionPath(TCHAR *versionPath)
- {
- TCHAR pathbuf[1024] = _T("");
- int pathlen = ::GetModuleFileName(NULL, pathbuf, 1024);//获得GuiConsole路径
- // 替换掉单杠
- int times = 0;
- while (pathlen > 0 && times != 2)
- {
- if (pathbuf[--pathlen] == '\\')
- times++;
- }
- pathbuf[++pathlen] = '\0';
- if (NULL == versionPath)
- return;
- else
- memcpy(versionPath, pathbuf, (pathlen + 1) * sizeof(TCHAR));
- }
- BOOL getLogPath(char *generatePath, const TCHAR *dirName, const TCHAR *fileName)
- {
- TCHAR pathBuf[1024];
- getVersionPath(pathBuf);
- CString dirPath = CString(pathBuf) + CString(dirName);
- if (!checkDirExist(dirPath))
- return FALSE;
- CString logName = dirPath + CString(fileName);
- CStringToMultiByte(logName, generatePath, logName.GetLength() + 1);
- return TRUE;
- }
|