File version information under NT

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:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as