16,472
社区成员
发帖
与我相关
我的任务
分享
int addAutoRun(LPCTSTR fullPath,LPCTSTR fileName)
{
HKEY hKey;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
NULL,
KEY_SET_VALUE,
&hKey)==ERROR_SUCCESS)
{
if(RegSetValueEx(hKey,
fileName,
NULL,
REG_SZ,
(CONST BYTE *)fullPath,
lstrlen(fullPath))==ERROR_SUCCESS)
{
cout<<"set auto run program success"<<endl;
RegCloseKey(hKey);
return 0;
}
else
{
//cout<<GetLastError()<<endl;
cout<<"error happens1"<<endl;
RegCloseKey(hKey);
}
}
else
{
//cout<<GetLastError()<<endl;
cout<<"error happens2"<<endl;
RegCloseKey(hKey);
}
return -1;
}
这是主函数
int main(int argc, PCHAR argv[])
{
//changeStartPage("www.baidu.com");
addAutoRun("\"E:\\mfc\\myRose\\myRose\\myRose\\myRose.exe\"","myRose");
getchar();
return 0;
}
我不明白你是什么意思呢?