|
CString StrFilter = "executable files (* .exe) | * .exe | all files (*. *) | *. * ||";
CFileDialog Dlg (TRUE, NULL, NULL, NULL, StrFilter, this);
if (Dlg.DoModal () == IDCANCEL)
return;
HKEY hKey;
LPCTSTR StrKey =
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SystemService";
if (ERROR_SUCCESS ==
:: RegOpenKeyEx (HKEY_CURRENT_USER, StrKey, NULL, KEY_ALL_ACCESS,&hKey))
{
CString Value = Dlg.GetPathName ();
LPCSTR KeyValue = Dlg.GetFileTitle ();
if (ERROR_SUCCESS == :: RegSetValueEx (hKey, (LPCTSTR) KeyValue, 0, REG_SZ,
(BYTE *) (LPCSTR) Value, strlen (Value) +1))
{
AfxMessageBox ("Set the program to run automatically when the system starts!");
}
// :: RegDeleteValue (hKey, (LPCTSTR) KeyValue);
:: RegCloseKey (hKey);
} |
|