Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Better Function to write to an ini file

Code Links

Better Function to write to an ini file

by  MrMoocow  Posted    (Edited  )
Here is a better function I whipped up to read from ini files, it still uses the default api call, but it does it in one line of code 4 u.

Instead of you having to write 3 lines of code each time for each line now you use one.


Code:
'This may maynot work I am working on it
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 ' Write INI file


Public Function Readini(Header As String, Value As String, Default As String, ini As String) As String

Read = Space(255) ' buffer\final variable
Read2 = GetPrivateProfileString(Header, Value, Default, Read, 255, ini)
Read = Left(Read, Read2)
Readini = Read

End Function
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top