The MASM Forum

General => The Workshop => Topic started by: sinsi on May 06, 2025, 05:45:40 PM

Title: Opinions on where to save options
Post by: sinsi on May 06, 2025, 05:45:40 PM
I have a clock program in progress which has a few options which I was going to save as a binary blob somewhere.
There are many ways to do this, each with their pros and cons.
 - registry   plenty of people dislike storing stuff in the registry
 - data file  what if we don't have write access (e.g. CD-ROM)?
 - resource   write access (as above), AV problems?
 - ADS        only for NTFS

Thoughts?
Title: Re: Opinions on where to save options
Post by: daydreamer on May 06, 2025, 07:35:40 PM
If its supposed to be on any cd or dvd rom,in readme.txt, tell user to install or move to a hd before use,to make it possible to write settings to a config file

Title: Re: Opinions on where to save options
Post by: Biterider on May 06, 2025, 07:49:11 PM
Hi sinsi
Just to complete the list, you can also use an environment variable, which is indirectly a registry entry.

Biterider
Title: Re: Opinions on where to save options
Post by: TimoVJL on May 06, 2025, 08:50:16 PM
Local user profile is a junkyard for many kind of files for user.
An AppData is similar folder for those files.

https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetfolderpatha (https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetfolderpatha)
Title: Re: Opinions on where to save options
Post by: Quin on May 06, 2025, 10:36:54 PM
I agree with Timo, probably the user's appdata folder  if you're worried about running off read-only media.
Title: Re: Opinions on where to save options
Post by: jj2007 on May 06, 2025, 11:53:40 PM
Quote from: sinsi on May 06, 2025, 05:45:40 PM- registry   plenty of people dislike storing stuff in the registry
 - data file  what if we don't have write access (e.g. CD-ROM)?

Just check if you can write to the executable's folder, and if not, use the registry.
Title: Re: Opinions on where to save options
Post by: zedd on May 07, 2025, 12:19:32 AM
Quote from: jj2007 on May 06, 2025, 11:53:40 PM
Quote from: sinsi on May 06, 2025, 05:45:40 PM- data file  what if we don't have write access (e.g. CD-ROM)?
Just check if you can write to the executable's folder, and if not, use the registry.
I would also check the "user" folders as well for write access. Even in scenarios where the user has limited privileges (a work computer for instance), the user folders are a possibility. In that scenario the registry may not be a viable option.
Title: Re: Opinions on where to save options
Post by: Quin on May 07, 2025, 01:30:32 AM
Quote from: zedd on May 07, 2025, 12:19:32 AM
Quote from: jj2007 on May 06, 2025, 11:53:40 PM
Quote from: sinsi on May 06, 2025, 05:45:40 PM- data file  what if we don't have write access (e.g. CD-ROM)?
Just check if you can write to the executable's folder, and if not, use the registry.
I would also check the "user" folders as well for write access. Even in scenarios where the user has limited privileges (a work computer for instance), the user folders are a possibility. In that scenario the registry may not be a viable option.
+1, I'd say current directory, user's appdata folder, and then registry, in that order.
Title: Re: Opinions on where to save options
Post by: NoCforMe on May 07, 2025, 03:56:55 AM
My preference, being a registry disliker, is a config file in the application's directory.

As you know, it's really easy to locate that folder by using GetModuleFileName(). That way you don't have config files spread out all over hell and gone.

Of course, if you want to have separate config files depending on what the user's current directory is, you can just write them to that folder.

Seems like a pretty good assumption that both of these schemes should have a writable folder available.
Title: Re: Opinions on where to save options
Post by: sinsi on May 08, 2025, 05:01:12 PM
OK, so my thoughts are
 - exe folder
 - user's appdata folder
 - registry
The data is going to be 4xDWORDs (x, y, font size, text colour) and a unicode font name.

Since it's going to start with Windows, maybe create a shortcut in Startup and use command-line parameters.


Quote from: jj2007 on May 06, 2025, 11:53:40 PMuse the registry.
jj, I had you pegged as vehemently anti-registry :badgrin:
Title: Re: Opinions on where to save options
Post by: NoCforMe on May 08, 2025, 06:18:49 PM
One thing I'm unclear about here:
What exactly is the "user's appdata folder"?
Is this their <username> folder under Users?
Title: Re: Opinions on where to save options
Post by: sinsi on May 08, 2025, 07:34:30 PM
Quote from: NoCforMe on Today at 06:18:49 PMOne thing I'm unclear about here:
What exactly is the "user's appdata folder"?
Is this their <username> folder under Users?
I would use local appdata
LOCALAPPDATA=C:\Users\<user>\AppData\Local
APPDATA=C:\Users\<user>\AppData\Roaming