StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
Using the RegistryReadString function
Rank: Newbie
Groups: Approved
Joined: 2/5/2021(UTC) Posts: 5 Thanks: 6 times
|
Im stumped trying to use the RegistryReadString function. Im trying to access the registry key "AppliedDPI" from this path: "HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics". Ive tried numerous ways, for example:
var result = sp.RegistryReadString("HKEY_CURRENT_USER", "Control Panel\Desktop\WindowMetrics", "AppliedDPI", 1)
and many others but with no luck. Can someone please enlighten me on the correct path usage! I have read the script help without luck.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Yeah, so that stuff was added WAAAAY back in the beginning, and it also appears I completely missed the example scripts in the help attribute...I'll have to correct that. Here's getting the value as a string and a number: Code:var sAppliedDPI = sp.RegistryReadString(Registry.CurrentUser, "Control Panel\\Desktop\\WindowMetrics", "AppliedDPI", true);
sp.MessageBox(sAppliedDPI, "AppliedDPI String");
var nAppliedDPI = sp.RegistryReadNumber(Registry.CurrentUser, "Control Panel\\Desktop\\WindowMetrics", "AppliedDPI", true);
sp.MessageBox(nAppliedDPI, "AppliedDPI Number");
Note that Registry in the script resolves to this class: https://docs.microsoft.com/en-us/dotnet/api/microsoft.win32.registry?view=netframework-4.8EDIT: The reason I mention it was from the very beginning is because it's not very well thought out, just something I crammed in there to basically match the original S+ and I haven't revisited those functions since. They could use some work! Edited by user Monday, February 8, 2021 6:11:21 AM(UTC)
| Reason: Added additional explanation
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
For just getting a value, probably easier to just call the method directly. I might get rid of those functions altogether and just expose Microsoft.Win32 to the script engine, instead of this proprietary stuff. Code:var oAppliedDPI = Registry.GetValue("HKEY_CURRENT_USER\\Control Panel\\Desktop\\WindowMetrics", "AppliedDPI", 96);
sp.MessageBox(oAppliedDPI, "AppliedDPI Object Result");
https://docs.microsoft.com/en-us/dotnet/api/microsoft.win32.registry.getvalue?view=netframework-4.8Last parameter is the default value to return if the AppliedDPI entry doesn't exist.
|
2 users thanked Rob for this useful post.
|
|
|
StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
Using the RegistryReadString function
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close