Go Back   DriverHeaven.net > Forums > Software / Tools > Programming, Coding, (Web)Design

Notices

Reply
 
LinkBack Thread Tools Display Modes
Old Dec 30, 2005, 11:09 PM   #1 (permalink)
PC_Stoker
DriverHeaven Newbie
 
Join Date: Dec 2005
Location: South Africa
Posts: 8
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

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump




 

 
Powered by: vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Artwork by Allan 'Zardon' Campbell, vBulletin implementation by Craig '5320' Humphreys based on original artwork by Ratchet.

All times are GMT -5. The time now is 12:41 PM. Copyright ©2008 DriverHeaven.net