我在我的应用程序中使用“RegSetKeyValue”API。 我指的是http://msdn.microsoft.com/en-us/library/ms724921(VS.85).aspx 。
正如文章中所述,我已经将_WIN32_WINNT_定义为0x0600,并且在我的链接器选项中包含了Advapi32.lib。
但我仍然得到链接错误,“无法parsing的外部符号_RegSetKeyValue”。 请告诉我我在这里错过了什么。
这是我的代码片段。
#define _WIN32_WINNT (0x0600) #include <windows.h> int main() { LONG status; status = RegSetKeyValue( HKEY_LOCAL_MACHINE, "SOFTWARE\\7-Zip", "path", REG_SZ, "C:\\newfolder\\path", strlen("C:\\chethan\\path")+1); return 0; }
PS:我正在使用VC ++ 6.0(甚至在Visual Studio 2005上试过,同样的错误呢!)。
链接器使用的Advapi32.lib可能太老了 – 这个API是在Vista中引入的。 确保链接器使用Vista SDK或更新的.lib。