使用 GetFileVersionInfoSize() 时出现错误 LNK2019

发布于 2024-11-29 03:16:08 字数 2309 浏览 1 评论 0原文

我刚刚将这一点包含在我已经工作的代码中,但我收到了 LNK2019 错误。粘贴代码后我将粘贴错误。

类 CAboutDlg 具有:

public:

    CStatic m_VersionInfoCtrl;

   virtual BOOL OnInitDialog();

};

函数本身:

BOOL CAboutDlg::OnInitDialog()

{

   CDialog::OnInitDialog();

   CString inFileName = AfxGetApp()->m_pszExeName;

   inFileName += ".exe";

   void * theVersionInfo;

   void * theFixedInfo;

   unsigned long aVersionInfoSize = GetFileVersionInfoSize ( inFileName , &aVersionInfoSize);

   CString returnString;

   if (aVersionInfoSize)

   {

   theVersionInfo = new char [aVersionInfoSize];

   GetFileVersionInfo ( inFileName, 0 , aVersionInfoSize, theVersionInfo) ;

   unsigned int aSize = 0;

   VerQueryValue( theVersionInfo , "\\" , &theFixedInfo , &aSize);

   if (theFixedInfo)

   {

   VS_FIXEDFILEINFO * aInfo = (VS_FIXEDFILEINFO *) theFixedInfo;

   DWORD dwMajorVersionMsb = HIWORD( aInfo->dwFileVersionMS );

   DWORD dwMajorVersionLsb = LOWORD( aInfo->dwFileVersionMS ); 

   DWORD dwMinorVersionMsb = HIWORD( aInfo->dwFileVersionLS );

   DWORD dwMinorVersionLsb = LOWORD( aInfo->dwFileVersionLS ); 



  returnString.Format("Version %d . %d . %d. %d",dwMajorVersionMsb,dwMajorVersionLsb,dwMinorVersionMsb,dwMinorVersionLsb);

  //memcpy(sVer,returnString.GetBuffer(),returnString.GetLength()+1);

  }

delete theVersionInfo;

   }

   m_VersionInfoCtrl.SetWindowText(returnString);

   return TRUE;  // return TRUE unless you set the focus to a control

   // EXCEPTION: OCX Property Pages should return FALSE

}

....

它给了我以下三个错误:

1.RangemasterGenerator error LNK2019: unresolved external symbol _VerQueryValueA@16 referenced in function "public: virtual int __thiscall CAboutDlg::OnInitDialog(void)" (?OnInitDialog@CAboutDlg@@UAEHXZ)

2.RangemasterGenerator error LNK2019: unresolved external symbol _GetFileVersionInfoA@16 referenced in function "public: virtual int __thiscall CAboutDlg::OnInitDialog(void)" (?OnInitDialog@CAboutDlg@@UAEHXZ)
3.RangemasterGenerator error LNK2019: unresolved external symbol _GetFileVersionInfoSizeA@8 referenced in function "public: virtual int __thiscall CAboutDlg::OnInitDialog(void)" (?OnInitDialog@CAboutDlg@@UAEHXZ)

... 我不明白问题是什么。任何人都可以帮忙吗? 谢谢。

I just included this bit in my already working code, but I am getting an LNK2019 error. I'll paste the error after pasting the code.

The Class CAboutDlg has:

public:

    CStatic m_VersionInfoCtrl;

   virtual BOOL OnInitDialog();

};

The Function itself:

BOOL CAboutDlg::OnInitDialog()

{

   CDialog::OnInitDialog();

   CString inFileName = AfxGetApp()->m_pszExeName;

   inFileName += ".exe";

   void * theVersionInfo;

   void * theFixedInfo;

   unsigned long aVersionInfoSize = GetFileVersionInfoSize ( inFileName , &aVersionInfoSize);

   CString returnString;

   if (aVersionInfoSize)

   {

   theVersionInfo = new char [aVersionInfoSize];

   GetFileVersionInfo ( inFileName, 0 , aVersionInfoSize, theVersionInfo) ;

   unsigned int aSize = 0;

   VerQueryValue( theVersionInfo , "\\" , &theFixedInfo , &aSize);

   if (theFixedInfo)

   {

   VS_FIXEDFILEINFO * aInfo = (VS_FIXEDFILEINFO *) theFixedInfo;

   DWORD dwMajorVersionMsb = HIWORD( aInfo->dwFileVersionMS );

   DWORD dwMajorVersionLsb = LOWORD( aInfo->dwFileVersionMS ); 

   DWORD dwMinorVersionMsb = HIWORD( aInfo->dwFileVersionLS );

   DWORD dwMinorVersionLsb = LOWORD( aInfo->dwFileVersionLS ); 



  returnString.Format("Version %d . %d . %d. %d",dwMajorVersionMsb,dwMajorVersionLsb,dwMinorVersionMsb,dwMinorVersionLsb);

  //memcpy(sVer,returnString.GetBuffer(),returnString.GetLength()+1);

  }

delete theVersionInfo;

   }

   m_VersionInfoCtrl.SetWindowText(returnString);

   return TRUE;  // return TRUE unless you set the focus to a control

   // EXCEPTION: OCX Property Pages should return FALSE

}

....

Its giving me the following three errors:

1.RangemasterGenerator error LNK2019: unresolved external symbol _VerQueryValueA@16 referenced in function "public: virtual int __thiscall CAboutDlg::OnInitDialog(void)" (?OnInitDialog@CAboutDlg@@UAEHXZ)

2.RangemasterGenerator error LNK2019: unresolved external symbol _GetFileVersionInfoA@16 referenced in function "public: virtual int __thiscall CAboutDlg::OnInitDialog(void)" (?OnInitDialog@CAboutDlg@@UAEHXZ)
3.RangemasterGenerator error LNK2019: unresolved external symbol _GetFileVersionInfoSizeA@8 referenced in function "public: virtual int __thiscall CAboutDlg::OnInitDialog(void)" (?OnInitDialog@CAboutDlg@@UAEHXZ)

...
I am not able to understand what the problem is. Can anyone help please.
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

我偏爱纯白色 2024-12-06 03:16:08

您需要链接包含两个函数 VerQueryValueGetFileVersionInfo 的库 - 默认情况下链接器不知道在哪里可以找到它们。

在 MSDN 上快速搜索这两个函数表明它们都在系统库 version.dll 中,而您要链接的库是 version.lib。只需将其添加到链接器属性中的库列表中即可。

You need to link against the library that contains the two functions VerQueryValue and GetFileVersionInfo - the linker doesn't know by default where to find them.

A quick search for the two functions on MSDN suggests that they're both in the system library version.dll and the library you want to link against is version.lib. Just add that to the library list in the linker properties.

屌丝范 2024-12-06 03:16:08

函数GetFileVersionInfo< /strong> 和 GetFileVersionInfoSize 定义于 < code>Version.dll 和 Version.lib 因此请确保您喜欢适当的库。

The functions GetFileVersionInfo and GetFileVersionInfoSize are defined in Version.dll and Version.lib so make sure, you are liking to the appropriate libraries.

兲鉂ぱ嘚淚 2024-12-06 03:16:08

在将 VS6.0 应用程序升级到 VS2012 平台时,我也遇到了同样的错误。

a. 错误 LNK2019:函数 _main 中引用的无法解析的外部符号 _GetFileVersionInfoSizeA@8

b. 错误LNK2019:函数_main中引用了无法解析的外部符号_GetFileVersionInfoA@16

c.错误LNK2019:函数_main中引用了无法解析的外部符号_VerQueryValueA@16

解决方案:

我发现这是由于缺少对库“Version.lib”的引用。

a. 对于 VS6.0,将其添加到项目设置->链接->库模块

b. 对于 VS2012,添加到项目属性->链接器->输入->其他依赖项
并将完整的 lib 路径添加到 Include 目录。

I am also getting same error, while upgrading the VS6.0 application to VS2012 platform.

a. error LNK2019: unresolved external symbol _GetFileVersionInfoSizeA@8 referenced in function _main

b. error LNK2019: unresolved external symbol _GetFileVersionInfoA@16 referenced in function _main

c. error LNK2019: unresolved external symbol _VerQueryValueA@16 referenced in function _main

Resolution:

I found that it is due to missing reference to library "Version.lib".

a. For VS6.0 add it to Project Setting->Link->library modules

b. For VS2012 add to Project Properties->Linker->Input->Additional Dependancies
and add full lib path to Include directory.

陌路终见情 2024-12-06 03:16:08

对于VS2012或2013添加到项目属性->链接器->输入->附加依赖项->添加版本.lib

For VS2012 or 2013 add to Project Properties->Linker->Input->Additional Dependencies -> Add Version.lib

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文