I don't understand why the following code fails when I execute it in a script (of Plus, of course) and the same code works perfectly in Visual Basic (typing it using VB syntax, of course).
I'm trying to access the registry, so first of all, I have to open it, using
RegOpenKeyEx, but it fails....
code:
var HKEY_CURRENT_USER = 0x80000001;
var KEY_ALL_ACCESS = 0xF003F;
var ret;
var key = Interop.Allocate(4);
var x = Interop.Allocate(10000);
ret = Interop.Call("advapi32.dll", "RegOpenKeyExW", HKEY_CURRENT_USER, "Software\\Patchou\\Messenger Plus! Live", 0, KEY_ALL_ACCESS, key);
if (ret != 0) {
Debug.Trace("" + ret + " " + Interop.GetLastError());
Interop.Call("kernel32.dll", "FormatMessageW", 0x00001000, 0, ret, 0, x, 1000, 0);
Debug.Trace(x.ReadString(0));
}
The output in the debug window is
quote:
2 0
El sistema no puede hallar el archivo especificado.
That means, in english: "The system can't find the specified file".
Seeing the "2 0", I understand that the function
RegOpenKeyEx fails, but GetLastError returns 0, ie: no error.
So it seems that it can't find the path "Software\Patchou\Messenger Plus! Live" under the HKCU branch of the registry. However, if I put only "Software", it opens it correctly. That, together with the fact that I can open it using VB, makes me think that Plus Live executes its scripts under another Windows account, therefore accessing another HKCU branch where there is no "Patchou" "folder". I know that's weird and stupid, but what else can it be?
Any ideas?
Thanks.