[ApplicationName]
Key=Value
***** 16-bit Örnek *****
Project’inize 1 adet commandbutton ekleyin ve aşağıdaki kodu yazınız:
Declare Function GetPrivateProfileString Lib "kernel" (ByVal lpApplicationName _
As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal _
lpReturnedString As String, ByVal nSize As integer, ByVal lpFileName As String) _
As integer
Declare Function WritePrivateProfileString Lib "kernel" (ByVal _
lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As _
String, ByVal lpFileName As String) As integer
Sub Command1_Click()
Dim sData As String
Dim iDataLen As integer
' WIN.INI ‘den okur.
' [Desktop]
' Wallpaper={path\filename.bmp}
sData = Space$(255) ' string’lerin yerlerini ayırır.
iDataLen = GetPrivateProfileString("Desktop", "Wallpaper", "", sData, _
Len(sData), "win.ini")
sData = Left$(sData, iDataLen)
'Debug penceresine yazılır.
Debug.Print sData
' WIN.INI şimdi yazılır.
' [Desktop]
sData = "here is some text"
WritePrivateProfileString "Desktop", "Test", sData, "win.ini"
End Sub
***** 32-bit Örnek *****
Project’inize 1 adet commandbutton ekleyin ve aşağıdaki kodu yazınız:
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
' WIN.INI’den okur.
' [Desktop]
' Wallpaper={path\filename.bmp}
sData = Space$(255) ' stringlerin yerini ayırır.
lDataLen = GetPrivateProfileString("Desktop", "Wallpaper", "", sData, _
Len(sData), "win.ini")
sData = Left$(sData, lDataLen)
' Debug penceresini yazılır.
Debug.Print sData
' WIN.INI şimdi yazılır.
' [Desktop]
sData = "here is some text"
WritePrivateProfileString "Desktop", "Test", sData, "win.ini"
End Sub