|
-
Feb 9th, 2003, 07:39 AM
#1
Thread Starter
New Member
Writing to an ini file
IS there an easy way to write a whole section to an ini file?
The code i have is
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
retval = WritePrivateProfileString("ICM", "TransportDriver", "TCP/IP", "C:\_custom\appsrv.ini")
which will write "TransportDriver=TCP/IP" to the 'ICM' section in the ini file...I have about 23 values that I need to add to the 'ICM' section..is there an easy way to write multiple values to the same section in a ini file?
I am only a newbie, so apologies if this is a basic question.
-
Feb 9th, 2003, 07:47 AM
#2
Fanatic Member
i have a solution
here is a code i got from psc:
VB 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 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 Function GetFromINI(Section As String, Key As String, Directory As String) As String
Dim strBuffer As String
strBuffer = String(750, Chr(0))
Key$ = LCase$(Key$)
GetFromINI$ = Left(strBuffer, GetPrivateProfileString(Section$, ByVal Key$, "", strBuffer, Len(strBuffer), Directory$))
End Function
Public Sub WriteToINI Section As String, Key As String, KeyValue As String, Directory As String
Call WritePrivateProfileString(Section$, Key$, KeyValue$, Directory$)
End Sub
syntax=WriteToINI("ICM","TransportDriver","TCP/IP",app.path+"\INIFile.ini")
syntax=msgbox GetFromINI("ICM","TransportDriver",app.path+"\INIFile.ini")
you can write a bunch of keys to the same section by using different key names... here is an example of an ini file for one of my progs:
[General]
MainOptions="10,10,12"
TenthMainOptionName="0,0,10"
Best Regards,
seec77
If you helped me, cosinder yourself thanked.
Get each and every Garfield strip here!
Here you can get all Calvin & Hobes strips!
Damn UComics! It was probably unprofitable for them to allow us to just download Garfield and Calving & Hobes strips... so they made folder indexing unallowed on their server!!!
I am 33% addicted to Counterstrike. What about you?
I am 23% addicted to Star Wars. What about you?
I am 0% addicted to Tupac. What about you?
-
Feb 9th, 2003, 07:53 AM
#3
Thread Starter
New Member
What I need to do is add all the below to the [ICM] section in the ini file:-
[iCM]
TransportDriver=TCP/IP
BrowserProtocol=UDP
Password=xxxxxxxx
DesiredHRES=4294967295
DesiredVRES=4294967295
ScreenPercent=0
DoNotUseDefaultCSL=Off
Description=iCM
Address=iCM
InitialProgram=#iCM
IconPath=C:\_custom\iCM.ico
IconIndex=1
ConnectType=1
MaximumCompression=Off
Compress=On
PersistentCacheEnabled=Off
MouseTimer=0
KeyboardTimer=0
AudioBandwidthLimit=1
UseDefaultSound=On
DefaultSoundType=1
UseDefaultEncryption=On
EncryptionLevel=1
-
Feb 9th, 2003, 08:14 AM
#4
Fanatic Member
what's the problem?
use the code i gave ya and write something like this:
VB Code:
WriteToINI("ICM","TransportDriver","TCP/IP",app.path+"\INIFile.ini")
WriteToINI("ICM","BrowserProtocol","UDP",app.path+"\INIFile.ini")
WriteToINI("ICM","Password","xxxxxxx",app.path+"\INIFile.ini")
and so on...
Best Regards,
seec77
If you helped me, cosinder yourself thanked.
Get each and every Garfield strip here!
Here you can get all Calvin & Hobes strips!
Damn UComics! It was probably unprofitable for them to allow us to just download Garfield and Calving & Hobes strips... so they made folder indexing unallowed on their server!!!
I am 33% addicted to Counterstrike. What about you?
I am 23% addicted to Star Wars. What about you?
I am 0% addicted to Tupac. What about you?
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
|