MAXScript vs Windows registry

MAXScript vs Windows registry

Anonymous
Not applicable
1,478 Views
2 Replies
Message 1 of 3

MAXScript vs Windows registry

Anonymous
Not applicable

Hi all!

 

I'm really confused with MXS's abilities in registry viewing.

The Help says:

"

registry.queryValue <HKey> <string valueName> type:<&name> value:<&value> expand:<bool>

Gets the data type and value of the specified value of the open HKey.
...
If the query is successful, the data type will be written to the type keyword variable.
If the query is successful and the data type is one of the following supported data types, the data value will be written to the value keyword variable.
...
Other data types that may be returned, but are not currently supported, are:
#REG_BINARY

"

But I need to get a value of type REG_BINARY! Why MXS fails every time I want to do something cool?Smiley Surprised

 

Actually, I'm trying to get actual monitor size from EDID(that method's described as the most efficient since Windows 7 gives too large values using GetDeviceCaps(IntPtr hdc, int nIndex); from WINAPI).

 

Is there any way to get such registry value?

Code's in the attach.

0 Likes
1,479 Views
2 Replies
Replies (2)
Message 2 of 3

Swordslayer
Advisor
Advisor

Do you mind a bit of .NET?

 

fn GetEDID =
(
	local reg = dotNetClass "Microsoft.Win32.Registry"
	local displays = reg.LocalMachine.OpenSubKey @"SYSTEM\CurrentControlSet\Enum\DISPLAY"

	for displayName in displays.GetSubKeyNames() do
	(
		format "MonitorName: %\n" displayName
		local displayKey = displays.OpenSubKey displayName

		for GUIDName in displayKey.GetSubKeyNames() do
		(
			format "\tGUID: %\n" GUIDName
			local GUIDKey = displayKey.OpenSubKey GUIDName

			for subName in GUIDKey.GetSubKeyNames() where subName == "Device Parameters" do
			(
				local EDID = (GUIDKey.OpenSubKey subName).GetValue "EDID"
				
				if EDID != undefined do
				(
					with printAllElements on format "\t\tEDID: %\n" EDID
					format "\t\tMonitor Width: % cm\n" EDID[22]
					format "\t\tMonitor Height: % cm\n" EDID[23]
				)
			)
		)
	)
)

GetEDID()

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

Well...I've already solved that by using .NET:
EDIDdata = ((DotNETClass "Microsoft.Win32.Registry").GetValue EDIDPath "EDID" undefined)
But I don't know if I like it or not, because nearly a half of my big project uses runtime generated .NET library code, instead of MXS(which just fails at some cases, because of some bugs or stupid MAX behavior).

0 Likes