Visual Basic 6

INI-Dateien auslesen

Zugriff auf Konfigurationsdateien per API

Es ist ein alter Hut, aber auch bei alten Hüten vergisst man oft wie sie aussehen: das Auslesen einer INI-Datei über die API-Funktionen GetPrivateProfileString. Das gleiche gilt natürlich auch für den umgekehrten Weg WritePrivateProfileString, um Daten in eine INI zu schreiben.

Der Einfachheit halber mit zwei kleinen Wrapper-Funktionen, um die Arbeit während des Kodierens zu erleichtern:

Die API-Deklarationen

Private 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

Private 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

Die Hilfsfunktionen

Public Function GetINIString( _
 ByVal strINIFile As String, _
 ByVal strSection As String, _
 ByVal strItem As String) As String

 On Error GoTo error_handler

 Dim intLen As Integer
 Dim strBuffer As String * 1024

 intLen = GetPrivateProfileString( _
 strSection, strItem, "", strBuffer, 1024, strINIFile)

 If intLen > 0 Then
 GetINIString = Left$(strBuffer, intLen)
 End If

error_handler:

End Function

Public Function SetINIString( _
 strINIFile As String, _
 strSection As String, _
 strItem As String, _
 strValue As String) As String

 On Error GoTo error_handler

 Dim lngRet As Long

 lngRet = WritePrivateProfileString( _
 strSection, strItem, strValue, strINIFile)

error_handler:

End Function
kick it on dotnet-kicks.de AddThis 0 wikio-Stimme(n) Trackback-Url...

Schlagworte

265 Kommentare bislang...

  • A formidable promote, My partner and i simply given this onto some sort of friend who seem to had been doing somewhat evaluation about this. As well as he or she in actual fact purchased me breakfast time as a result of I discovered it regarding him or her.. laugh. Thus allow me to reword in which: Thnx for that deal with! However yes Thnkx regarding investing any time to debate this particular, My partner and i really feel powerfully about this as well as like studying extra about this subject. In the event that doable, just like you change into experience, on earth do you thoughts updating ones weblog together with extra particulars? It's extremely useful with luck. Large browse in place just for this weblog put up!
    265
  • Although the name of Jordan shoes is famous all Jordans 4 For Cheap around the world, air jordan for cheap for those who don't know what it refers to, this is a completely great range regarding sneakers what seemed to be originally created and designed by a celebrity name from the world of basketball, called Michael Jordan. These air shoes were first made for him, but later in the year 1985, these were made available for the common man.
    264
    jordans forcheap : Freitag, 20. Januar 2012 01:14
  • Nike brand has a terrific combination with Jordan shoes and it is an absolute Cheap Retro Jordans win-win situation for the brand. When it comes to actually choosing the type of shoe, Red Air 11s are the choicest ones. They have the right blend of all the marvelous factors which make the brand so powerful. . Also they have the colors of Chicago Bulls of Michael Jordan. Air Jordan 4 Shoes The striking red and blue combination design only brings you back to the memories of Chicago bulls.

    263
    Jordans Outlet : Freitag, 20. Januar 2012 01:09
  • People made some <a href="http://wheretotravelguide.com">Century 21 Broker Properti Jual Beli Sewa Rumah Indonesia</a> decent factors generally <a href="http://www.greatengagementrings.com/2011/12/cheap-engagement-rings-for-women.html">cheap engagement rings for women</a> there. When i seemed on <a href="http://www.blogspottutorial.com/">blogger templates</a>the web for the issue and located most people can go along with with your site.
    262
    lowongan kerja : Montag, 16. Januar 2012 02:34
  • I will tell you right now that how to grow your penis if you want to be the best of the best then you must make sure that you are working extremely hard at what is the most I'm just going to be extremely honest here.
    261
    grow your penis : Samstag, 14. Januar 2012 23:51

Dein Kommentar hierzu...


Kommentar-Feed für diesen Beitrag
Gravatare werden unterstützt .:. eMail-Adressen werden nicht veröffentlicht
 

RSS-Feed

Die URL des Standard-Newsfeed von zerbit.de lautet:

http://www.zerbit.de/rssfeed.aspx

Login


 

 

Statistik



kürzlich kommentiert

Artikel 15

  • Datum: 08.03.2005
    Kategorie: Visual Basic 6
    Zugriffe: 5.810
    Kommentare: 265
    Trackbacks: 0

Letzte Beiträge

Kategorien

Buttons & More

Blog-Roll

Banner Piraten-Partei