VC++.net新建windows工程后粘贴入代码报错
来源:百度知道 编辑:UC知道 时间:2024/05/19 20:18:28
代码如下
HKEY hKey;
DWORD re;
re=0;
(const BYTE *) &re;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",0,KEY_WRITE,&hKey);
RegSetValueEx(hKey,"AutoRestartShell",0,REG_DWORD,(const BYTE *)&re,4);
RegCloseKey(hKey);
1.看代码是否有错误
2.去掉代码中间的空格(一般都是这个问题)
链接出错的
regedit.obj : error LNK2028: 无法解析的标记(0A00000E) "extern "C" long __stdcall RegCloseKey(struct HKEY__ *)" (?RegCloseKey@@$$J14YGJPAUHKEY__@@@Z),该标记在函数 "private: void __clrcall regedit::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@regedit@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z) 中被引用
regedit.obj : error LNK2028: 无法解析的标记(0A00000F) "extern "C" long __stdcall RegSetValueExA(struct HKEY__ *,char const *,unsigned long,unsigned long,unsigned char const *,unsigned long)" (?RegSetValueExA@@$$J224YGJPAUHKEY__@@PBDKKPBEK@Z),该标记在函数 "private: void __clrcall regedit::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@regedit@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z) 中被引用
regedit.obj : error LNK2028: 无法解析的标记(0A000010) "extern "C" long __stdcall RegOpenK