Results 1 to 4 of 4

Thread: Editing TXT docs

  1. #1
    chenko
    Guest
    How do I change a line in a ini file.

    Thanks,
    Simon

  2. #2
    Guest
    See this link

  3. #3
    Hyperactive Member
    Join Date
    May 2000
    Location
    Or
    Posts
    316
    You use the WritePrivateProfileString API

    Here is a quick example:

    Code:
    Private Declare Function GetPrivateProfileString Lib "kernel32.dll" 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
    Private Declare Function WritePrivateProfileString Lib "kernel32.dll" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
    Private Const MAX_SIZE = 255
    
    
    
    Private Sub Command1_Click()
        MsgBox getstring
        Call writestring
        MsgBox getstring
    
    End Sub
    
    '***************
    'Return a value
    '***************
    
    Private Function getstring() As String
    Dim tmp_var As String
    Dim lret As Long
        tmp_var = Space(MAX_SIZE)
        lret = GetPrivateProfileString("Default", "Value", "", tmp_var, MAX_SIZE, "C:\windows\desktop\test.ini")
        tmp_var = Left(tmp_var, lret)
        getstring = tmp_var
    End Function
    
    '***************
    'Write a value
    '***************
    
    Private Sub writestring()
    Dim retval As Long
        retval = WritePrivateProfileString("Default", "Value", "TestValue", "C:\windows\desktop\test.ini")
    End Sub
    Hope this helps

  4. #4
    Guest
    Thanks I will try them.

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