Results 1 to 34 of 34

Thread: [RESOLVED by schoolbusdrive]Save to registry, but it doesn't!

Threaded View

  1. #6
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Save to registry, but it doesn't!

    Quote Originally Posted by aikidokid
    I am only assuming that because there is not already a key for this in the registry, that it doesn't write to it.
    That is correct. RegSetValueEx requires an pre-existing subkey if you're not writing a value directly to the hive's root. Use RegCreateKeyEx to create the subkey first.

    As an aside, it's not good practice to use KEY_ALL_ACCESS, as this is likely to fail if you're not logged-in as admin. Use KEY_CREATE_SUB_KEY and KEY_SET_VALUE as appropriate.

    EDIT From MSDN:
    Unlike the RegCreateKeyEx function, the RegOpenKeyEx function does not create the specified key if the key does not exist in the registry.
    The initial error will actually occur in RegOpenKeyEx.
    Last edited by schoolbusdriver; Mar 7th, 2007 at 12:31 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width