Código:
#include <windows.h>
int main()
{
LPSTR lpSubKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
HKEY hkResult = 0;
RegOpenKeyEx(HKEY_CURRENT_USER, lpSubKey, 0, KEY_WRITE, &hkResult);
{
HKEY hKey = 0;
LPSTR lpValueName = "ejemplo";
LPSTR lpData = "C:\\ejemplo.exe";
RegSetValueEx(hKey, lpValueName, 0, REG_SZ, (LPBYTE)lpData, lstrlen(lpData));
RegCloseKey(hKey);
}
}