简体   繁体   English

您应该为Windows API调用VerQueryValue提供哪些参数

[英]What Arguments are you supposed to give to the Windows API call VerQueryValue

I understand the first argument must be the result of GetFileVersionInfo(). 我理解第一个参数必须是GetFileVersionInfo()的结果。

The third and forth are target buffer and size 第三个和第四个是目标缓冲区和大小

What is the second argument, lpSubBlock? 第二个参数是什么,lpSubBlock?

Thanks In Advance 提前致谢

When you view the version info through the resource editor you might notice that there is an initial section with FILEVERSION, PRODUCTVERISON etc. and then one or more blocks which contain language specific settings. 当您通过资源编辑器查看版本信息时,您可能会注意到有一个包含FILEVERSION,PRODUCTVERISON等的初始部分,然后是一个或多个包含特定于语言的设置的块。

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 5,0,0,0
 PRODUCTVERSION 5,0,0,0
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x40004L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "CompanyName", ""
            VALUE "FileVersion", "5, 0, 0, 0"
            VALUE "ProductName", ""
            VALUE "ProductVersion", "5, 0, 0, 0"
        END
        BLOCK "000004b0"
        BEGIN
            VALUE "CompanyName", ""
            VALUE "FileVersion", "5, 0, 0, 0"
            VALUE "ProductName", ""
            VALUE "ProductVersion", "5, 0, 0, 0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x0, 1200, 0x409, 1200
    END
END

To get a VS_FIXEDFILEINFO with the non language specific detail use 获取具有非语言特定详细信息的VS_FIXEDFILEINFO

VS_FIXEDFILEINFO *versionInfo;
PUINT versionInfoSize;
VerQueryValue(buffer.get(), TEXT("\\"), (void**) &versionInfo, &versionInfoSize))

To find out what languages are supported use 要了解支持哪种语言使用

Var *translationsInfo;
PUINT transaltionInfoSize;
VerQueryValue(buffer.get(), TEXT("\\VarFileInfo\\Translation"), (void**) &translationsInfo, &transaltionInfoSize))

To get the language specific version detail then use 要获取特定语言版本的详细信息,请使用

StringTable *stringTable;
PUINT stringTableSize;
std::wstring path( L"\\StringFileInfo\\" );
path += L"040904b0";  // get this value from the language support list
path += L"\\FileVersion";
VerQueryValue(buffer.get(), path.c_str(), (void**) &stringTable, &stringTableSize))

It must be a string whose format you can find here: 它必须是一个字符串,其格式可以在这里找到:
http://www.hep.wisc.edu/~pinghc/books/apirefeng/v/verqueryvalue.html http://www.hep.wisc.edu/~pinghc/books/apirefeng/v/verqueryvalue.html

There is another example of usage (in VB, easy to read): 还有另一个使用示例(在VB中,易于阅读):
http://support.microsoft.com/kb/160042 http://support.microsoft.com/kb/160042

You can also check out this whole CodeProject article for a working example in C++: 您还可以查看整个CodeProject文章,了解C ++中的工作示例:
http://www.codeproject.com/KB/cpp/GetLocalVersionInfos.aspx http://www.codeproject.com/KB/cpp/GetLocalVersionInfos.aspx

Another article on the subject of retrieving version information: 另一篇关于检索版本信息的文章:
http://www.microsoft.com/msj/0498/c0498.aspx http://www.microsoft.com/msj/0498/c0498.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM