char regname[]="Software\\Microsoft\\Windows\\CurrentVersion\\Run";
/*开机启动路径*/
HKEY hkResult;
int ret=RegOpenKey(HKEY_LOCAL_MACHINE,regname,&hkResult);
ret=RegSetValueEx(hkResult,"注册表键名",0,REG_EXPAND_SZ,(unsigned char "要运行的程序路径"/,25);
if(ret==0){
printf("success to write run key\n");
RegCloseKey(hkResult);
}
else {
printf("failed to open regedit.%d\n",ret);
return 0;
}