写了一个控制台程序,采用在静态库中使用MFC,出现以下错误。
一.相关错误
LNK2001 无法解析的外部符号 __imp__RegQueryValueExA@24
LNK2001 无法解析的外部符号 __imp__RegOpenKeyExA@20
LNK2001 无法解析的外部符号 __imp__RegCloseKey@4
二.解决办法
方法一.MFC的使用-使用标准Windows库(在其他平台运行可能缺少相关.dll)
方法二.报错信息可知注册表函数缺少相关库
1.MSDN查找RegQueryValueEx
2.找到该函数库
|
Minimum supported client |
Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names |
RegQueryValueExW (Unicode) and RegQueryValueExA (ANSI) |
2.加入
#pragma comment (lib,"Advapi32.lib")
本文介绍了一种在使用MFC的控制台程序中遇到的注册表访问错误,并提供了两种解决方案:一是调整MFC设置以使用标准Windows库;二是明确链接到Advapi32.lib库来解决未解析的外部符号问题。
3523

被折叠的 条评论
为什么被折叠?



