Results 1 to 3 of 3

Thread: Reading/Writing INI file...

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    Finland
    Posts
    12

    Lightbulb

    I dunno how to use INI files...
    Could someone help me???
    Little tutorial or something...
    GAMES, PROGRAMS, ACTIVEX CONTROLS!
    ALL, WHAT WE NEED

  2. #2
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    look into VB API, it took me just an hour to understand and use the functions WritePrivateProfileString and GetPrivateProfileString. ;-)
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  3. #3
    Guest
    Here is a good example:

    Code:
    Public Declare Function GetPrivateProfileString _
    Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal _
    lpApplicationName As String, ByVal lpKeyName As String, _
    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(strsection As String, strkey As String, strfullpath As String) As String
       Dim strbuffer As String
       Let strbuffer$ = String$(750, Chr$(0&))
       Let ReadINI$ = Left$(strbuffer$, GetPrivateProfileString(strsection$, ByVal LCase$(strkey$), "", strbuffer, Len(strbuffer), strfullpath$))
    End Function
    
    Public Sub WriteINI(strsection As String, strkey As String, strkeyvalue As String, strfullpath As String)
        Call WritePrivateProfileString(strsection$, UCase$(strkey$), strkeyvalue$, strfullpath$)
    End Sub
    
    
    Usage
    
    'read:
    x = ReadINI("Value.ini", "Value", "C:\Value.ini")
    MsgBox X
    
    
    'write:
    'Call WriteINI("Value.ini", "Value", "1", "C:\Value.ini")

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