在C++中用以下代码读取注册表信息时出错。
HKEY hKey;
LPCTSTR data_Set="Software\\Microsoft\\Windows\\CurrentVersion\\GoldOfficeExpired\\";
unsigned char *day;
unsigned char *month;
unsigned char *year;
DWORD bdata=80;
DWORD type_1=REG_SZ ;
day=new unsigned char[2];
month=new unsigned char[2];
year=new unsigned char[4];
long ret1=RegOpenKeyEx (KEY_LOCAL_MACHINE,data_Set,0,KEY_READ,&hKey);
if (ret1!=ERROR_SUCCESS)
{
long ret2=RegQueryValueEx(hKey,"day",NULL,&type_1,day,&bdata);
if (ret2==ERROR_SUCCESS)
{
}
}
RegCloseKey(hKey);
报错信息为:
checkinstall.obj : error LNK2001: unresolved external symbol __imp__RegCloseKey@
4
checkinstall.obj : error LNK2001: unresolved external symbol __imp__RegQueryValu
eExA@24
checkinstall.obj : error LNK2001: unresolved external symbol __imp__RegOpenKeyEx
A@20
HKEY hKey;
LPCTSTR data_Set="Software\\Microsoft\\Windows\\CurrentVersion\\GoldOfficeExpired\\";
unsigned char *day;
unsigned char *month;
unsigned char *year;
DWORD bdata=80;
DWORD type_1=REG_SZ ;
day=new unsigned char[2];
month=new unsigned char[2];
year=new unsigned char[4];
long ret1=RegOpenKeyEx (KEY_LOCAL_MACHINE,data_Set,0,KEY_READ,&hKey);
if (ret1!=ERROR_SUCCESS)
{
long ret2=RegQueryValueEx(hKey,"day",NULL,&type_1,day,&bdata);
if (ret2==ERROR_SUCCESS)
{
}
}
RegCloseKey(hKey);
报错信息为:
checkinstall.obj : error LNK2001: unresolved external symbol __imp__RegCloseKey@
4
checkinstall.obj : error LNK2001: unresolved external symbol __imp__RegQueryValu
eExA@24
checkinstall.obj : error LNK2001: unresolved external symbol __imp__RegOpenKeyEx
A@20
Advapi32.lib可以在Project Setting里面将这个lib包含进取