Community discussion forum

INI Access

Tags: vb6 India
  • 4 years ago

    hi,
       what i want is to access ini file from visual basic program. so that whenever i save the settings and close the program. i get exactly what i saved before when i open it again. is there is any easy way to do it . I mean i know how to do this by using API. bye  bye

  • 4 years ago

    What INI file? Your own? Do ou create it?


    If yor problem is to read/write a text file from/to disk check the Code Library on my site http://www.rc-dev.com.
    There you find VB functions to do that stuff and lots more.


    keep coding!...

  • 4 years ago

    i want to open ini file not text files(even babies can open text files). ini files are initialization files in which all the default setting or defined settings of the program are saved. ini cannot be very larger because of some problems. ini files are different then text files.

  • 4 years ago

    I use this code to read/write INI's.. served me well so far


    just put it in a module.

    Code:

    '--------------------------------------------------------------------------
    ' This module makes writing to an INI file very easy.  See the examples
    ' below for what needs to go into the VB code for this to work.


    ' Write Example:
    ' --------------
    ' WriteINI "Section", "Setting", Value, App.Path & "\settings.ini"
    '
    ' Read Example:
    ' -------------
    ' Variable = ReadINI("Section", "Setting", App.Path & "\settings.ini")
    '--------------------------------------------------------------------------


    Option Explicit


    Public Declare Function getprivateprofilestring Lib "kernel32" 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
    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


    Function ReadINI(Section As String, KeyName As String, FileName As String) As String
       Dim sRet As String
       sRet = String(255, Chr(0))
       ReadINI = Left(sRet, getprivateprofilestring(Section, ByVal KeyName$, "", sRet, Len(sRet), FileName))
    End Function


    Function WriteINI(sSection As String, sKeyName As String, sNewString As String, sFileName) As Integer
       Dim r
       r = writeprivateprofilestring(sSection, sKeyName, sNewString, sFileName)
    End Function

  • 4 years ago

    ini ? .. was settings of older progs .... or driver .. in VB performance to use GETSETTINGS and SAVESETTINGS functions to store init keys info in Win32 register ..  the register info about your software can be simply export in .REG


    VB reg space  is in "HKCU"/software/Vb and VBA Program settings




  • 4 years ago

    Id just like to say thankyou i may not have asked the question, but it did help me with a project im working on for a mate .  Ty again, saved me a lot of headache time.

Post a reply

Enter your message below

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback