为现有 C++ 建立 VersionInfo 存在困难; DLL项目
我有一个现有的 C++ DLL,它可以正确编译,但没有与之关联的版本信息,例如已编译库的“属性”中的“版本”选项卡。奇怪的是,它在 Visual Studio 中确实有一个 .rc 文件,该文件与该项目关联,并且似乎定义正确。但是,无论是使用该文件,还是将其替换为 将资源文件添加到VC6 dll,DLL 中的版本资源不可见右键单击,或http://www.codeproject.com/ KB/DLL/XDllPt3.aspx,我仍然无法让它导出DLL信息。我无法发布该项目的大部分代码,因为它是内部的,但这是 .rc 文件的内容: //Microsoft Developer Studio 生成的资源脚本。 //
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "PTU DLL library\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "PTUDLL32\0"
VALUE "LegalCopyright", "Copyright (C) 1999\0"
VALUE "ProductName", "PTU DLL library\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
I have an extant C++ DLL which compiles properly, but has no version information associated with it such was the Version tab in Properties for the compiled library. The odd things about it is that it does have a .rc file in Visual Studio which is associated with the project and which seems to be correctly defined. However, whether using that file, or replacing it with values from locations such as Adding resource file to VC6 dll, Version resource in DLL not visible with right-click, or http://www.codeproject.com/KB/DLL/XDllPt3.aspx, I still cannot get it to export the DLL info. I cannot post most of the code of the project, since it is internal, but this is the contents of the .rc file:
//Microsoft Developer Studio generated resource script.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "PTU DLL library\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "PTUDLL32\0"
VALUE "LegalCopyright", "Copyright (C) 1999\0"
VALUE "ProductName", "PTU DLL library\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上我的问题是如何将版本信息放入其中。但事实上,问题本身就解决了。显然该项目附带的资源文件已损坏。创建一个新项目,将其附加到项目中,然后移动所提供的信息以使其发挥作用。谢谢。
Actually my question was on getting the version info into it. But as it is, the problem resolved itself. Apparently the resource file that came with the project had gotten corrupted. Creating a new one, attaching it to the project, and moving over the information served to make it work. Thank you.
要从文件中检索版本信息,您需要使用 GetFileVersionInfo()。在调用 GetFileVersionInfoSize() 检索版本信息之前,您应该采取额外的步骤来确定存储的版本信息的大小。
To retrieve the version information from a file you need to use GetFileVersionInfo(). You should take the additional step of determining the size of the version information stored before retrieving it with a call to GetFileVersionInfoSize().