HardwareHeaven.com

HardwareHeaven.com

Looking for the skin chooser?
 
 
  • Home

  • Hardware reviews

  • Articles

  • News

  • Tools

  • Gaming at HardwareHeaven

  • Forums

 

Go Back   HardwareHeaven.com > Forums > Software / Tools > Programming, Coding, (Web)Design


Programming, Coding, (Web)Design Discuss all your programming or design needs with likeminded people.

Reply
 
Thread Tools
Old Dec 31, 2005, 04:09 AM   #1
DriverHeaven Newbie
 
Join Date: Dec 2005
Location: South Africa
Posts: 8
Rep Power: 0
PC_Stoker is on a distinguished road

INI Files

hi all, thought i would start off by putting something out there...

INI File Manipulation, this is a really usefull piece of code (if you don't know about it, that is).

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As Any, ByVal lplFileName As String) As Long

---

Public Function GetIni(IniFile As String, Section As String, Key As String) As String

Dim Temp As String
Dim retval As Long

Temp = String(255, 0)
retval = GetPrivateProfileString(Section, Key, "", Temp, Len(Temp), IniFile)
If retval = 0 Then

Else
GetIni = Left(Temp, InStr(Temp, Chr(0)) - 1)
End If

End Function

Public Function SetIni(IniFile, Section, Key, Value)

Dim retval As String
retval = WritePrivateProfileString(Trim$(Section), Trim$(Key), CStr(Value), IniFile)

End Function

--File sample
[LASTUPDATE]
Date=12 jan 2001

--Use
GetIni("c:\a.ini", "LASTUPDATE", Date)
SetIni("c:\a.ini", "LASTUPDATE", "Date","02 jan 2001")

hope someone finds it useful...
PC_Stoker is offline   Reply With Quote


Reply

Thread Tools