TCHAR szPath[MAX_PATH]; GetModuleFileName(NULL,szPath,MAX_PATH); HKEY newValue; HKEY resKey; subValue = "MyProgram"; long key = RegQueryValueExA(resKey, subValue, NULL, NULL, NULL, NULL); if(key == ERROR_FILE_NOT_FOUND) { return false; } else { const DWORD cbData = sizeof(TCHAR) * (lstrlen(szPath) + 1); RegOpenKey(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",&newValue); RegSetValueEx(newValue, subValue ,0,REG_SZ,(LPBYTE)szPath,cbData); RegCloseKey(newValue); }