c++ - RegSetValueEx silently fails to write to HKLM -
i'm trying write in hkey_local_machine\software\microsoft\windows\currentversion\run c++ application this:
hkey key; if (regopenkeyex(hkey_local_machine, text("software\\microsoft\\windows\\currentversion\\run"), null, key_all_access, &key) == error_success){ if (regsetvalueex(key, text("lcr"), 0, reg_sz, (const byte*)runcmd.c_str(), (runcmd.size()+1)*sizeof(wchar_t)) != error_success){ cout << "error" ; }else{ cout << "ok" << endl; } regclosekey(key); }else{ cout << "error" ; } but silently fails , nothing happens!
tried both running normal user & running administrator.
problem?
the problem application subject uac registry virtualization. because did not include manifest in application, system drops xp (!) compatibility mode. when write restricted parts of registry under hklm, system re-directs them known virtual store under hkcu.
you should add manifest application no longer virtualized. if need write hklm need specify requireadministrator option in manifest application executed elevated rights.
probably next move take time read documentation linked above , sure understand implications of uac.
Comments
Post a Comment