// 添加当前模块路径到注册表的自动启动列表中(完整路径) HKEY hKey = NULL; LPCTSTR lpSubKey = TEXT("Software//Microsoft//Windows//CurrentVersion//Run"); TCHAR lpFileName[MAX_PATH + 1]; const DWORD nTchar = GetModuleFileName(NULL, lpFileName, MAX_PATH); const DWORD cbData = (nTchar + 1) * sizeof(TCHAR); if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpSubKey, 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS) { ::RegSetValueEx(hKey, TEXT("bom"), 0, REG_SZ, (const BYTE*)lpFileName, cbData); ::RegCloseKey(hKey); }