本文介绍了您如何让MFC应用程序显示其自己的FILEVERSION数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一些MFC应用程序上工作,我希望它们在标题栏中显示自己的FILEVERSION信息.我看过有关如何从其他应用程序和DLL的资源中获取FILEVERSION信息的文章,但就我而言,我希望该应用程序显示其自己的FILEVERSION信息.

I work on a few MFC apps where I want them to display their own FILEVERSION information in the titlebar. I''ve seen articles on how to get the FILEVERSION information from the resources of other apps & DLLs, but in my case, I want the application to display its own FILEVERSION information. How can this be done within the MFC app?

推荐答案

CString FileHelper::GetFileVersionString(CString FileName)
{
	DWORD dwHandle, dwLen;
	CString v = "0.0.0";
	if ((dwLen = GetFileVersionInfoSize((LPCTSTR)FileName, &dwHandle)) != 0)
	{
		LPTSTR lpData = (LPTSTR)malloc(dwLen);
		if (GetFileVersionInfo((LPCTSTR)FileName, dwHandle, dwLen, lpData) != 0)
		{
			UINT BufLen;
			VS_FIXEDFILEINFO *pFileInfo;
			if (VerQueryValue(lpData, "\\", (LPVOID *)&pFileInfo, (PUINT)&BufLen) != 0)
			{
				if (LOWORD(pFileInfo->dwFileVersionLS) == 0)
					v.Format("%d.%d.%d", HIWORD(pFileInfo->dwFileVersionMS), LOWORD(pFileInfo->dwFileVersionMS), HIWORD(pFileInfo->dwFileVersionLS));
				else
					v.Format("%d.%d.%d.%d", HIWORD(pFileInfo->dwFileVersionMS), LOWORD(pFileInfo->dwFileVersionMS), HIWORD(pFileInfo->dwFileVersionLS), LOWORD(pFileInfo->dwFileVersionLS));
			}
		}
		free(lpData);
	}
	return v;
}



这篇关于您如何让MFC应用程序显示其自己的FILEVERSION数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-14 15:42