LPCTSTR Rgspath="Software\\Microsoft\\Windows\\CurrentVersion\\Run" ;
int ret=RegOpenKeyEx(HKEY_LOCAL_MACHINE,Rgspath,0,KEY_WRITE, &hKEY);
if(ret!=ERROR_SUCCESS)
{
RegCloseKey(hKEY);
return FALSE;
}
DWORD size=100;
LPSTR FileCurrentName;
GetModuleFileName(NULL,FileCurrentName,size);
//Set Key
ret=RegSetValueEx(hKEY,"name",NULL,type,(const unsigned char*)FileCurrentName,size);
if(ret!=ERROR_SUCCESS)
{
RegCloseKey(hKEY);
return FALSE;
}
RegCloseKey(hKEY);
C:\Documents and Settings\Administrator\「开始」菜单\程序\加一个快捷方式,当然要指向你自己的程序
键值如下:
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run
鼠标右键“新建”“字窜值”,随便起个名字。然后用鼠标右键单机你新建的自窜值,选择“修改”。在“数值数据”中输入你索要运行的应用程序完整路径。“确定”退出,关闭注册表。