Link to home
Start Free TrialLog in
Avatar of gthgb
gthgb

asked on

INI"S

is there anyway i can make a visual basic prog edit one entry in an ini file
eg
wavdir=C:\wav\
avidir=c:\sumthin\
and not change any other settings like this

wavdir=c:\wav\
avidir=c:\sumthinelse\
Avatar of Jaysin28
Jaysin28

Yes you can change only one setting in an INI file.  I have a ready made module that will do this for you if you want.
You can achieve this with a few API calls. The ones that are used most are:

'To retrieve a value from an .INI file:
Declare Function GetPrivateProfileString Lib "kernel32" 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

'To write a value to an .INI file:
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
Avatar of gthgb

ASKER

yeah ill take the module

You'll have to reject my answer then to allow Jaysin28 to lock the question.
You have to reject the other answer first so I can Answer
Avatar of gthgb

ASKER

ok done

ASKER CERTIFIED SOLUTION
Avatar of Jaysin28
Jaysin28

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:-)
caraf_g,
Thanks, I tried to figure out the problem with the tooltips...  It's weird how it is working for one and not the other...

Jaysin
It's very strange alright. I don't know why this is happening. Let's hope someone will come up with a solution!
Avatar of gthgb

ASKER

holly poop on a stick ok ill try this and see wot happens

Avatar of gthgb

ASKER

ummm will this work on vb5  im having trouble (i dun know much code so help me out here)
error

Public Declare Function GetPrivateProfileString Lib "kernel32" _
   Alias "GetPrivateProfileStringA" (ByVal sSection As String, _
   ByVal sParameter As String, ByVal sDefault As String, _
   ByVal sReturnedString As String, ByVal nSize As Long, _
   ByVal sFileName As String) As Long

says that only comments may appear after end sub end fuction or end property
You have to stick it in the General declarations section before any procedures...
Add a new module in your VB project and paste the code directly into it.   You can read the INI file using ReadINIFile.  sSection is the Section you want to read (i.e.  [GENERAL] ), sParm is the parameter in sSection that you want read ( i.e. Load = ), bDefault is any default you value you want the function to return if the sParm don't exist, and sIniFile is the INI filename.
Avatar of gthgb

ASKER

ok illtry that then