Reading ini string error - Strange error
Hi all,
I am trying to read a particular value from the ini file.
a.ini (contents).
-----
data = c:\test
I got the following code from the nsis website and try to compiled it. It is compiling fine. But when it runs it gives error "Installer corrupted Invalid OpCode".
I want the value of key "data" into some variable which I can use it in my nsis script? Can anybody help me in this regard?
Regards
Pradeep
Code:
----
OutFile "test_ini.exe"
;${ReadINIStrNS} $R0 "D:\Build\Builds\Code\test.ini" "data"
Section "OgO Open File Association" SEC02
Push $0
Call ReadINIStrNS
;Pop $0
;${ReadINIStrNS} $0 "D:\Build\Builds\Code\test.ini" "data"
SectionEnd
Function ReadINIStrNS
Exch $R0 ; key
Exch
Exch $R1 ; ini file
Push $R2 ; ini file handle
Push $R3 ; key len
Push $R4
Push $R5
FileOpen $R2 $R1 r
IfErrors End
StrLen $R3 $R0
IntOp $R3 $R3 + 1 ; inc. "="
LoopRead:
ClearErrors
IfErrors End
FileRead $R2 $R1
StrCpy $R4 $R1 $R3
StrCmp $R4 "$R0=" 0 LoopRead
StrLen $R5 $R1
IntOp $R3 $R5 - $R3
StrCpy $R0 $R1 "" -$R3
Push $R0
; Call TrimNewLines
Pop $R0
Goto +2
End:
StrCpy $R0 "no value!"
FileClose $R2
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0 ; output value
FunctionEnd
;!define ReadINIStrNS "!insertmacro ReadINIStrNS"
;!macro ReadINIStrNS Var File Key
; Push "${File}"
; Push "${Key}"
; Call ReadINIStrNS
; Pop "${Var}"
;!macroend