Announcement

Collapse
No announcement yet.

WritePrivateProfileString slow?

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

  • Scott Turchin
    replied
    The only time i've ever seen it slow is when there's code that is looping or something.
    So what I tend to do is make a function to retrieve the INI file settings.

    Also, just to be safe test this code against it, I've had my share of issues with reading ini files

    Code:
    Declare Function GetINIData( IniFile As String,GroupName As String, ParName As String, wDefault As String)As String
    Declare Function WriteIniData(IniFile As String,GroupName As String, ParName As String,wValue As String) As Long
    
    'My examples of getting it, but sometimes I lump all of this in one function by itself:
    g_CurrentServer = Val(GetIniData(g_IniFile, g_Setup, g_RegCurServer,"1"))
    g_Status = Val(GetIniData(g_IniFile, g_Setup, g_RegStatus,"1"))
    g_Splash = Val(GetIniData(g_IniFile, g_Setup, g_RegSplash,"1"))
    g_Sound  = Val(GetIniData(g_IniFile, g_Setup, g_RegSound,"1"))
    
    '------------------------------------------------------------------------------------------
    Function GetINIData( IniFile As String,GroupName As String, ParName As String, wDefault As String) Export As String
    Local Result     As Long
    Local zGroupName As Asciiz * 125
    Local zParname   As Asciiz * 125
    Local zData      As Asciiz * 150
    Local zDefault   As Asciiz * 150
    Local zIniFile   As Asciiz * 255
    zGroupName = GroupName
    zParname   = Parname
    zIniFile   = IniFile
    zDefault   = wDefault
    Result = GetPrivateProfileString(zGroupName,zParName,zDefault,zData,SizeOf(zData),zIniFile)
    Function = zData
    End Function
    '------------------------------------------------------------------------------------------
    Function WriteIniData(IniFile As String,GroupName As String, ParName As String,wValue As String) Export As Long
    Local zGroupName As Asciiz * 125
    Local zParname   As Asciiz * 125
    Local zValue     As Asciiz * 150
    Local zIniFile   As Asciiz * 255
    Local Result     As Long
    zGroupName = GroupName
    zParname   = Parname
    zIniFile   = IniFile
    zValue     = wValue
    Function = WritePrivateProfileString(zGroupName,zParname,zValue,zIniFile)
    End Function
    '------------------------------------------------------------------------------------------
    ------------------
    Scott
    mailto:[email protected][email protected]</A>

    [This message has been edited by Scott Turchin (edited January 20, 2001).]

    Leave a comment:


  • Michael Mattias
    replied
    Well, you could build up all the strings into sections and use WritePrivateProfileSection.

    That would be one API call and a single I-O per section instead of one per string.

    MCM


    [This message has been edited by Michael Mattias (edited January 20, 2001).]

    Leave a comment:


  • Borje Hagsten
    replied
    Should not be a problem. Have you checked the code carefully? I once
    did a test just for fun and found that it is a bit slower that using
    the registry, but otherwise it works fine. Think there's a 64K limit
    for each section though.

    A tip: If lpKeyName for some reason is %NULL, the whole section
    is deleted. Check the return value and see where it fails.

    ------------------


    [This message has been edited by Borje Hagsten (edited January 20, 2001).]

    Leave a comment:


  • Egbert Zijlema
    started a topic WritePrivateProfileString slow?

    WritePrivateProfileString slow?

    Hi,

    My app. needs to create 3 INI files on the fly. In total those inis contain about 20 entries.
    I tried to write those entries using WritePrivateProfileString, one after each other.
    Windows did not fulfill the task. I saw only a few entries created.
    Is the Windows API too slow to do such a simple job? What can we expect if we really want to write complicated software with it?

    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/

    [This message has been edited by Egbert Zijlema (edited January 20, 2001).]
Working...
X