Old 6th January 2005, 22:20   #1
Junior Member
Join Date: Nov 2004
Posts: 8
Question REG_MULTI_SZ reader problem


I am trying to use the REG_MULTI_SZ reader posted in the Archives and am failing to get it to run for me.

I would like to read the PagingFiles memory setting -- and then set them if they are not correct. After I get the read method to work, I will try the writer.

I only edited the three lines between the "Edited this" and "Stop editing" AND I took out the 'bla' and put in the ${Value} about line 86:
System::Call "${RegQueryValueEx}(r4, ${VALUE}, 0, 0, r1, r2) .r3"

I keep getting: "Can't query registry value (2)[2]"

Also, where can I read about the meaning of a system call function like: System::Call "*(i) i (0) .r0"
I am having trouble understanding that call and similar ones.

Thanks to all.

Here is the code:

OutFile "REG_MULTI_SZ Reader.exe"

Name "REG_MULTI_SZ Reader"

ShowInstDetails show

!define HKEY_CLASSES_ROOT 0x80000000
!define HKEY_CURRENT_USER 0x80000001
!define HKEY_LOCAL_MACHINE 0x80000002
!define HKEY_USERS 0x80000003
!define HKEY_PERFORMANCE_DATA 0x80000004
!define HKEY_PERFORMANCE_TEXT 0x80000050
!define HKEY_CURRENT_CONFIG 0x80000005
!define HKEY_DYN_DATA 0x80000006

!define KEY_QUERY_VALUE 0x0001

!define REG_MULTI_SZ 7

!define RegOpenKeyEx "Advapi32::RegOpenKeyExA(i, t, i, i, i) i"
!define RegQueryValueEx "Advapi32::RegQueryValueExA(i, t, i, i, i, i) i"
!define RegCloseKey "Advapi32::RegCloseKeyA(i) i"

####### Edited this!

!define SUB_KEY "SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management"
!define VALUE "PagingFiles"

####### Stop editing

Section "Read"
StrCpy $0 ""
StrCpy $1 ""
StrCpy $2 ""
StrCpy $3 ""
SetPluginUnload alwaysoff
System::Call "*(i) i (0) .r0"
System::Call "*(i) i (0) .r1"
System::Call "*(i) i (0) .r2"
System::Call "${RegOpenKeyEx}(${ROOT_KEY}, '${SUB_KEY}', \

StrCmp $3 0 goon
MessageBox MB_OK|MB_ICONSTOP "Can't open registry key! ($3)"
Goto done

System::Call "*$0(&i4 .r4)"
System::Call "${RegQueryValueEx}(r4, '${VALUE}', 0, r1, 0, r2) .r3"

StrCmp $3 0 read
MessageBox MB_OK|MB_ICONSTOP "Can't query registry value! ($3)"
Goto done


System::Call "*$1(&i4 .r3)"

StrCmp $3 ${REG_MULTI_SZ} multisz
MessageBox MB_OK|MB_ICONSTOP "Registry value no SZ_MULTI_SZ! ($3)"
Goto done


System::Call "*$2(&i4 .r3)"

StrCmp $3 0 0 multiszalloc
MessageBox MB_OK|MB_ICONSTOP "Registry value empty! ($3)"
Goto done


System::Free $1
System::Alloc $3
Pop $1

StrCmp $1 0 0 multiszget
MessageBox MB_OK|MB_ICONSTOP "Can't allocate enough memory! ($3)"
Goto done


System::Call "${RegQueryValueEx}(r4, ${VALUE}, 0, 0, r1, r2) .r3"

StrCmp $3 0 multiszprocess
MessageBox MB_OK|MB_ICONSTOP "Can't query registry value! ($3)[2]"
Goto done


StrCpy $4 $1


System::Call "*$4(&t${NSIS_MAX_STRLEN} .r3)"
StrCmp $3 "" done
DetailPrint $3
StrLen $5 $3
IntOp $4 $4 + $5
IntOp $4 $4 + 1
Goto loop


System::Free $2
System::Free $1

StrCmp $0 0 noClose
System::Call "${RegCloseKey}(r0)"


SetPluginUnload manual
System::Free $0
jfellis is offline   Reply With Quote
Old 7th January 2005, 10:38   #2
[NSIS Dev, Mod]
kichik's Avatar
Join Date: Oct 2001
Location: Israel
Posts: 11,343
I have removed 'bla' from Archive page. I have already fixed the script in the Useful Information section of the documentation, but apparently I forgot to fix it in the Archive.

As for your error, try quoting ${VALUE}. It should work then.

System::Call "*(i) i (0) .r0" creates a structure with one integer in it. It actually just allocates four bytes for an integer. You should be able to find information about that at the end of the System plug-in documentation.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 7th January 2005, 16:19   #3
Junior Member
Join Date: Nov 2004
Posts: 8

You guys are a great help and NSIS is amazing.

jfellis is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump