瀏覽代碼

Z991239-6340 #comment 把windows的os信息获取移动到VtmLoader启动时

oilyang 4 月之前
父節點
當前提交
449ef2a21f

+ 1 - 26
Module/mod_healthmanager/HealthManagerFSM.cpp

@@ -50,9 +50,7 @@ enum EntityOP
 ErrorCodeEnum CHealthManagerFSM::Initial()
 {
 	m_netList.Init(0);
-#if defined(RVC_OS_WIN)
-	SaveOsVersion();
-#endif
+
 	CSmartPointer<IEntityFunction> pFunc = GetEntityBase()->GetFunction();
 	CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
 	CSmartPointer<IAsynWaitSp> spWait;
@@ -632,29 +630,6 @@ void CHealthManagerFSM::PostProcessAfterUpgrade()
 		}
 	}
 }
-void CHealthManagerFSM::SaveOsVersion()
-{
-#if defined(RVC_OS_WIN)
-	CSimpleStringA runInfoPath;
-	ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->GetPath("runinfo", runInfoPath);
-	if (eErr != Error_Succeed) {
-		DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("GetPath runinfo error=%d.", eErr);
-		return;
-	}
-	runInfoPath += "\\runcfg\\osverion";
-	ifstream is;
-	is.open(runInfoPath.GetData(), ios::binary);
-	if (!is.is_open())
-	{
-		DWORD dwErr = GetLastError();
-		DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("open runcfg\\osverion file failed. [%d]", dwErr);
-		CSimpleStringA csCmd;
-		csCmd = CSimpleStringA::Format("cmd /c ver >%s", runInfoPath);
-		WinExec((LPCSTR)csCmd, SW_HIDE);
-	}
-#endif
-	return;
-}
 CSimpleStringA CHealthManagerFSM::GetOsVersion()
 {
 #if defined(RVC_OS_WIN)

+ 0 - 1
Module/mod_healthmanager/HealthManagerFSM.h

@@ -204,7 +204,6 @@ private:
 	virtual ErrorCodeEnum AsyncContinueEntity(const char *entity_name, void *pData);
 	virtual ErrorCodeEnum AsyncTerminateEntity(const char *entity_name, void *pData);
 	virtual void OnAnswer(CSmartPointer<IAsynWaitSp> pAsynWaitSp);
-	void SaveOsVersion();
 	CSimpleStringA GetOsVersion();
 	int sumday(int year,int month,int day);//¼ÆËãÌìÊý
 	bool CheckProcessExistByName(CSimpleStringA procName);

+ 21 - 15
Module/mod_vtmloader/VtmLoaderFSM.cpp

@@ -288,6 +288,7 @@ void CVtmLoaderFSM::s0_on_entry()
 		NetWorkCheckAndGetSettingTask* task = new NetWorkCheckAndGetSettingTask(this);
 		GetEntityBase()->GetFunction()->PostThreadPoolTask(task);
 	}
+	GetOsVersion();
 }
 
 void CVtmLoaderFSM::s0_on_exit()
@@ -3133,26 +3134,31 @@ CSimpleStringA CVtmLoaderFSM::GetOsVersion()
 		return "";
 	}
 	runInfoPath += "\\runcfg\\osverion";
+	CSimpleStringA csCmd;
+	csCmd = CSimpleStringA::Format("cmd /c ver >%s", runInfoPath);
+	WinExec((LPCSTR)csCmd, SW_HIDE);
+
 	ifstream is;
 	is.open(runInfoPath.GetData(), ios::binary);
-	if (!is.is_open())
+	if (is.is_open())
+	{
+		string line;
+		while (!is.eof()) {
+			getline(is, line);
+			int start = line.find("版本");
+			if (start != string::npos)
+			{
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("ver:[%s]", line.c_str());
+				return CSimpleStringA(line.c_str());
+			}
+			else
+				continue;
+		}
+	}
+	else
 	{
 		DWORD dwErr = GetLastError();
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("open runcfg\\osverion file failed. [%d]", dwErr);
-		CSimpleStringA csCmd;
-		csCmd = CSimpleStringA::Format("cmd /c ver >%s", runInfoPath);
-		WinExec((LPCSTR)csCmd, SW_HIDE);
-	}
-	is.seekg(0, std::ios::beg);
-	string line;
-	while (!is.eof()) {
-		getline(is, line);
-		int start = line.find("版本");
-		if (start != string::npos)
-			//return CSimpleStringA(line.substr(start + 5, line.length() - start - 7).c_str());
-			return CSimpleStringA(line.c_str());
-		else
-			continue;
 	}
 	return "";
 #else