Results 1 to 6 of 6

Thread: WriteINI and ReadINI

  1. #1

    Thread Starter
    Fanatic Member Emcrank's Avatar
    Join Date
    Jan 2009
    Posts
    566

    WriteINI and ReadINI

    A Class for reading and writing .INI files easily.
    I didn't make these.
    Instructions
    1. Put this code into your project.
    VB Code:
    1. Class INIReadWrite
    2.  
    3.     <DllImport("kernel32.dll", SetLastError:=True)> _
    4.     Private Shared Function GetPrivateProfileString(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
    5.     End Function
    6.  
    7.     <DllImport("kernel32.dll", SetLastError:=True)> _
    8.     Private Shared Function WritePrivateProfileString(ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Boolean
    9.     End Function
    10.  
    11.     Public Shared Function ReadINI(ByVal File As String, ByVal Section As String, ByVal Key As String) As String
    12.         Dim sb As New StringBuilder(500)
    13.         GetPrivateProfileString(Section, Key, "", sb, sb.Capacity, File)
    14.         Return sb.ToString
    15.     End Function
    16.  
    17.     Public Shared Sub WriteINI(ByVal File As String, ByVal Section As String, ByVal Key As String, ByVal Value As String)
    18.         WritePrivateProfileString(Section, Key, Value, File)
    19.     End Sub
    20.  
    21. End Class
    2. To read an .INI file
    Code:
    ReadINI(File, Section, Key)
    3. To write to an .INI file
    Code:
    WriteINI(File, Section, Key, Value)

  2. #2
    New Member
    Join Date
    Jul 2010
    Posts
    1

    Re: WriteINI and ReadINI

    Thanks just what I was looking for.

    Thanks

    SDS7

  3. #3
    New Member
    Join Date
    Mar 2015
    Posts
    12

    Re: WriteINI and ReadINI

    Nice one thanks a lot was looking for something like this long time.!

  4. #4
    Registered User Abiey's Avatar
    Join Date
    May 2015
    Posts
    1

    Re: WriteINI and ReadINI

    I was looking for 1 week ago

    Thanks mate

  5. #5
    Junior Member
    Join Date
    Oct 2014
    Posts
    25

    Re: WriteINI and ReadINI

    Was looking for something like this, but could someone explain how to use?
    Am just starting VB, Thanks

  6. #6
    Junior Member
    Join Date
    Oct 2014
    Posts
    25

    Re: WriteINI and ReadINI

    Was looking for something like this, but could someone explain how to use?
    Am just starting VB, Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width