Results 1 to 3 of 3

Thread: INI File

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2001
    Posts
    12

    Exclamation INI File

    How can I Save and retrive datas through INI file?

  2. #2
    Addicted Member Supester's Avatar
    Join Date
    Nov 2001
    Location
    The Netherlands
    Posts
    220
    You can create the ini file yourself as a text-file.......

    There should be plenty of postings around here on how to create files and manipulate them...

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. Option Explicit
    2. Private Declare Function GetPrivateProfileString _
    3. Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal _
    4. lpApplicationName As String, ByVal lpKeyName As String, _
    5. ByVal lpDefault As String, ByVal lpReturnedString As _
    6. String, ByVal nSize As Long, ByVal lpFileName As String) As _
    7. Long
    8.  
    9. Private Declare Function WritePrivateProfileString _
    10. Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal _
    11. lpApplicationName As String, ByVal lpKeyName As Any, ByVal _
    12. lpString As Any, ByVal lpFileName As String) As Long
    13.  
    14.  
    15.  
    16. Private Function ReadINI(strsection As String, strkey As String, strfullpath As String) As String
    17.    Dim strbuffer As String
    18.    Let strbuffer$ = String$(750, Chr$(0&))
    19.    Let ReadINI$ = Left$(strbuffer$, GetPrivateProfileString(strsection$, ByVal LCase$(strkey$), "", strbuffer, Len(strbuffer), strfullpath$))
    20. End Function
    21.  
    22. Private Sub WriteINI(strsection As String, strkey As String, strkeyvalue As String, strfullpath As String)
    23.     Call WritePrivateProfileString(strsection$, UCase$(strkey$), strkeyvalue$, strfullpath$)
    24. End Sub
    25.  
    26.  
    27. Private Sub Command1_Click()    WriteINI "DBParam", "DBName", "C:\myapp\db\mydb.mdb", "C:\TEST.INI"
    28.     WriteINI "Temp", "TMPPath", "C:\myapp\tmp", "C:\TEST.INI"    
    29. End Sub
    30.  
    31. Private Sub Command2_Click()
    32.     MsgBox ReadINI("DBParam", "DBName", "C:\TEST.INI")
    33.     MsgBox ReadINI("Temp", "TMPPath", "C:\TEST.INI")
    34. End Sub

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