|
-
Aug 26th, 2000, 01:34 PM
#1
Thread Starter
Hyperactive Member
I have an ini file that I need to read and write to
It looks like this
[Friends]
Jonnie:34.131.256.204
Bill:262.159.45.224
Does anyone have a routine or a bas module that will let me get the entries under [FRIENDS] and get the total count
of the entries under the heading ?
Thanx guys
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Aug 26th, 2000, 01:47 PM
#2
Here you go:
Code:
Public 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
Public Function readini(strsection As String, strkey As String, strfullpath As String) As String
Dim strbuffer As String
Let strbuffer$ = String$(750, Chr$(0&))
Let readini$ = Left$(strbuffer$, GetPrivateProfileString(strsection$, ByVal LCase$(strkey$), "", strbuffer, Len(strbuffer), strfullpath$))
End Function
Usage:
Text1.text = readini("Friends", "Jonnie", "C:\Friends.ini")
-
Aug 26th, 2000, 01:57 PM
#3
Thread Starter
Hyperactive Member
Thanx =)
How bout this now
what happens If I Dont know the entries under [Friends]
How can I Find out how many entries there are ?
Also how bout a writeini function ?
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Aug 26th, 2000, 02:12 PM
#4
Here is how to Write an INI:
Code:
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
Public Sub writeini(strsection As String, strkey As String, strkeyvalue As String, strfullpath As String)
Call WritePrivateProfileString(strsection$, UCase$(strkey$), strkeyvalue$, strfullpath$)
End Sub
Call writeini("Friends.ini", "NewFriend", "Number", "C:\Friends.ini")
Don't know how to find all entries under [Friends], but you can open and through VB and look through it.
Code:
Open "C:\Friends.ini" For Input As #1
Text1.Text = Input$(LOF(1), 1)
Close #1
-
Aug 26th, 2000, 02:31 PM
#5
Thread Starter
Hyperactive Member
Thanx again Mathew , I appreciate your help
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|