Yeah I'm aware of that. I thought there might have been a module/api to manipulate my file, instead of me coding one myself like I have done ...
VB Code:
Private Sub WriteMameIni(name As String, spaces As Integer, value As Byte)
Dim strText As String
Dim pos As Integer
Dim counter As Long
Dim varText As Variant
Dim Upper As Long
Dim FileNum As Integer
Dim arrWrite() As String
Dim mamePath As String
mamePath = ReadInI("PATHS AND FOLDERS", "mamePath", App.Path & "\mstart.ini")
Open mamePath & "\mame.ini" For Input As #1
strText = Input(LOF(1), #1)
Close #1
varText = Split(strText, vbCrLf)
Upper = UBound(varText)
ReDim arrWrite(Upper)
'Read and process all in one go.
For counter = 0 To Upper - 1
pos = InStr(1, varText(counter), name)
If pos <> 0 Then
varText(counter) = name & Space(spaces) & value
End If
arrWrite(counter) = varText(counter)
Next
FileNum = FreeFile
Open "d:\emu\mame\mame.ini" For Output As #FileNum
'Write all in one go.
For counter = 0 To Upper - 1
Print #FileNum, arrWrite(counter)
Next
Close #FileNum
End Sub
Private Function ReadMameIni(name As String)
Dim strText As String
Dim pos As Integer
Dim counter As Long
Dim varText As Variant
Dim Upper As Long
Dim mamePath As String
mamePath = ReadInI("PATHS AND FOLDERS", "mamePath", App.Path & "\mstart.ini")
Open mamePath & "\mame.ini" For Input As #1
strText = Input(LOF(1), #1)
Close #1
varText = Split(strText, vbCrLf)
Upper = UBound(varText)
ReDim arrWrite(Upper)
For counter = 0 To Upper - 1
pos = InStr(1, varText(counter), name)
If pos <> 0 Then
varText(counter) = Mid(varText(counter), Len(name) + 1)
ReadMameIni = Trim(varText(counter))
Exit For
End If
Next
End Function
Oh well, wasted a few hours :S
Thanks again.