Writing to the Registry

H

Howard31

Hi All,

I'm developing an application which will be used on a company network. I am
saving and retrieving settings to the registry, now by default the
SaveSettings saves the settings to the CurrentUser section of the registry,
does that mean that every computer on the network will save and retrieve
different settings? In this application I need that at least some of the
vsettings should be the same for each user and others should be user based,
is there a way with VBA to save the settings so that all computers get the
same values?
 
C

Chip Pearson

Generally speaking, everything in the registry is local to the
machine, and if there are multiple user accounts on a single machine,
each user account will have a separate HKEY_CURRENT_USER region.

Basic application data, items over which the user has no control via
your program, are typically stored in HKEY_LOCAL_MACHINE. Any option
that the use has control of, and that two users may want different
values for, should go in HKEY_CURRENT_USER.

If you are using GetSetting and SaveSetting, those values are stored
in HKEY_CURRENT_USER so each user will have his own set of values and
one user cannot see the values of another user. These values cannot be
shared amongst users.

This is all local to one machine. If you need to store configuration
values to be used by all users on all machines connected to your
network, you can use text-based configuration files (e.g., ini text
files, or, better, XML files). At startup, the application would
connect to the network, read the configuration data out of the data
store on the server (text, xml, perhaps even a database) and act
accordingly to the values of the config data.

I have an ActiveX DLL that wraps up all the various registry-related
API functions into a nice neat VBA-friendly set of functions. You can
get more details and a download at
http://www.cpearson.com/excel/registryworx.aspx.

RegistryWorx allows you to work with any hive (CURRENT_USER,
CLASSES_ROOT, LOCAL_MACHINE) and any key contained therein. However,
it does not support remote registry access (yet). Send me an email if
you want the VB6 source code for the DLL.

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
H

Howard31

Thanks Chip for responding to my question,

Will it be possible for you just to give me the API calls and how to use
them? I understand that It's not that freindly and your thing that you made
with VB6 will be easier to use , but I and my clients don't have VB6 we only
have Excel and the VBA that comes with it.

Thanks again,
 
C

Chip Pearson

Howard,

Although the RegistryWorx.dll component was written in Visual Basic 6,
it is not necessary to have VB6 installed in order to use the
component. If you download the component and unzip it into some
folder, all you need to do is register the component with Windows. Go
to the Windows Start menu, choose Run, and enter the following and
click OK:

RegSvr32 "C:\Your Path\RegistryWorx.dll"

Of course, change "Your Path" to the complete file name of the
RegistryWorx.dll file. If you distribute a workbook that uses the
RegistryWorx component, you'll have to distribute that component with
the workbook and register it on the other machine. In this case, it is
best just to distribute the Setup.exe program and let the users
install that. Setup.exe automatically registers the component, so it
is not necessary to do the RegSvr32 step.

With the component registered, you can reference the component in VBA.
In the VBA Editor, go to the Tools menu, choose References, and scroll
down to Registry Worx. Check this item.

All that said, I have put a zip file up on my web site that has the
complete VB6 project and source files. Download

http://www.cpearson.com/Zips/HowardRegWorx.ziip .

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top