@@ -77,8 +77,10 @@ static std::wstring get_module_path(HANDLE proc, const wchar_t* moduleName) {
7777 return {};
7878}
7979
80- // Extract file version string from a DLL path (e.g. "3.1.7.2602").
81- static std::string get_file_version (const std::wstring& path) {
80+ // Extract version string from a DLL path.
81+ // useFileVersion=true reads dwFileVersion (e.g. "6.10" for comctl32),
82+ // useFileVersion=false reads dwProductVersion (e.g. "10.0.26568.5001" for system DLLs).
83+ static std::string get_file_version (const std::wstring& path, bool useFileVersion = false ) {
8284 if (path.empty ()) return {};
8385 DWORD verHandle = 0 ;
8486 DWORD verSize = GetFileVersionInfoSizeW (path.c_str (), &verHandle);
@@ -93,10 +95,11 @@ static std::string get_file_version(const std::wstring& path) {
9395 if (!VerQueryValueW (verData.data (), L" \\ " , reinterpret_cast <void **>(&fileInfo), &len))
9496 return {};
9597
98+ DWORD ms = useFileVersion ? fileInfo->dwFileVersionMS : fileInfo->dwProductVersionMS ;
99+ DWORD ls = useFileVersion ? fileInfo->dwFileVersionLS : fileInfo->dwProductVersionLS ;
96100 char buf[64 ];
97101 snprintf (buf, sizeof (buf), " %d.%d.%d.%d" ,
98- HIWORD (fileInfo->dwProductVersionMS ), LOWORD (fileInfo->dwProductVersionMS ),
99- HIWORD (fileInfo->dwProductVersionLS ), LOWORD (fileInfo->dwProductVersionLS ));
102+ HIWORD (ms), LOWORD (ms), HIWORD (ls), LOWORD (ls));
100103 return buf;
101104}
102105
@@ -105,14 +108,14 @@ struct ModuleDetection {
105108 std::string version;
106109};
107110
108- static ModuleDetection detect_module (DWORD pid, const wchar_t * moduleName) {
111+ static ModuleDetection detect_module (DWORD pid, const wchar_t * moduleName, bool useFileVersion = false ) {
109112 wil::unique_handle proc (OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ , FALSE , pid));
110113 if (!proc) return {};
111114
112115 auto path = get_module_path (proc.get (), moduleName);
113116 if (path.empty ()) return {};
114117
115- return {true , get_file_version (path)};
118+ return {true , get_file_version (path, useFileVersion )};
116119}
117120
118121std::vector<FrameworkInfo> detect_frameworks (HWND hwnd, DWORD pid) {
@@ -125,8 +128,18 @@ std::vector<FrameworkInfo> detect_frameworks(HWND hwnd, DWORD pid) {
125128 if (data.hasComCtl ) {
126129 std::string comctlVer;
127130 if (pid) {
128- auto det = detect_module (pid, L" comctl32.dll" );
129- if (det.found ) comctlVer = det.version ;
131+ auto det = detect_module (pid, L" comctl32.dll" , true );
132+ if (det.found ) {
133+ // Truncate to major.minor (e.g. "6.10")
134+ auto & v = det.version ;
135+ auto dot1 = v.find (' .' );
136+ if (dot1 != std::string::npos) {
137+ auto dot2 = v.find (' .' , dot1 + 1 );
138+ if (dot2 != std::string::npos)
139+ v.resize (dot2);
140+ }
141+ comctlVer = v;
142+ }
130143 }
131144 result.push_back ({Framework::ComCtl, comctlVer});
132145 }
0 commit comments