StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
niczoom  
#1 Posted : Monday, February 8, 2021 4:57:37 AM(UTC)
niczoom

Rank: Newbie

Reputation:

Groups: Approved
Joined: 2/5/2021(UTC)
Posts: 5
Australia

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.
Rob  
#2 Posted : Monday, February 8, 2021 5:58:40 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
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.8

EDIT: 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

thanks 1 user thanked Rob for this useful post.
niczoom on 2/8/2021(UTC)
Rob  
#3 Posted : Monday, February 8, 2021 6:19:09 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
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.8

Last parameter is the default value to return if the AppliedDPI entry doesn't exist.
thanks 2 users thanked Rob for this useful post.
niczoom on 2/8/2021(UTC), thexray on 7/26/2023(UTC)
Users browsing this topic
Guest
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.