Old 27th February 2005, 18:58   #1
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Problem with !define

Is there any way to pass this code?

code:
Name "RegSearch"
OutFile "RegSearch.exe"

!macro RegSearch _ROOTKEY
!define _ROOT ${_ROOTKEY}
Call RegSearch
!macroend

Function RegSearch
EnumRegKey $0 ${_ROOT} "" 1
FunctionEnd

Section
!insertmacro RegSearch HKLM
MessageBox MB_OK "$0"
SectionEnd

Instructor is offline   Reply With Quote
Old 28th February 2005, 12:02   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Are you saying that ${_ROOT} has no value in the RegSearch function call?

Edit: Oh I see. Just use Push ${_ROOTKEY} and in your Function Pop it into a variable.

-Stu
Afrow UK is offline   Reply With Quote
Old 28th February 2005, 15:25   #3
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
${_ROOT} can't be a variable

It seems like functions compiles first and then macros and sections.

I see only one solution, but it's not comfortably for the user:

code:
Function RegSearch
!define _ROOT HKLM
EnumRegKey $0 ${_ROOT} "" 1
FunctionEnd



May be there is another way.
Instructor is offline   Reply With Quote
Old 28th February 2005, 16:22   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
The only suggestion that I can think of, is that you have multiple copies of the RegSearch functions with different names (i.e. RegSearch_HKLM) which is called like so:
code:

!macro RegSearch _ROOTKEY
Call RegSearch_${_ROOTKEY}
!macroend



You are right that the function is only compiled once, therefore you cannot change the value of ${_ROOT}.

-Stu
Afrow UK is offline   Reply With Quote
Old 1st March 2005, 09:24   #5
kike_velez
Member
 
Join Date: Jun 2004
Location: Barcelona
Posts: 57
What´s about a change the order

This compile for me:

code:

Name "RegSearch"
OutFile "RegSearch.exe"

!macro RegSearch _ROOTKEY
!define _ROOT ${_ROOTKEY}
Call RegSearch
!macroend



Section
!insertmacro RegSearch HKLM
MessageBox MB_OK "$0"
SectionEnd

Function RegSearch
EnumRegKey $0 ${_ROOT} "" 1
FunctionEnd




Best Regards
kike_velez is offline   Reply With Quote
Old 1st March 2005, 10:48   #6
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
kike_velez and Afrow UK thanks.
Instructor is offline   Reply With Quote
Old 1st March 2005, 18:48   #7
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
If you're trying to pass HKLM for all users and HKCU for current user, see SHCTX in the latest CVS version.

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 23rd March 2005, 10:42   #8
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 671
Is it possible in future to change all root_key (HKCR|HKLM|HKCU|HKU|HKCC|HKDD|HKPD) at runtime?
Instructor is offline   Reply With Quote
Old 24th March 2005, 15:48   #9
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
I doubt it. It'll break backwards compatibility because it'll be converted into defines. You can submit a feature request, if one doesn't already exist, to keep the request from fading away in the forum.

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
Reply
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