Hey everyone,
I'm having a bit of a problem when I save an entry into the registry. It'll story any number less than 100, however if the number (aka the variable: trigger_key ) is equal to or greater than 100 (no larger than 255), it saves a random value.
Code:
HKEY hk;
DWORD dwDisp;
TCHAR dwData[120];
RegCreateKeyExA(HKEY_CURRENT_USER, "SOFTWARE\\MacroKeys", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hk, &dwDisp);
_stprintf ( dwData, _T("%d"), trigger_key );
RegSetValueEx(hk, _T("trigger_key"), 0, REG_DWORD, (PBYTE)&dwData, sizeof(PDWORD));
Here is my code to retrieve the value
Code:
HKEY hk;
DWORD dwType;
DWORD dwLength;
TCHAR val[120];
RegOpenKeyExA(HKEY_CURRENT_USER, "SOFTWARE\\MacroKeys", 0, KEY_QUERY_VALUE, &hk);
RegQueryValueEx(hk, _T ( "trigger_key" ), NULL, NULL, (LPBYTE)val, &dwLength);
trigger_key = _ttoi ( val );
Any help will be appreciated.
Thanks,
Matt N