Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword
Global Sections(), Keys() As String
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 50,10,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If Cb.Msg = %WM_Command And Cb.Ctl = 100 And Cb.CtlMsg = %BN_Clicked Then ? ReadINIFile(EXE.Path$ + "test.ini")
End Function
Function ReadINIFile(INIFile As String) As String
Local temp$, section$, key$, value$, result$, i,j As Long
Open INIFile For Input As #1
While IsFalse(Eof(1))
Line Input #1, temp$
If InStr(temp$,"=") Then
'is key
i = InStr(temp$,"=")
key$ = Left$(temp$,i-1)
value$ = Mid$(temp$,i+1)
result$ = result$ + $CrLf + section$ + " : " + key$ + " : " + value$
Else
'is section
i = InStr(temp$,"[")
j = InStr(temp$,"]")
section$ = Mid$(temp$,i+1,j-i-1)
End If
Wend
Function = result$
End Function
'gbs_00734
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm