File version information under NT

Question:
I am using the GetFileVersionInfoSize, GetFileVersionInfo, and VerQueryValue APIs to get the file version of third-party applications. In all cases, GetFileVersionInfoSize returns a large number, but when I query it for StringFileInfo40904B0ProductVersion, sometimes I get nothing. My Visual Basic application and my C++ DLL both return values, but Excel and Visio return nothing. Any thoughts?

Answer:
Not a direct answer, but if you are doing this from multiple envioronments, wouldn’t it be easier to create an ActiveX exe which returns this information, and then use it from all your programs? Write it in either Visual Basic or C++; both do a good job with this kind of stuff. Then you don’t have to worry about what different things you need to do in Excel, Visio, or whatever. Little utility packages like this can be incredibly useful and have a quick payback.

BSTR FAR PASCAL utl_GetFileVersion(LPTSTRpFileName, LPTSTR pInfoToGet){DWORD   dwVerInfoSize;		// Size of version information blockLPSTR   lpVersion;			// String pointer to 'version' textDWORD   dwVerHnd=0;			// An 'ignored' parameter, always '0'UINT    uVersionLen;		// Length of string version informationBOOL    bRetCode;BSTR    bstrVersionInfo;	// Version Info to pass back		// get the size of the version information block	dwVerInfoSize = GetFileVersionInfoSize(pFileName, &dwVerHnd);	if (dwVerInfoSize)	{		LPSTR   lpstrVffInfo;	// pointer to version information block		HANDLE  hMem;		// pointer to allocated memory		HANDLE  hMem2;		// ditto		LPSTR	lpstrVerText;	// text string of info to get			//allocate memory for the version information block		hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);		//load the version information block		lpstrVffInfo  = (char *)GlobalLock(hMem); 		GetFileVersionInfo(pFileName, dwVerHnd, 			dwVerInfoSize, lpstrVffInfo);		hMem2 = GlobalAlloc(GMEM_MOVEABLE, 25 + strlen(pInfoToGet));	lpstrVerText  = (char *)GlobalLock(hMem2);		sprintf(lpstrVerText,"\StringFileInfo\040904B0\%s",pInfoToGet);		// Query the version information block for Product Version		bRetCode = VerQueryValue((LPVOID)lpstrVffInfo,			TEXT(lpstrVerText),			(LPVOID *)&lpVersion,			&uVersionLen);		if(bRetCode)		{				// copy version info into a string VB understands			bstrVersionInfo = SysAllocStringLen(NULL, strlen(lpVersion)+1);			memset(bstrVersionInfo, 0, strlen(lpVersion)+1);			memcpy(bstrVersionInfo, lpVersion, strlen(lpVersion));			return (bstrVersionInfo);		}		else		{			return (0);		}	}	else		return (0);  }

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

technology leadership

Why the World Needs More Technology Leadership

As a fact, technology has touched every single aspect of our lives. And there are some technology giants in today’s world which have been frequently opined to have a strong influence on recent overall technological influence. Moreover, those tech giants have popular technology leaders leading the companies toward achieving greatness.

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job