topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday December 6, 2024, 10:52 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Apply changes in Registry immediately  (Read 7375 times)

Yaron

  • Participant
  • Joined in 2014
  • *
  • default avatar
  • Posts: 22
    • View Profile
    • Donate to Member
Apply changes in Registry immediately
« on: July 03, 2015, 03:42 PM »
Hello,

The following code (in a Firefox extension) toggles the value of the "FontSmoothing" Registry-Key.

Code: Javascript [Select]
  1. let regFontSmooth = Components.classes["@mozilla.org/windows-registry-key;1"].createInstance(Components.interfaces.nsIWindowsRegKey);
  2. regFontSmooth.open(regFontSmooth.ROOT_KEY_CURRENT_USER, "Control Panel\\Desktop", regFontSmooth.ACCESS_ALL);
  3. regFontSmooth.writeStringValue("FontSmoothing", regFontSmooth.readStringValue("FontSmoothing") == 0 ? 2 : 0);
  4. regFontSmooth.close();

How do I apply the changes immediately (without a reboot or restarting Windows Explorer?

Thank you.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Apply changes in Registry immediately
« Reply #1 on: July 03, 2015, 04:30 PM »
I don't know about from inside extension code.  But AutoIt3  has a function EnvUpdate().  Short of logging off, then back on, or restarting Explorer, it is the best I have found so far.  I usually call it 3 times with perhaps a 1/2 second pause between.

Or you can just download the program UpdateEnv from my page:
http://milesaheadsoftware.org/

Yaron

  • Participant
  • Joined in 2014
  • *
  • default avatar
  • Posts: 22
    • View Profile
    • Donate to Member
Re: Apply changes in Registry immediately
« Reply #2 on: July 03, 2015, 05:01 PM »
Hello my friend,

I hope you're doing well.

Thank you for this reply.
And also many thanks for "MoveIt" and "Process Counter"; - I use both frequently and really enjoy them.

I think there's a way to update the registry from a Firefox extension without using external applications.
So, I'd rather wait. Please don't consider this ungrateful. :)

Can you think of other good forums I can post this question? I'd appreciate that.

Have a great weekend.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Apply changes in Registry immediately
« Reply #3 on: July 03, 2015, 05:19 PM »
Hello my friend,

I hope you're doing well.

Thank you for this reply.
And also many thanks for "MoveIt" and "Process Counter"; - I use both frequently and really enjoy them.

I think there's a way to update the registry from a Firefox extension without using external applications.
So, I'd rather wait. Please don't consider this ungrateful. :)

Can you think of other good forums I can post this question? I'd appreciate that.

Have a great weekend.

Glad you enjoy using MoveIt.  The only stuff I ever wrote for browser integration were DLLs using the old Netscape Plugin API.  I have never attempted a modern extension.  Now and then I consider trying to do a simple one.  But I have no clue what programming forums handle that type of thing.  I thought browsers, excluding ActiveX stuff, were precluded from effecting the host OS environment?  If you could call a Windows API I would try the one used by SysInternals sync.exe program.  The author gets Windows to flush file buffers to disk simply by locking the volume, then releasing the lock.  It flushes file buffers but I don't know if it will flush the registry to disk.

Yaron

  • Participant
  • Joined in 2014
  • *
  • default avatar
  • Posts: 22
    • View Profile
    • Donate to Member
Re: Apply changes in Registry immediately
« Reply #4 on: July 03, 2015, 06:22 PM »
Hello MilesAhead,

Thanks again. I appreciate it.

The code I use does change the value in the registry; - it doesn't apply it immediately.
Your replies are very helpful. I'll wait a bit.

Best wishes.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Apply changes in Registry immediately
« Reply #5 on: July 04, 2015, 01:12 PM »
Hello MilesAhead,

Thanks again. I appreciate it.

The code I use does change the value in the registry; - it doesn't apply it immediately.
Your replies are very helpful. I'll wait a bit.

Best wishes.

I found this API call that may be worth reading.

https://msdn.microso...SPPError=-2147217396


mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Apply changes in Registry immediately
« Reply #6 on: July 04, 2015, 02:02 PM »
It's a shame but I don't believe there is truly a way to make the system readjust to some registry changes without a reboot.

Yaron

  • Participant
  • Joined in 2014
  • *
  • default avatar
  • Posts: 22
    • View Profile
    • Donate to Member
Re: Apply changes in Registry immediately
« Reply #7 on: July 04, 2015, 04:25 PM »
@MilesAhead,

Persistent as always. :) I'm truly grateful.

I think that "Components.interfaces.nsIWindowsRegKey" uses that API.

I posted the question here and Mike referred me to the SystemParametersInfo function.

So, the following code works:

Code: Javascript [Select]
  1. Components.utils.import("resource://gre/modules/ctypes.jsm");
  2. let lib = ctypes.open("user32.dll");
  3.  
  4. let fontSmooth = lib.declare("SystemParametersInfoW", ctypes.winapi_abi, ctypes.bool, ctypes.unsigned_int, ctypes.unsigned_int, ctypes.voidptr_t, ctypes.unsigned_int);
  5.  
  6. fontSmooth(0x004B, true, ctypes.voidptr_t(0), 0);   // 0x004B = SPI_SETFONTSMOOTHING. true/false = toggle font smoothing.
  7.  
  8. lib.close();

Best regards.

***
@mouser,

Thanks for replying. I really appreciate it.

Best regards.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Apply changes in Registry immediately
« Reply #8 on: July 04, 2015, 05:41 PM »
@MilesAhead,

Persistent as always. :) I'm truly grateful.

I think that "Components.interfaces.nsIWindowsRegKey" uses that API.

I posted the question here and Mike referred me to the SystemParametersInfo function.

So, the following code works:

Thanks for posting how you solved it.  I tried a little JavaScript back around the year 2000. (Just struggled with beginner code.)  I am glad to see it has some serious capabilities. Very cool.

Yaron

  • Participant
  • Joined in 2014
  • *
  • default avatar
  • Posts: 22
    • View Profile
    • Donate to Member
Re: Apply changes in Registry immediately
« Reply #9 on: July 04, 2015, 06:21 PM »
Hi MilesAhead,

Thank you.

I have very little experience in development; - I wouldn't know where to start creating a nice app like "MoveIt".
With your talent, I'm sure you could contribute a lot to Firefox and Firefox add-ons. I think you would enjoy it as well.

http://forums.mozill...g/viewforum.php?f=19

I wish you the very best.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Apply changes in Registry immediately
« Reply #10 on: July 05, 2015, 08:38 AM »
Hi MilesAhead,

Thank you.

I have very little experience in development; - I wouldn't know where to start creating a nice app like "MoveIt".
With your talent, I'm sure you could contribute a lot to Firefox and Firefox add-ons. I think you would enjoy it as well.

http://forums.mozill...g/viewforum.php?f=19

I wish you the very
 best.

It might be fun to try one of my own.  I wonder how soon they are going to start this extension signing crap.  It destroyed a fun community of MaxThon extension writers when they did signing there.

Yaron

  • Participant
  • Joined in 2014
  • *
  • default avatar
  • Posts: 22
    • View Profile
    • Donate to Member
Re: Apply changes in Registry immediately
« Reply #11 on: July 05, 2015, 06:04 PM »
Hi MilesAhead,

You should try. Best of luck.
The singed extensions policy is supposed to start in v40 (in about 6 weeks). I hope it won't be difficult to modify the relevant code.

Regards.