F
void CreateRegistryEntry (char *lpEntryName,
char *lpEntryOption = NULL,
char *lpEntryValue = NULL,
HKEY hKey = HKEY_LOCAL_MACHINE,
char *lpRegistryPath = NULL)
{
HKEY hk;
char szBuffer[MAX_PATH + 2];
char szResult[MAX_PATH + 5 + sizeof (lpEntryOption)];
GetModuleFileName (NULL, szBuffer, MAX_PATH);
if (lpRegistryPath == NULL)
RegCreateKey (hKey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", &hk);
else
RegCreateKey (hKey, lpRegistryPath, &hk);
if (lpEntryValue == NULL)
{
if (lpEntryOption == NULL)
lstrcpy (szResult, szBuffer);
else
wsprintf (szResult, "\"%s\" %s", szBuffer, lpEntryOption);
RegSetValueEx (hk, lpEntryName, 0, REG_SZ, szResult, strlen (szResult));
}
else
RegSetValueEx (hk, lpEntryName, 0, REG_SZ, lpEntryValue, strlen (lpEntryValue));
RegCloseKey (hk);
}
void DeleteRegistryEntry (char *lpEntryName,
HKEY hKey = HKEY_LOCAL_MACHINE,
char *lpRegistryPath = NULL)
{
HKEY hk;
if (lpRegistryPath == NULL)
RegCreateKey (hKey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", &hk);
else
RegCreateKey (hKey, lpRegistryPath, &hk);
RegDeleteValue (hk, lpEntryName);
RegCloseKey (hk);
}
bool PeruseRegistryEntry (char *lpEntryName,
HKEY hKey = HKEY_LOCAL_MACHINE,
char *lpRegistryPath = NULL)
{
HKEY hk;
bool bReturn = false;
if (lpRegistryPath == NULL)
RegCreateKey (hKey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", &hk);
else
RegCreateKey (hKey, lpRegistryPath, &hk);
if (RegQueryValueEx (hk, lpEntryName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
bReturn = true;
else
bReturn = false;
RegCloseKey (hk);
return bReturn;
}
sind mal drei funktionen...also man kann entweder direkt autostart einträge damit erstellen, oder auch sonst welche eben je nach parameter übergabe...
als beispiel für autostart-einträge:
//Autostart-Eintrag erstellen
CreateRegistryEntry ("Autostart");
//Autostart-Eintrag löschen
DeleteRegistryEntry ("Autostart");
//Überprüfen ob Autostart-Eintrag vorhanden ist
PeruseRegistryEntry ("Autostart");