gpt4 book ai didi

c++ - 带有 Unicode UTF-16 (1200) 代码页字符串表的 VerQueryValue 失败

转载 作者:行者123 更新时间:2023-11-30 02:16:48 28 4
gpt4 key购买 nike

<分区>

我正在尝试使用以下代码从 PE 文件中检索文件描述:

//This code was simplified &
//most error checks were removed for brevity

BYTE* pData = new BYTE[4096];
LPCTSTR path = L"C:\\Windows\\system32\\Speech\\Engines\\TTS\\MSTTSEngine.dll";
if(::GetFileVersionInfo(path, NULL, 4096, pData))
{
struct LANGANDCODEPAGE
{
WORD wLanguage;
WORD wCodePage;
} *lpTranslate = NULL;

UINT cbTranslate;
if(VerQueryValue(pData, L"\\VarFileInfo\\Translation", (LPVOID*)&lpTranslate, &cbTranslate))
{
CString strBlock;
strBlock.Format(L"\\StringFileInfo\\%04x%04x\\FileDescription",
lpTranslate[0].wLanguage,
lpTranslate[0].wCodePage
);

UINT dwProdLn = 0;
VOID* lpBufferName = NULL;
if(VerQueryValue(pData, strBlock, &lpBufferName, &dwProdLn))
{
TRACE(L"Description: %s", lpBufferName);
}
else
{
TRACE(L"Error=%d", ::GetLastError());
}
}

delete[] pData;
}

该特定文件(here's the cop y,如果您的 Windows 10 上没有它)的字符串表编码为 wLanguage 为 0,wCodePage 为 1200 . 在那种情况下 VerQueryValue 失败,错误代码为 ERROR_RESOURCE_TYPE_NOT_FOUND。但是当我在文件资源管理器中检查该文件时,我知道该文件具有“文件描述”属性:

enter image description here

那么我在上面的代码中做错了什么?

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com