OneDrive Developer Center (redirect)

Looking for the Live SDK?

OneDrive logo

The Live SDK 5.6 is now available

Find it on the OneDrive Dev Center, the new place to find samples, documentation, and other resources for integrating OneDrive into your app.
Choose your download

If you're using previous versions of the Live SDK, the Live SDK 5.5 reference is still available.

 locked
How do you make Windows reread the Registry? (Developing workaround for Visio bug)

    Question

  • I want to know how to make Windows reread the Registry. First, I will tell why I am writing a software workaround. I will present my code. Then I will explain what my code is not able to do. Then I will ask how to make Windows reread the Registry in C# (or VB).

     

     

    Why I Am Writing a Software Workaround

     

    I'm using Visio UML to design software. One thing that was annoying me about Visio is when I used "Insert Object" to open a supplemental PDF document, the document opens maximized. I saw no way to change this to open to restore-size. So, I changed to inserting hyperlinks. I saw no built in way to use a double-click to open the hyperlink. I have to right-click and select the hyperlinked file I want to open. Even so, hyperlink did open the PDF in restore-size instead of maximized. The only thing is the Visio hyperlinks has a bug. So now the Visio hyperlink bug annoys me.

     

    The Visio hyperlink bug is after creating a hyperlink or after opening a hyperlink, Visio sets Animate Windows to on. I don't want Animate Windows on. And switching to Animate Windows has nothing logically relating it to opening a hyperlink. The annoyance will be lessened if I have a one-click solution to turn Animate Windows back off. So, that is why I am writing a software workaround.

     

    The software workaround will allow me to click on an icon on my desktop instead of opening up Computer Properties; Selecting "Advanced system settings" (which in Windows Vista puts you back to the familiar Windows XP System Properties dialog); advance tab is selected by default; select "Performance Settings" button; and finally unchecking "Animate windows when minimizing and maximizing". So, you can see how my one-click workaround will reduce my annoyance.

     

     

    My Code

     

    Here is my code for my utility to turn off Windows Animation:

     

    Code Snippet

    using System;

    using System.Collections.Generic;

    using System.Text;

    using System.Globalization;

    using Microsoft.Win32; // This allows access to Registry

     

    namespace Turn_Off_Animate_Win_MaxMin

    {

    class Turn_Off_Animate_Win_MaxMin_1

    {

    // My style of const

    private string RegKey() { return "HKEY_CURRENT_USER\\Control Panel\\Desktop\\WindowMetrics"; }

     

    // My style of const

    private string RegValName() { return "MinAnimate"; }

     

    // Called so I can see the before and after values in the Registry

    public object GetVal() { return Registry.GetValue( RegKey(), RegValName(), -1); }

     

    // Make the value returned from the Registry a string

    public string InterpretVal(object o) { return o.ToString(); }

     

    // Set the value in the Registry to off

    public void SetVal_Off() { Registry.SetValue( RegKey(), RegValName(), "0"); }

    }

     

    class Turn_Off_Animate_Win_MaxMin

    {

    static void Main_1(Turn_Off_Animate_Win_MaxMin_1 c)

    {

    c.InterpretVal(c.GetVal());

    c.SetVal_Off();

    c.InterpretVal(c.GetVal());

    }

     

    static void Main()

    {

    // Use Main_1 to avoid declaring inside a method

    Main_1(new Turn_Off_Animate_Win_MaxMin_1());

    }

    }

    }

     

     

     

     

    What My Code Is Not Able To Do

     

    My code successfully turns off the Windows Animation in the Registry. However, the windows do not stop animating until I reboot. The System Properties dialog makes the windows animation start and stop without rebooting. I suspect it has some way of making Windows reread the Registry. Come to think of it, and to my further annoyance, Visio has some way of changing the Registry to turn on windows animation AND of making the Registry change take immediately. Neither the System Properties nor Visio need a system reboot to make the Registry change take. However, my code does need a system reboot before the Registry change will take.

     

     

    How Do You Make Registry Changes Take Without System Reboot?

     

    I hope someone will please tell me how to make the Registry change take immediately. I'm using C#. But I'm okay if there is a solution in C# or VB. If I must, I can make use of a C++ solution as well.

     

    Am I in the right direction using the Registry? Or do I need to send some Windows message (if so which one(s)? ).

     

    I will appreciate your help.

     

    Ron

    Thursday, July 17, 2008 2:17 AM
OneDrive Developer Center (redirect)

Looking for the Live SDK?

OneDrive logo

The Live SDK 5.6 is now available

Find it on the OneDrive Dev Center, the new place to find samples, documentation, and other resources for integrating OneDrive into your app.
Choose your download

If you're using previous versions of the Live SDK, the Live SDK 5.5 reference is still available.