Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private iniFile As String
- Private Declare Auto Function GetPrivateProfileString Lib "Kernel32" _
- (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As StringBuilder, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
- Private Declare Auto Function WritePrivateProfileString Lib "Kernel32" _
- (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
- Private Function ReadINI(ByVal key_name As String, ByVal section_name As String, ByVal default_value As String) As String
- Const MAX_LENGTH As Integer = 500
- Dim string_builder As New StringBuilder(MAX_LENGTH)
- GetPrivateProfileString(section_name, key_name, default_value, string_builder, MAX_LENGTH, iniFile)
- Return string_builder.ToString()
- End Function
- Private Sub WriteINI(ByVal key_name As String, ByVal section_name As String, ByVal value As String)
- WritePrivateProfileString(section_name, key_name, value, iniFile)
- End Sub
- Private Sub checkIniExists()
- If Not File.Exists(iniFile) Then
- File.CreateText(iniFile).Dispose()
- Wait(100)
- End If
- End Sub
- Private Function Read_INI_String(opt As String, categoy As String, def As String) As String
- If ReadINI(opt, categoy, "") = "" Then WriteINI(opt, categoy, def)
- Return ReadINI(opt, categoy, def)
- End Function
- 'set the path in iniFile variable
- 'call checkIniExists to make sure that the .ini file exists
- 'use ReadIni and WriteIni
- 'use Read_INI_String when you want set a default value when there is no value in the variable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement