未验证 提交 3d2b5ea6 编写于 作者: X xinsheng Ren 提交者: GitHub

Fix/xsren/td 20179/win version info (#19708)

* fix:get system info on windows

* fix:head file

* fix:del tchar.h
上级 6316a984
......@@ -41,7 +41,7 @@ target_link_libraries(
)
if(TD_WINDOWS)
target_link_libraries(
os PUBLIC ws2_32 iconv msvcregex wcwidth winmm crashdump dbghelp
os PUBLIC ws2_32 iconv msvcregex wcwidth winmm crashdump dbghelp version
)
elseif(TD_DARWIN_64)
find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)
......
......@@ -280,11 +280,46 @@ int32_t taosGetEmail(char *email, int32_t maxLen) {
#endif
}
#ifdef WINDOWS
bool getWinVersionReleaseName(char *releaseName, int32_t maxLen) {
TCHAR szFileName[MAX_PATH];
DWORD dwHandle;
DWORD dwLen;
LPVOID lpData;
UINT uLen;
VS_FIXEDFILEINFO *pFileInfo;
GetWindowsDirectory(szFileName, MAX_PATH);
wsprintf(szFileName, L"%s%s", szFileName, L"\\explorer.exe");
dwLen = GetFileVersionInfoSize(szFileName, &dwHandle);
if (dwLen == 0) {
return false;
}
lpData = malloc(dwLen);
if (lpData == NULL) return false;
if (!GetFileVersionInfo(szFileName, dwHandle, dwLen, lpData)) {
free(lpData);
return false;
}
if (!VerQueryValue(lpData, L"\\", (LPVOID *)&pFileInfo, &uLen)) {
free(lpData);
return false;
}
snprintf(releaseName, maxLen, "Windows %d.%d", HIWORD(pFileInfo->dwProductVersionMS),
LOWORD(pFileInfo->dwProductVersionMS));
free(lpData);
return true;
}
#endif
int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
#ifdef WINDOWS
snprintf(releaseName, maxLen, "Windows");
if (!getWinVersionReleaseName(releaseName, maxLen)) {
snprintf(releaseName, maxLen, "Windows");
}
return 0;
#elif defined(_TD_DARWIN_64)
char osversion[32];
......
......@@ -34,6 +34,12 @@ TEST(osTest, osSystem) {
ELogLevel level = DEBUG_FATAL;
int32_t dflag = 255; // tsLogEmbedded ? 255 : uDebugFlag
taosPrintTrace(flags, level, dflag, 0);
const int sysLen = 64;
char osSysName[sysLen];
int ret = taosGetOsReleaseName(osSysName, sysLen);
printf("os systeme name:%s\n", osSysName);
ASSERT_EQ(ret, 0);
}
void fileOperateOnFree(void *param) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册