Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading a var from an ini file from Visual basc
Message
De
13/09/2002 12:43:08
 
 
À
12/09/2002 10:38:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00699767
Message ID:
00700243
Vues:
22
Hi Doug,
You might try something like this from Robert Houghtaling on VisualBasic.org:

http://www.visualbasic.org/vbfaq/common.htm#C1

Here is an example you can download:

http://www.vbcode.com/asp/showzip.asp?ZipFile=http://members.xoom.com/QuinqSoft/files/vb/ReadWriteIni.zip&theID=348
In a project with 1 commandbutton, place the following code:

Option Explicit
Private 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
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias _
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _
lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As _
Long

Private Sub Command1_Click()

Dim sData As String
Dim lDataLen As Long
' Read from WIN.INI
' [Desktop]
' Wallpaper={path\filename.bmp}
sData = Space$(255) ' Allocate space for the string
lDataLen = GetPrivateProfileString("Desktop", "Wallpaper", "", sData, _
Len(sData), "win.ini")
' strip off the NULL that API routines put on the end of strings
sData = Left$(sData, lDataLen)
' Print the string to the debug window
Debug.Print sData
' Now write to WIN.INI
' [Desktop]
' Test=here is some text
sData = "here is some text"
WritePrivateProfileString "Desktop", "Test", sData, "win.ini"

End Sub
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform