HKEY hKey;
TCHAR *lpSubKey = "Upload"; //注册表键值
TCHAR *SubKey = "Software \\Microsoft\\Windows\\CurrentVersion\\Run";
CHAR cFileName[MAX_PATH];
GetModuleFileName(NULL, cFileName, MAX_PATH);
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SubKey, 0,
KEY_ALL_ACCESS, &hKey)!=ERROR_SUCCESS)
return FALSE; //打开键值
if (RegSetValueEx(hKey, lpSubKey, 0, REG_SZ, (const unsigned char*)cFileName,
strlen(cFileName))!=ERROR_SUCCESS) //写入注册表
return FALSE;
RegCloseKey(hKey);