Prøv at kikke på:
http://home20.inet.tele.dk/midgaard/snip/registry.html
#include <windows.h>
#include <iostream.h>
int main(void)
{
HKEY hKey;
DWORD Value = 1;
// Try to read
if(RegOpenKey(HKEY_CURRENT_USER, "Software\\\\MyCompany\\\\MyApp", &hKey) == ERROR_SUCCESS)
{
DWORD Type = REG_SZ, Size = sizeof(DWORD);
RegQueryValueEx(hKey, "Net_S", 0, &Type, (BYTE *)&Value, &Size);
cout << "Got Value: " << Value << endl;
}
else
cout << "Failed to read value" << endl;
RegCloseKey(hKey);
// Try to save the Value
if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, 0) == ERROR_SUCCESS)
{
Value++;
RegSetValueEx(hKey, "Net_S", 0, REG_SZ, (BYTE *)&Value, sizeof(Value));
cout << "Did write value" << endl;
}
else
cout << "Failed to write value" << endl;
RegCloseKey(hKey);
return 0;
}
Okay har næsten fået det til at virke som det skal, men kan bare ikke får den til at tage i mod andre tegn end tal som værdi, hvordan ændre man dette?
//Nick