I was writing a simple tracking support program to write statistic data
into INI file (WritePrivateProfileString) after processed each record.
However, when the system crash (for eg, reset the computer) the INI file
seem to be not updated. I have tried to display a message after each
WRITE and then take a look on the INI, and it’s work fine.
I have tried to flush the cache by setting first 3 parameters to NULL,
but it doesn’t work.
Thanks for any help!
Best Greeting
Ung
Sorry for my English.
--
Andrew Kotsar'
IT specialist
Moscow
Sodexho AO Russia
Ung wrote in message <366CDC7C...@tm.net.my>...
This code flushes ok for me.
Private Declare Function WritePrivateProfileStringFlush Lib "kernel32"
Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As Long, _
ByVal lpKeyName As Long, _
ByVal lpString As Long, _
ByVal lpFilename As String) As Long
Public Function SetIniFlush(HoldFile as string) As Boolean
WritePrivateProfileStringFlush 0, 0, 0, HoldFile
SetIniFlush = True
End Function
I was using the WritePrivateProfileString in conjunction with the
DoEvents.
Here are the code...
Sub Record_Process()
Initialize and Write to INI file
While EndOfProcess
DoEvents
Wend
Terminate Process
End sub
At the same time, there is a timer which will fire an event to call
Step_Process to step through each record. So, upon completion of
processing each record, the INI file should be updated and write to disk
file instead of cache.
Sub Timer1_Timer()
Call Step_Process()
End sub
Sub SetIniFlush()
If WritePrivateProfileString( 0&, 0&, 0&, IniFile) then :
End sub
Sub Step_Process()
...
if WritePrivateProfileString(sections, entry,key,IniFile) then:
SetIniFlush()
End sub
I called the SetIniFlush inside the Step_Process but it seem to be working
only for the first record.For the subsequent processed record, the INI
file is not updated.
Thanks for help!
Regards
Ung