Re: Reg/INI Discussion from much earlier

From: Bob Butler (tiredofit_at_nospam.com)
Date: 07/27/04


Date: Tue, 27 Jul 2004 14:18:43 -0700


"YYZ" <notapplicable> wrote in message
news:eG1f51BdEHA.3596@tk2msftngp13.phx.gbl
> "Bob Butler" <tiredofit@nospam.com> wrote in message
> news:eQraCIBdEHA.3260@TK2MSFTNGP09.phx.gbl...
>> "Wes Spikes" <MornThdr@NOSPAMverizon.net> wrote in message
>> news:f9yNc.12829$Nu4.4912@nwrddc01.gnilink.net
>>> I HATE it when windows crashes after whatever you're wokring on on
>>> changing and i lose all changes and apps can't tell you anything
>>> except settings are corrupt.
>>
>> I do too which is why I generally update saved settings whenever
>> they are changed, not just when the app terminates. That eliminates
>> almost all chance of them being lost especially under NT-based OS's.
>
> I hate jumping on a thread midstream to ask a question, but Bob you
> seem to one of the proponents of ini files vs. registry. I currently
> store a bunch o stuff in the registry, and I'd like to write a
> function to take that and put it in an ini file. I'm not asking you
> how to enum registry keys or anything, but I was wondering about the
> structure of an ini file. Let's say I wanted to store the
> top/left/width/height of multiple forms, along with a few general
> settings. Would you recommend this structure?
>
> [General Settings]
> lastusername=tim
> recalconclose=yes
>
> [frmEstimateMaster]
> left=90
> top=0
> width=6000
> height=4800
>
> [frmSomethingelse]
> left=XX
> top=0
> width=XX
> height=XX

That works... if you have a lot of forms you can reduce the size with
something like:
[screenstate]
frmEstimateMaster_Top=0
frmEsimateMaster_Left=90
frmEstimateMaster_Height=4800
frmEstimateMaster_Width=6000
frmSomethingElse_Top=100
frmSomethingElse_Left=400
frmSomethingElse_Height=4000
frmSomethingElse_Width=3000

or even more if you do:
[screenstate]
frmEstimateMaster=90,0,6000,4800
frmSomethingElse=400,100,3000,4000

if you want to handle multiple users with different settings either use a
user-specific path for the INI file or append it to the section name (e.g.
[screenstate tim]). I try to keep the size of INI files to a minimum.

> I'll have to do some research into finding what happens if a section
> doesn't exist already, if a key doesn't exist already, etc. but I'll
> do that -- not looking for examples, more of a theory answer.

The GetPrivateProfileString and WritePrivateProfileString API calls will
essentially handle those issues for you.

-- 
Reply to the group so all can participate
VB.Net... just say "No"


Relevant Pages

  • Re: Best way to use INI file
    ... I was told that there may be some issues with the security settings on ... I didn't have a way to test writing to the registry and I ... Is there any particular reason you are using an INI file rather ... than GetSettings and SaveSetting to store data in the registry. ...
    (microsoft.public.excel.programming)
  • Re: Best way to use INI file
    ... I was told that there may be some issues with the security settings on ... I didn't have a way to test writing to the registry and I ... Is there any particular reason you are using an INI file ... rather than GetSettings and SaveSetting to store data in the registry. ...
    (microsoft.public.excel.programming)
  • Re: Reg/INI Discussion from much earlier
    ... >in the event of an improper shutdown, the registry is NOT saved. ... >uncontrolable factor and the user wants to save his/her settings. ... Using both the Registry and the INI file has got to be /slower/ than ... I should really do a similar test with FileMon ...
    (microsoft.public.vb.general.discussion)
  • Re: INI formatting
    ... Microsoft's with program settings. ... the registry in Vista. ... But I can see where this restriction in Vista ... | into INI file located in C:\MyCompanyNam\MyProgram. ...
    (microsoft.public.vb.general.discussion)
  • Re: How to save a Date to the registry?
    ... registry, since it was prone to corruption and loss of the users settings. ... Settings that are global to the app I still tend to put in an .ini file ... outage while rewriting the .ini will lose a lot of the settings (far safer ...
    (comp.lang.basic.visual.misc)