我刚刚将这一点包含在我已经运行的代码中,但是我收到了LNK2019错误.粘贴代码后我会粘贴错误.
CAboutDlg类具有:
public:
CStatic m_VersionInfoCtrl;
virtual BOOL OnInitDialog();
};
Run Code Online (Sandbox Code Playgroud)
功能本身:
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
}
Run Code Online (Sandbox Code Playgroud)
....
它给了我以下三个错误:
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)
Run Code Online (Sandbox Code Playgroud)
......我无法理解问题所在.任何人都可以帮忙.谢谢.
Tim*_*sch 54
你需要对包含两个功能链接库VerQueryValue和GetFileVersionInfo-链接器默认情况下不会在哪里可以找到他们知道.
快速搜索MSDN上的两个函数表明它们都在系统库version.dll中,而您要链接的库是version.lib.只需将其添加到链接器属性中的库列表即可.
小智 5
在将VS6.0应用程序升级到VS2012平台时,我也遇到了同样的错误.
一个.错误LNK2019:函数_main中引用的未解析的外部符号_GetFileVersionInfoSizeA @ 8
湾 错误LNK2019:函数_main中引用了未解析的外部符号_GetFileVersionInfoA @ 16
C.错误LNK2019:函数_main中引用了未解析的外部符号_VerQueryValueA @ 16
解析度:
我发现它是由于缺少对库"Version.lib"的引用.
一个.对于VS6.0,将其添加到项目设置 - >链接 - >库模块
湾 对于VS2012,添加到Project Properties-> Linker-> Input-> Additional Dependancies 并添加完整的lib路径到Include目录.