Prev Previous Post   Next Post Next
Old 16th March 2003, 21:56   #1
wossName
Junior Member
 
Join Date: Mar 2003
Location: Earth
Posts: 7
Question Problem with DeleteINISec

Hi,

I seem to have a problem with DeleteINISec: I call that command in my function and then add the deleted section back in (with some modifications), at least that's the plan. But in reality, the INI file is empty on every other run of the installer, even though the details view shows $R0 having the correct value.

I can't use the normal INI functions, because I'm modifying wininit.ini.

If anyone can give me some hints, that would be very nice. Maybe I'm doing something obviously wrong, this is my first more complicated function for NSIS. (I'm using NSIS 2.0b2.)

Here's the function:
code:

;
; AddToWininit - adds lines to the [Rename] section of wininit.ini
;
; Expects string with new lines on top of stack
; Returns nothing, error flag will be set on failure
;
; Make sure new lines end with "$\r$\n"
;
Function AddToWininit
Exch $R0 ; lines
Push $R1 ; file handle
Push $R2 ; read buffer
Push $R3 ; compare buffer

ClearErrors
IfFileExists "$WINDIR\wininit.ini" 0 WRITE
FileOpen $R1 "$WINDIR\wininit.ini" "r"
IfErrors SAFE_RETURN

SECTION_LOOP:
FileRead $R1 $R2
IfErrors READ_DONE
Push $R2
Call TrimNewlines
Pop $R2
StrCmp $R2 "[Rename]" 0 SECTION_LOOP

READ_LOOP:
FileRead $R1 $R2
IfErrors READ_DONE
Push $R2
Call TrimNewlines
Pop $R2
StrCmp $R2 "" READ_LOOP
StrCpy $R3 $R2 1
StrCmp $R3 "[" READ_DONE
StrCpy $R0 "$R0$R2$\r$\n"
Goto READ_LOOP

READ_DONE:
FileClose $R1
DeleteINISec "$WINDIR\wininit.ini" "Rename"
ClearErrors

WRITE:
FileOpen $R1 "$WINDIR\wininit.ini" "a"
IfErrors SAFE_RETURN
FileSeek $R1 0 END
FileWrite $R1 "$\r$\n[Rename]$\r$\n"
DetailPrint $R0
FileWrite $R1 $R0
FileClose $R1

SAFE_RETURN:
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd


Last edited by wossName; 16th March 2003 at 22:15.
wossName 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