PDA

View Full Version : Possible bug in SessionVar.Expand



bnasmmbaker
12-05-2005, 11:35 AM
Hello,
I came across an odd bug in use of SessionVar.Expand. The expansion takes place, and I get what looks like a valid string using Debug.Print. However, passing this value to Registry.GetValue results in a no key found error. If I replace SessionVar.Expand with SessionVar.Get and just use string concatenation, it works just fine.

Buggy code:
g_RegRoot = SessionVar.Expand("Software\\BNA Software\\%ProductName%\\Application State";
Debug.Print( g_RegRoot );
local v = Registry.GetValue(HKEY_CURRENT_USER,g_RegRoot,"Setting",false);


Good code:
Buggy code:
g_RegRoot = "Software\\BNA Software\\"..SessionVar.Get("%ProductName%").."\\Application State";
Debug.Print( g_RegRoot );
local v = Registry.GetValue(HKEY_CURRENT_USER,g_RegRoot,"Setting",false);

Thanks
Mark

Mark
12-07-2005, 08:48 AM
Hi bnasmmbaker,

I've tested this out and have not been able to make it fail, using your code below on a TrueUpdate 2.0 registry key.

If the string g_RegRoot is correct when it gets passed to Registry.GetValue() it should not matter how it was created. Are you sure that the g_RegRoot value is the same with each creation method?

If you can create a script that fails on a common registry key, please post it here and we will use it to debug this issue.