Create ini file

Light

Staff member
Administrator
Credits to KingpinX (I found this on the old forum)

This is the code to put into load form part to load the data. You can also put it in the ReadINI module like i do..works better prob i think ;D

Code:
Form2.Text1.text = ReadINI("passport", "msnregcookie", App.Path + "\option.ini")
Form2.Text2.text = ReadINI("passport", "passportticket", App.Path + "\option.ini")
Form2.Text3.text = ReadINI("passport", "passportprofile", App.Path + "\option.ini")

This code is to save the data when you unload the form. Can aswall go into module i did that too...

Code:
WriteINI "option", "room", txtroomname.text, App.Path + "\option.ini"
WriteINI "option", "nick", txtnickname.text, App.Path + "\option.ini"

[CODE]Option Explicit
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Public Function ReadINI(SectionHeader As String, VariableName As String, FileName As String) As String
Dim strReturn As String
strReturn = String(255, Chr(0))
ReadINI = Left$(strReturn, GetPrivateProfileString(SectionHeader, ByVal VariableName, "", strReturn, Len(strReturn), FileName))
End Function

Public Function WriteINI(SectionHeader As String, VariableName As String, Value As String, FileName As String)
WriteINI = WritePrivateProfileString(SectionHeader, VariableName, Value, FileName)
End Function
 
RackNerd Leaderboard Banner

Back
Top