Guys,
I also do prefer to hand manage my INI files. I use only PB statements (no APIs - thanks Peter, I'll continue to do so!). This way I also use an INI file for some non-traditional tasks. For instance, when I need to read-modify-write the file, I can do it inside an unique lock-unlock block. I'm not sure this task could be done with the standard WritePrivateProfileString and the other related API calls (different instances of the program would overlap their read and write accesses to the file). The second reason I like to hand hand manage my INI files is to override the default NT settings, for which it uses the registry.
Well, all this sounds good. But is it? Has anyone any comment to add?
Aldo
------------------
Announcement
Collapse
No announcement yet.
Priorities
Collapse
X
-
Originally posted by Paul Noble:
Personally, I now tend bypass the API calls for reading / writing
ini files, and just code those actions manually. That way, you
don't get caught by this problem. PB's neat string functions make
this very easy.
HTH !
Yes, I'm speaking from experience
------------------
Best Regards
Peter Scheutz
[This message has been edited by Peter Scheutz (edited May 01, 2001).]
Leave a comment:
-
Scott,
I think Michael provided the answer, but just call it any time
you want to force a save or flush the ini contents to disk.
Whether that means on exit or during the program is entirely up
to yourself.
Personally, I now tend bypass the API calls for reading / writing
ini files, and just code those actions manually. That way, you
don't get caught by this problem. PB's neat string functions make
this very easy.
HTH !
Leave a comment:
-
Where does this statement go? Ie in the save or in the exit?
You may want to add a flag variable such as IniSaveNeeded. When that is TRUE, you'd want to save your INI file (with our without a user prompt) on WM_CLOSE, WM_QUERYENDSESSION and on the explicit IDM_EXIT.
MCM
(Oops! Just noticed you already DO have a flag variable)
[This message has been edited by Michael Mattias (edited May 01, 2001).]
Leave a comment:
-
Yikes, in Win2k they prefer that you use an INI file but it won't write to it?
Where does this statement go? Ie in the save or in the exit?
Scott
------------------
Scott
Leave a comment:
-
Scott,
This annoying behaviour is documented in MSDN KB ID: Q68827
Just do this any time you want to force a save -
Code:WritePrivateProfileString byval %NULL, byval %NULL, byval %NULL, byval strptr( sIniFile )
Leave a comment:
-
INI's are VERY late updated, has nothing to do with smartdrv.
Use NULL's as parameter to flush/force.
------------------
Leave a comment:
-
In certain cases, Windows may ignore calls to MessageBox since it could interfere with the current message execution, however, it would seem unlikely to be occurring in the case you present above. A quite run through the debugger should show what is actually happening.
There are other solutions involving a semi-direct call to the procedure with %BN_CLICKED via CallWindowProc(), but I would not recommend this.
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
Leave a comment:
-
Priorities
Easy question:
Will my INI File save before the exit is complete?
Something tells me not, my messagebox does not appear....
I'd hate to duplicate code, I could make a function to do the saving...
Code:Case %IDM_SAVE 'SAve file here g_IsSaved = %TRUE lResult = MessageBox(CbHndl,g_IniFile & " was saved",ByVal StrPtr(g_szCCS),ByVal %MB_ICONINFORMATION) Case %IDM_EXIT If IsFalse g_IsSaved Then lResult = MessageBox(CbHndl,"Save changes? Y/n",ByVal StrPtr(g_szCCS),ByVal %MB_ICONINFORMATION Or %MB_YESNO) If lResult = %IDYES Then 'Save INI File Control Send CbHndl,%IDM_SAVE, %BM_CLICK,0,0 End If End If Dialog End CbHndl,1
Scott
[This message has been edited by Scott Turchin (edited April 30, 2001).]Tags: None
Leave a comment: