Apply changes in Registry immediately - DonationCoder.com
Welcome Guest.   Make a donation to an author on the site August 03, 2015, 01:38:05 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2013! Download dozens of custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Apply changes in Registry immediately  (Read 801 times)
Yaron
Participant
*
Posts: 14

View Profile Give some DonationCredits to this forum member
« on: July 03, 2015, 03:42:51 PM »

Hello,

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

Formatted for Javascript with the GeSHI Syntax Highlighter [copy or print]
  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.
Logged
MilesAhead
Supporting Member
**
Posts: 6,064



View Profile WWW Give some DonationCredits to this forum member
« Reply #1 on: July 03, 2015, 04:30:08 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/
Logged

Yaron
Participant
*
Posts: 14

View Profile Give some DonationCredits to this forum member
« Reply #2 on: July 03, 2015, 05:01:32 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. smiley

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

Have a great weekend.
Logged
MilesAhead
Supporting Member
**
Posts: 6,064



View Profile WWW Give some DonationCredits to this forum member
« Reply #3 on: July 03, 2015, 05:19:50 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. smiley

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.
Logged

Yaron
Participant
*
Posts: 14

View Profile Give some DonationCredits to this forum member
« Reply #4 on: July 03, 2015, 06:22:21 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.
Logged
MilesAhead
Supporting Member
**
Posts: 6,064



View Profile WWW Give some DonationCredits to this forum member
« Reply #5 on: July 04, 2015, 01:12:44 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.microsoft.co...amp;MSPPError=-2147217396

Logged

mouser
First Author
Administrator
*****
Posts: 34,836



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #6 on: July 04, 2015, 02:02:58 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.
Logged
Yaron
Participant
*
Posts: 14

View Profile Give some DonationCredits to this forum member
« Reply #7 on: July 04, 2015, 04:25:56 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:

Formatted for Javascript with the GeSHI Syntax Highlighter [copy or print]
  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.
Logged
MilesAhead
Supporting Member
**
Posts: 6,064



View Profile WWW Give some DonationCredits to this forum member
« Reply #8 on: July 04, 2015, 05:41:28 PM »

@MilesAhead,

Persistent as always. smiley 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.
Logged

Yaron
Participant
*
Posts: 14

View Profile Give some DonationCredits to this forum member
« Reply #9 on: July 04, 2015, 06:21:11 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.mozillazine.org/viewforum.php?f=19

I wish you the very best.
Logged
MilesAhead
Supporting Member
**
Posts: 6,064



View Profile WWW Give some DonationCredits to this forum member
« Reply #10 on: July 05, 2015, 08:38:27 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.mozillazine.org/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.
Logged

Yaron
Participant
*
Posts: 14

View Profile Give some DonationCredits to this forum member
« Reply #11 on: July 05, 2015, 06:04:42 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. 
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.051s | Server load: 0.02 ]


Share on Facebook
submit to reddit