|
-
Mar 17th, 2000, 11:05 AM
#1
Thread Starter
Addicted Member
How do i read and write to a ini files?
-
Mar 17th, 2000, 07:24 PM
#2
New Member
The answer
Declare these two APIs in a module:
Public 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
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As String, ByVal lpFileName As String) As Long
To write to an ini file:
Dim Res As Long
Res = WritePrivateProfileString("Section", "Key Name", "Key Value", "C:\MyINI.ini")
"Res" will be zero if an error occurs.
To read:
Dim strString As String
Dim strStringLen As Integer
strString = Space(256)
strStringLen = 255
GetPrivateProfileString "Section", "Key Name", "", strString, strStringLen, "C:\MyINI.ini"
If "Section" or "Key Name" is not found then strString will be "" else strString will contain the value of "Key Name"
Hope this helps.
Regards:
VBJ
-
Mar 17th, 2000, 07:31 PM
#3
Fanatic Member
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
|