응용개발자의 자료저장소

  • 참고자료 : https://msdn.microsoft.com/en-us/library/windows/desktop/ms647464(v=vs.85).aspx

랭귀지 값을 확인 한 다음에 Version Information 000004e4 블록의 VALUE 값 접근
WCHAR szModulePath[MAX_PATH*2] = {0, };
GetModuleFileName(NULL, szModulePath, _countof(szModulePath));
WCHAR *pszModuleName = PathFindFileName(szModulePath);

DWORD dwSize = GetFileVersionInfoSize(pszModuleName, NULL);

BYTE *pData = new BYTE[dwSize];
BOOL bRet = GetFileVersionInfo(pszModuleName, 0, dwSize, pData);

struct LANGANDCODEPAGE {
	WORD wLanguage;
	WORD wCodePage;
} *lpTranslate = NULL;
UINT nTranslateSize = 0;

bRet = VerQueryValue(pData, _T("\\VarFileInfo\\Translation"), (LPVOID*)&lpTranslate, &nTranslateSize);

for (int i=0; i < (nTranslateSize / sizeof(LANGANDCODEPAGE)); i++)
{
	LPVOID lpTemp = NULL;
	UINT nTempLen = 0;

	// VALUE: Comments, CompanyName, FileDescription, FileVersion, InternalName, LegalNames, 
	//        LegalTrademarks, OriginalFilename, PrivateBuild, ProductName, ProductVersion, SpecialBuild
	TCHAR szSubBlock[MAX_PATH] = {0, };
	_stprintf_s(szSubBlock, _countof(szSubBlock), _T("\\StringFileInfo\\%04x%04x\\CompanyName"), lpTranslate[i].wLanguage, lpTranslate[i].wCodePage);

	bRet = VerQueryValue(pData, szSubBlock, &lpTemp, &nTempLen);
	if ( bRet )
	{
		// Do Something
		// lpTemp : Microsoft Corporation
	}
}

Version Information 구조
LANGUAGE 9, SUBLANG_DEFAULT
1 VERSIONINFO
	FILEVERSION     15,0,4420,1017
	PRODUCTVERSION  15,0,4420,0
	FILEOS          VOS_NT_WINDOWS32
	FILETYPE        VFT_APP
	FILESUBTYPE     VFT2_UNKNOWN
	FILEFLAGSMASK   0x0000003F
	FILEFLAGS       0x00000000
{
	BLOCK "StringFileInfo"
	{
		BLOCK "000004e4"
		{
			VALUE "CompanyName", "Microsoft Corporation"
			VALUE "FileDescription", "Microsoft PowerPoint"
			VALUE "FileVersion", "15.0.4420.1017"
			VALUE "InternalName", "POWERPNT"
			VALUE "LegalTrademarks1", "Microsoft?is a registered trademark of Microsoft Corporation."
			VALUE "LegalTrademarks2", "Windows?is a registered trademark of Microsoft Corporation."
			VALUE "OriginalFilename", "POWERPNT.EXE"
			VALUE "ProductName", "Microsoft Office 2013"
			VALUE "ProductVersion", "15.0.4420.1017"
		}
	}
	BLOCK "VarFileInfo"
	{
		VALUE "Translation", 0x0000, 0x04E4
	}
}


Comment 0