treizesegments
19th December 2005 07:26 UTC
Pocket PC Registry with RAPI.DLL
Hello,
I want to read data from the PocketPC Registry.
I use this code :
System::Call "rapi::CeRapiInit() i .r0"
; Recherche la clé Ident
; LONG CeRegOpenKeyEx( HKEY hKey, LPCWSTR lpszSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
System::Call "rapi::CeRegOpenKeyEx(i, w, i, i, *i) i(0x80000002, 'Ident', 0, 0, .r1) .r0"
; LONG CeRegQueryValueEx( HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved,LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData );
System::Call "rapi::CeRegQueryValueEx(i, w, i, *i, i, *i) i(r1., 'Name', 0, .r2, 0, .r3) .r0"
; LONG CeRegQueryValueEx( HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved,LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData );
System::Call "rapi::CeRegQueryValueEx(i, w, i, *i, *t, *i) i(r1., 'Name', 0, .r2, .r4, .r3) .r0"
I can read type of data and its number of bytes with the second call. But when I want to read the data itself (third call), the CeRegQueryValueEx function returns ERROR_FILE_NOT_FOUND or E_FAIL (0x80004005) error code.
I can't find the correct parameter type or I forget an important initialization !!! Somebody have an idea ? Thanks.
Instructor
19th December 2005 14:51 UTC
Maybe something like this (I can't test it):
Name "Output"
OutFile "Output.exe"
Section
System::Call "rapi::CeRapiInit() i .r0"
System::Call "rapi::CeRegOpenKeyEx(i, w, i, i, *i) i(0x80000002, 'Ident', 0, 0, .r1) .r0"
System::Call "rapi::CeRegQueryValueEx(i, w, i, *i, i, *i) i(r1., 'Name', 0, 0, 0, .r2) .r0"
System::Call "*$2(&i4 .r3)"
System::Alloc $3
Pop $3
System::Call "rapi::CeRegQueryValueEx(i, w, i, *i, *i, *i) i(r2., 'Name', 0, .r4, .r3, .r2) .r0"
StrCpy $5 $3
StrCpy $6 $2
System::Call "*$4(&i4 .r7)"
System::Call "*$5(&t${NSIS_MAX_STRLEN} .r8)"
System::Call "*$6(&i4 .r9)"
System::Free $2
System::Free $3
System::Free $4
System::Free $5
System::Free $6
MessageBox MB_OK "Type={$7}$\nValue={$8}$\nLen={$9}"
SectionEnd
treizesegments
19th December 2005 16:33 UTC
It's making a fatal error on this line :
System::Call "*$2(&i4 .r3)"
$2 equals 20 after the previous instruction.
I saw this king of code in another example but, i can't understand what it's doing :
System::Call "*$4(&i4 .r7)"
System::Call "*$5(&t${NSIS_MAX_STRLEN} .r8)"
System::Call "*$6(&i4 .r9)"
Can you explain me quickly ?
Instructor
19th December 2005 18:04 UTC
System::Call "*$2(&i4 .r3)"
You use this structure to reach the number. $2 it is the pointer to the registry value lenght number, $3 its an object (number) on which $2 points. Try to replace CeRegOpenKeyEx line with
System::Call "*(i) i (0) .r1"
System::Call "rapi::CeRegOpenKeyEx(i, w, i, i, *i) i(0x80000002, 'Ident', 0, 0, r1) .r0"
MessageBox MB_OK '$0'