Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Registry Help
#1
Hi Gintaras,
I am trying to retrieve data from the registry in QM3, can't seem to get the actual value that I can in QM2.

QM2 Code was:
/ Macro182

;; HKEY_CURRENT_USER\Software\GinDi\QM2\Test

str rkey = "Software\GinDi\QM2\Test\"
str name = "ADD1"
str s1

rget s1 "ADD1" rkey
out s1

;;    Output:
;;        1051 FAIRFAX LN
___________________________________________

QM3 Code is:
{
string userRoot = "HKEY_CURRENT_USER";
string subkey = @"Software\GinDi\QM2\Test\";
string keyName = userRoot + "\\" + subkey;
string name = "ADD1";
string data = "ADD1";

Print(ARegistry.GetString(out data, name, keyName));
}}
__________________________________________
*The Key is "Test" which is under "HKEY_CURRENT_USER\Software\GinDi\QM2\" and String Value = ADD1
*The data is "1051 FAIRFAX LN", but the code is returning, False

Any help is greatly appreciated. Thanks,
ScottF
#2
Here returns true and data. My QM3 version is newer, but registry functions didn't change during that time.

.NET has registry functions too:

C# code:
// script "" //.
using Au; using System;
using Microsoft.Win32;
partial class Script { [STAThread] static void Main(string[] a) => new Script(a); Script(string[] args) { //;;;

string userRoot = "HKEY_CURRENT_USER";
string subkey = @"Software\GinDi\QM2\Test\";
string keyName = userRoot + @"\" + subkey;
string name = "ADD1";

#if tru
if(ARegistry.GetString(out string data, name, keyName)) Print(data); else Print("not found");
#else
string data = Registry.GetValue(keyName, name, null) as string;
Print(data);
#endif



}

void Print(object o) => AOutput.Write(o);
}
#3
When I run this,  I get error converting object to string:

Compilation: 1 errors
<open "<0x100000011>|21|39">Script5.cs(21,39): error CS1503: Argument 1: cannot convert from 'object' to 'string'

This line, #12, is like gray in color, not sure if helps debug.
if(ARegistry.GetString(out string data, name, keyName)) Print(data); else Print("not found");
#4
Sorry, must be
void Print(object o) => AOutput.Write(o?.ToString());

The #if disables the gray code, and is used the colored code. Add letter e to tru and it will use other code.
#5
Perfect, That did the trick.
Thanks Gintaras.


Forum Jump:


Users browsing this thread: 1 Guest(s)