dcsimg
December 10, 2016
Hot Topics:

VB TIP: Using INI Files

  • November 18, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

You may still need to use INI files in your applications - this tip shows you how.

Option Explicit
Global inifile$

Function MakePath$(ByVal drv$, ByVal subdir$)

Do While Right$(drv$, 1) = "\"
drv$ = Left$(drv$, Len(drv$) - 1)
Loop

Do While Left$(subdir$, 1) = "\"
subdir$ = Mid$(subdir, 2)
Loop

MakePath$ = drv$ + "\" + subdir$

End Function

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

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

Private Sub cmdWrite_Click()
rslt = WritePrivateProfileString("Main", _
                       "Hello", _
                       Format$(Check1.Value), _
                       inifile$)
End Sub

Private Sub Form_Load()
inifile$ = MakePath$(App.Path, App.EXEName + ".INI")
End Sub





Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel