Jump to content
Xtreme .Net Talk

Recommended Posts

Guest Morgon
Posted

With the project I'm running, I just use the builtin SaveSetting() and GetSetting() functions.

 

Format (All args are type String):

GetSetting(HKCU Folder, SubFolder, Key, Default Value If Key Not Found)

 

SaveSetting(HKCU Folder, SubFolder, Key, Value)

 

(Caveat - This places the folder under "HKCU\Software\VB and VBA Program Settings" - Cool for some of us, but if you're deploying something name-worthy, I'm not sure how to keep it from sticking it there)

 

Example:

Dim SaveDir As String = GetSetting("MyProj", "Settings", "FileLocation", CStr(MyDocs) & "\MyProj Personal Files\")

Or

SaveSetting("MyProj", "Settings", "FileLocation", InputBox1.Text)

 

---

Just as an added bonus, I've seen a lot of people asking for a way to find out the current "My Documents" directory, since it is changeable and will vary on a multi-user machine.. the way I do it is just with a couple little lines at the top:

Dim aKey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")

Dim MyDocs As Object = aKey.GetValue("Personal")

 

Also note you must use an "Imports Microsoft.Win32" to use the RegistryKey type

 

Hope this helps!

-Morgon

Guest Morgon
Posted
I'm curious.. why is XML better than using the registry, or even just an INI file? Is it "coolness factor" or is there some real benefit?
Guest _RIP_DREAMS
Posted
xml r0x are easy to see and easy to use
Guest Morgon
Posted
Okay, well Captain '37337'.. why does XML 'rox' .. is it just like an INI file, or what? I've only seen XML as its own file.. so is it just "INI 2.0" or what? Someone enlighten me :)
  • *Gurus*
Posted

Everything taken together, XML is to INI as the ocean is to small

pond. That doesn't mean it would be better when all you need is

a simple way to save some options, but as has been said, XML is

on the MS marketing machine top 10 list.

Guest SoTTo
Posted
The GetSetting and SaveSetting Functions: were are your options saved????

HKEY_CURRENT_USER - software - VB and VBA Program Settings - application name (you can specify this one) - subkey (you can specify this one to - value (pretty logic that you can specify these too)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...