65,208
社区成员
发帖
与我相关
我的任务
分享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;
}addAutoRun(L"Rose.exe",L"Rose");
addAutoRun("Rose.exe","Rose");而MFC的工程一定要转换呢?addAutoRun(L"Rose.exe",L"Rose");[/quote]addAutoRun("Rose.exe","Rose");而MFC的工程一定要转换呢?addAutoRun(L"Rose.exe",L"Rose");