PDA

Click to See Complete Forum and Search --> : Getting Info From An .INI File


Insane Killa
Nov 30th, 1999, 01:51 PM
I Am Making A Program For The Virtual Places Chat Client,
I Don't Know If Any Of You Are Familiar With It Or Not.

But What I Need Help From Is Getting Some Text Out Of A .INI
File.

I Am Trying To Get The Users Nickname.
This File is located by default in the directory:
C:\Program Files\VPlaces\vplaces.INI

the users nickname would be listed as so

NickName=Insane_Killa

this .INI file has alot a bit of text in it not just the nickname
so I need it to search for the Nickname can anyone help????

Also Can Anyone Also Tell Me How To Put Information In A Certain
Field For Example The Hobbies Field which would could appear
in the file like so:
Hobbies=Programming

Also If Anyone Has Built A Program For Virtual Places Before
And They Would Be Happy To Help Further Then Please Email Me
At: insanekilla88@hotmail.com

jgomes
Nov 30th, 1999, 02:09 PM
Heres a multistep example of the INI thingy u want... hope this helps :)
Also I put Load & Save, Just in case :)

Declare Function WritePrivateProfileString _
Lib "kernel32" Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationname As String, ByVal _
lpKeyName As Any, ByVal lsString As Any, _
ByVal lplFilename As String) As Long
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

'After adding that code make a command
'button, with the caption "save"
'Then add this code to it

Dim lngResult As Long
Dim strFileName
strFileName = "c:\test.ini"
lngResult = WritePrivateProfileString(txtHeading, _
txtKey.Text, txtValue.Text, strFileName)

If lngResult = 0 Then
'An error has occurred
Call MsgBox("An error has occurred", _
vbExclamation)
End If

'Now create another command button with the
'caption "Load". Heres the code for this...

Dim lngResult As Long
Dim strFileName
Dim strResult As String * 50

strFileName = "c:\test.ini"
lngResult = GetPrivateProfileString(txtHeading, _
txtKey, strFileName, strResult, Len(strResult), _
strFileName)

If lngResult = 0 Then
'An error has occurred
Call MsgBox("An error has occurred", _
vbExclamation)
Else
txtValue.Text = Trim(strResult)
End If

Hope this helps!

-Justin =]