Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Apply Registry changes immediately (c++ question)

  1. #1
    Senior Member
    Join Date
    Nov 2001
    Posts
    257

    Apply Registry changes immediately (c++ question)

    Lets say to maintain a level of security on a windows system you need to make changes to the registry at every logon. Making the changes is easy (small c++ app called from logon script), however they dont seem to go into effect until the user logs off and back on to the system.

    Is there a way to force the changes into effect immediately? Through the c++ app or other system command that can be called from the login script? One example would be the current wallpaper.

    PS - I've been gone from the AO community for quite some time, it's good to be back!
    -Shkuey
    Living life one line of error free code at a time.

  2. #2
    Senior Member
    Join Date
    Jun 2003
    Posts
    236
    I think what you need to is to ensure the logon script runs first.
    Registry changes will take place right away but the executing program probably gets these values right when it starts up so sequence of events would be important in your case..now the next??? can you enforce sequential execution of logon programs
    That which does not kill me makes me stronger -- Friedrich Nietzche

  3. #3
    Senior Member
    Join Date
    Nov 2001
    Posts
    257
    Thanks for the comments.

    The problem is that registry changes are not all applied immediately. You can test this yourself, open regedit and navigate to HKEY_CURRENT_USER/Control Panel/Desktop and change the 'Wallpaper' value. You'll notice that your wallpaper does not change immediately, however if you log off and then log back in again the new wallpaper will be displayed.

    So what I need is some type of api call that will force the operating system to refresh this information, or a system command that will do the same.
    -Shkuey
    Living life one line of error free code at a time.

  4. #4
    Not sure if applicable to what you're trying to do...

    But if you're using a version of Win95 or Win98 you can kill the explorer.exe process and refuse the reboot. This will cause it to open a new explorer.exe process with the new registry settings... (Was a nifty trick I found and useed on old PI 133mhz and slower systems to save myself the reboot time)

    Doesn't work with Win2K (probably not XP either) as they won't restart a new explorer process automatically...

    Figurred this could point you in right direction if nothing else.

    RRP

  5. #5
    Senior Member
    Join Date
    Sep 2003
    Posts
    279
    i would like to recommend that if you have never meddes with your registry before that you take caution when doing so in the future.
    AntiOnline Quick Forum Version 2b Click Here
    10010101000000110010001100111

  6. #6
    I think the registry changes are made immediately, but the problem is that they are not propogated to all applications - that is, you change the wallpaper, but the explorer application does not refresh its wallpaper source. I have done a number of bits of work that update the registry and they have always updated immediately.

    My first thought would be to check the windows messages, and see if there is one to notify applications of a registry update. Or of Wallpaper updates or something relating to this. Sending this message either globally or to the explorer.exe should make it do what you want.

    If I get a chance, I will look up my windows message reference to see.

  7. #7
    Senior Member
    Join Date
    Nov 2001
    Posts
    257
    That would be great Schrodinger, if you could. I did some googling on the subject and didnt come up with much of anything.
    -Shkuey
    Living life one line of error free code at a time.

  8. #8
    I can't make any promises on this, as I work in VB, and am using a 5 year old reference book. So this may at least help you to move towards the answer.

    It would seem that if you broadcast the WM_SETTINGCHANGE message ( &H1A ), this will hit all top level windows telling them a system-wide change has been made. I cannot be certain that this will include a wallpaper change, but this would seem to fit. If not, you may need to chase down some similar windows messages.

    I hope this is helpful.

  9. #9
    Senior Member
    Join Date
    Nov 2001
    Posts
    257
    Thanks for the help.

    I dig some more digging and found a SystemParametersInfo() function in the windows library that can change all kinds of these things, most without touching the registry directly. So, I think I'm gonna stick with using that for these purposes.
    -Shkuey
    Living life one line of error free code at a time.

  10. #10
    That sounds good, but bear in mind that you may have to still tell the system that things have changed. But hopefully not.

    Hope you can get this sorted.

Posting Permissions

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