aemik
11th January 2008 15:52 UTC
Need a simple Macro
I dont know how to write a macro. So I need your help:
I have this code:
ClearErrors
ReadRegStr $0 HKLM "Software\Test\Test" "X"
IfErrors 0 +2
WriteRegStr HKLM "Software\Test\Test" "X" myValue
I have a lot of Regkeys. And I only want to write them if they not exist. So I want to give the RegKey and his Value to a macro (or function?).
Like this: ${myRegistry::Key::Keyname::Value}
Is it possible???
Thank you very much for your help
aemik
aemik
11th January 2008 16:06 UTC
Just use a macro:
code:!macro _CreateRegInstruction Type Root Key Name Value
Push $R0
ClearErrors
ReadReg${Type} $R0 `${Root}` `${Key}` `${Name}`
Pop $R0
IfErrors 0 +2
WriteReg${Type} `${Root}` `${Key}` `${Name}` `${Value}`
!macroend
!macro _WriteRegDWORD Root Key Name Value
!insertmacro _CreateRegInstruction DWORD `${Root}` `${Key}` `${Name}` `${Value}`
!macroend
!define WriteRegDWORD `!insertmacro _WriteRegDWORD`
!macro _WriteRegStr Root Key Name Value
!insertmacro _CreateRegInstruction Str `${Root}` `${Key}` `${Name}` `${Value}`
!macroend
!define WriteRegStr `!insertmacro _WriteRegStr`
!macro _WriteRegBin Root Key Name Value
!insertmacro _CreateRegInstruction Bin `${Root}` `${Key}` `${Name}` `${Value}`
!macroend
!define WriteRegBin `!insertmacro _WriteRegBin`
${WriteRegDWORD} HKLM `Software\MyApp` `Blah1` 1
${WriteRegBin} HKLM `Software\MyApp` `Blah2` ABCD
${WriteRegStr} HKLM `Software\MyApp` `Blah3` Hello
Stu
-----------------
this is what i meant. Thank you very very much.
aemik
Afrow UK
11th January 2008 17:19 UTC
Code shortened:
!macro _WriteReg Type Root Key Name Value
Push $R0
ClearErrors
ReadReg${Type} $R0 `${Root}` `${Key}` `${Name}`
Pop $R0
IfErrors 0 +2
WriteReg${Type} `${Root}` `${Key}` `${Name}` `${Value}`
!macroend
!define WriteRegDWORD `!insertmacro _WriteReg DWORD`
!define WriteRegBin `!insertmacro _WriteReg Bin`
!define WriteRegStr `!insertmacro _WriteReg Str`
Stu