Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Simple INI file routines

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple INI file routines

    Hope you find these useful (took me five mins):


    Code:
    $Compile Exe
    $Include "WIN32API.INC"
    
    %STD_LEN = 255
    
    Function GetINI (ByVal IniFile As String, ByVal sSection As String, ByVal sKey As String, ByVal sDefault As String) Export As String
     Local zText As Asciiz * 255
     GetPrivateProfileString ByCopy sSection, ByCopy sKey, ByCopy sDefault, zText, SizeOf(zText), ByCopy IniFile
     Function = zText
    End Function
    
    
    Function SetINI (ByVal IniFile As String, ByVal sSection As String, ByVal sKey As String, ByVal sValue As String) As Long
     Function = WritePrivateProfileString (ByCopy sSection, ByCopy sKey, ByCopy sValue, ByCopy IniFile)
    End Function


    Kev

    [This message has been edited by K Peel (edited 08-16-99).]

  • #2
    Just for extended information, if you want to access the file other than with the GetPrivateProfileString, enter the text:

    Code:
     ' Flush the API INI buffer, change 'MyFile.ini' to your filename.
     SetIni "MyFile.ini", "", "", ""
    After much trial & error, I discovered that Windows "caches" the file on access, denying other functions write access.

    Cheerz,


    -------------
    Kev G Peel
    KGP Software
    Bridgwater, UK.
    mailto:[email protected][email protected]</A>

    Comment

    Working...
    X