How to add a new registry key of type string to registry

K

kumar

hai,

i am developing an vc++ application.

For this application i have to create a new string type key in the
registry.

i know that, RegCreateKey and RegCreateKeyEx fuctions can be used
to create the new value.

but i am unable to succeed on those. so can you give me an example
for this one ?


Regards,


kumar.
 
W

William DePalo [MVP VC++]

[responding out of order to post]
but i am unable to succeed on those. so can you give me an
example for this one ?

Well, it is always good to describe a _little_ about what you have tried and
how it failed.
For this application i have to create a new string type key in
the registry.

i know that, RegCreateKey and RegCreateKeyEx fuctions can be used
to create the new value.

Just so there is no confusion, do you know the difference between keys and
values? Are you creating a new key or a new string value on an existing key.
If you are creating a new key then of what key is yours a subkey? If you
describe a little of the key structure you need, I'm sure someone here can
sketch what you need to do.

Finally, note that the shell provides a set of simplified (if somewhat
inefficient) functions for common registry updates. The functions all have
names like SHRegxxx

Regards,
Will
 
E

Egbert Nierop \(MVP for IIS\)

If you use ATL or MFC... (error handling omitted)

CRegKey regkey;


LONG lErr = regkey.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE", KEY_WRITE); // new
Key

lErr = regkey.Create(regkey.m_hKey, L"blahkey");

lErr = regkey.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\blahkey", KEY_WRITE);

lErr = regkey.SetStringValue(L"newValue", L"theValue"); // new string value
 

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