2

I am modifying the registry value found at:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects.

For my purposes it can store a DWORD value of 0, 1, 2. These values correspond to the Visual Effects radio buttons under Performance Options in Windows 7; "Let Windows choose what's best for my computer", "Adjust for best appearance", and "Adjust for best performance" respectively.

If you use the actual "Performance Options" screen and make a change and click apply, the visual settings in Windows will reload as expected. If you programatically change the value, it doesn't do anything.

Is there a way to accomplish this in code?

Harry Johnston
  • 35,639
  • 6
  • 68
  • 158
Brandon
  • 261
  • 1
  • 8
  • 17
  • 6
    That value is just for show. It merely tells the control panel what radio button to select the next time you open it. It doesn't actually *do* anything. – Raymond Chen Mar 27 '12 at 20:43
  • 1
    @RaymondChen Good to know! Is there a way of achieving my goal? – Brandon Mar 27 '12 at 20:49
  • 1
    Might I ask why you are programmatically trying to modify something that should be a user-configured option? This is something an application should never need to do, as it's based on the user experience with the specific hardware that Windows is being run on. (If it were something your app should be able to do, there would be a published API to use to do it, or a flag value in `SystemParametersInfo` to change it. There isn't.) – Ken White Mar 27 '12 at 20:58
  • 1
    It's not clear what your goal is. Do you want to change the performance option, or do you just want to play with the radio button? To change the performance option, use the corresponding API, such as `SystemParametersInfo(SPI_SETNONCLIENTANIMATION)`. – Raymond Chen Mar 27 '12 at 21:05
  • 1
    @KenWhite: Often the reason is so that an administrator can change one or more options for a whole bunch of users/machines rather than having to try to explain to the end users how to do it. If there isn't a corresponding group policy setting (I don't know whether there is or not in this case) a logon script is often a convenient alternative. – Harry Johnston Mar 27 '12 at 22:02
  • @HarryJohnston, that's fine for a software setting or something. Presumably in this case the admin isn't asking the end-user to take the PC out of the box and set it up, though; this is a setting that either should have been configured before it went to the user or should be left alone for the user to configure based on the performance of the system. (This isn't the type of setting an admin should normally need to configure on the fly; if mass or group config is required, it should have been done pre-delivery to the user. Not sure how hardware is down-graded en-masse to need this, IOW. – Ken White Mar 27 '12 at 22:06
  • @KenWhite: ideally, sure, you do it beforehand, but you still want to automate it if at all possible. Even if you're using cloning, recommended practice is to automate setup for the master image. (Other possibilities are that you didn't do quite enough testing before shipping these particular computers to the users, or that you're deploying a new application that has trouble with the default settings.) – Harry Johnston Mar 27 '12 at 22:15
  • 2
    @KenWhite It needs to be programatically set so that I can do it before running a series of medical tests presented to the user that require as close to millisecond accuracy as possible. We have found through extensive testing that "Let Windows Handle" causes an increased in timing inaccuracy. Furthermore users aren't very computer literate and being able to give them a "HEY SILLY CLICK THIS BUTTON" option would be optimal. – Brandon Mar 28 '12 at 04:46

2 Answers2

3

To expand on Raymond's comment:

The Visual Effects tab has fifteen individual performance options. The radio button "Adjust for best appearance" turns them all on. "Adjust for best performance" turns them all off. "Let Windows choose what's best for my computer" presumably sets them based on the Windows Experience index, or some similar method.

You aren't going to be able to implement "Let Windows choose what's best for my computer" from an application, or at least not easily. But you should be able to implement the other two options, by using SystemParametersInfo and setting each of the fifteen individual options.

You'll need to identify the fifteen settings corresponding to the options in the Visual Effects tab: some will be reasonably obvious, others may be a matter of trial and error. Hopefully if you set the radio button to "Custom", when you open the Visual Effects tab you'll see the changes your application has made, so you'll be able to tell whether you've go the right setting or not.

You might want to set the registry value for the radio button as well so that the user sees the right thing if they open the control panel.

Addendum: for the scenario you describe, you'll probably want to read each of the current settings first and restore them afterwards. Either read and restore the registry setting too, or just don't touch it.

Harry Johnston
  • 35,639
  • 6
  • 68
  • 158
1

To my knowledge, registry works like any other storage.

When applications need a value from the registry, they check it. Most applications only read the registry when they first start up. You usually have to restart the relevant application if you manually change one of its registry entries. Even if a restart is not required, you will still need to figure out how to trigger that specific application to re-retrieve that specific entry.

So to answer the your question, there is no magic "refresh" command that will push the current value of a registry entry to the appropriate application(s).

Now, the real question you want to ask is "Is there a way to force Windows to reload the Performance Options?". I know of no way to do this.

If there is a WinApi call available, it will probably have you provide the new value and it will take care of updating the registry.

cadrell0
  • 17,109
  • 5
  • 51
  • 69