Amaç ?           

Web Tasarım !!

İhtiyacınız web Sitesiyse Doğru Yerdesiniz

Devamı..

Android Uygulamalarımız!!

Android Uygulamalarımız için yorumlarınızı bekliyoruz.

Devamı..

İni File İşlmeleri

Murat özçelik tarafından yazıldı. Aktif . Yayınlanma VB.net

Projemize clas ekliyoruz ve aşşağıdaki kodları yaıyoruz.

 

Public Class IniFiles

Private Declare Ansi Function GetPrivateProfileString Lib "kernel32.dll" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As System.Text.StringBuilder, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Private Declare Ansi Function WritePrivateProfileString Lib "kernel32.dll" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
Private Declare Ansi Function GetPrivateProfileInt Lib "kernel32.dll" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
Private Declare Ansi Function FlushPrivateProfileString Lib "kernel32.dll" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As Integer, ByVal lpKeyName As Integer, ByVal lpString As Integer, ByVal lpFileName As String) As Integer
Private strFilename As String = ""

Public Sub New(ByVal Filename As String)
strFilename = Filename
End Sub

Public Property FileName(ByVal strFilename As String) As String

Get
Return strFilename
End Get
Set(ByVal value As String)
strFilename = value
End Set
End Property

Public Function Getir(ByVal Section As String, ByVal Key As String, ByVal [Default] As String) As String
Dim Sonuc As String = ""
Dim intCharCount As Integer
Dim objResult As New System.Text.StringBuilder(1024)
intCharCount = GetPrivateProfileString(Section, Key, [Default], objResult, objResult.Capacity, strFilename)
If intCharCount > 0 Then Sonuc = Left(objResult.ToString, intCharCount)
Getir = Sonuc
End Function

Public Function GetirSayi(ByVal Section As String, ByVal Key As String, ByVal [Default] As Integer) As Integer
Return GetPrivateProfileInt(Section, Key, [Default], strFilename)
End Function

Public Sub Yaz(ByVal Section As String, ByVal Key As String, ByVal Value As String)
WritePrivateProfileString(Section, Key, Value, strFilename)
Flush()
End Sub

Public Sub YazSayi(ByVal Section As String, ByVal Key As String, ByVal Value As Integer)
Yaz(Section, Key, CStr(Value))
Flush()
End Sub

Private Sub Flush()
FlushPrivateProfileString(0, 0, 0, strFilename)
End Sub

End Class

 

2- form içersidnde en tepeye 

Dim inifile As IniFiles = New IniFiles("C:\diji.ini")

3- anaktar oluşturmak için
inifile.Yaz("ANAHTARADI", "ANAHTARBOLUMU", "DEGER") 'String
4-değer eklemek değiştirmek için
inifile.Yaz("ANAHTARADI", "ANAHTARBOLUMU", "DEFAULTDEGER")
5-değer okumak için
MsgBox(inifile.Getir("ANAHTARADI", "ANAHTARBOLUMU", ""))

yazıyoruz

 




Yorum ekle

Yorum Ekleyin.


Güvenlik kodu
Yenile

56 ziyaretçi ve 0 üye çevrimiçi