Results 1 to 2 of 2

Thread: Reading from INI file

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2000
    Posts
    37

    Red face

    Hi,

    How can I read from INI file without writing the key name hard coded?

    Thanks, Lior

  2. #2
    Guest
    I believe you can as long as you have it like:

    Key=Value
    blah=blah


    Code:
    Private 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
    
    Private 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
    
    MyValue = ReadINI("MyValue.ini", "MyValue", "C:\MyValue.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