473,791 Members | 3,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Registry Access (Write Access)

MFC Application VC++.NET 2003

I have a certain registry key (HKCU\Software\ MyKey) that contains between 30
& 64 string values

I need to write a '*' to all those 30 - 64 string values under that
particular key.

Example:

HKCU\Software\M yKey

Key name Value

MyKey1 http://www.somesite.com
MyKey2 http://www.someothersite.com

Becomes:

MyKey1 *
MyKey2 *
....

Any ideas?

Have searched The Code Project & cannot make head not tail of these classes
as I am just starting back into C++ after many years

TIA
Apr 3 '07 #1
20 3802
CRegKey is your friend.

http://msdn2.microsoft.com/en-us/lib...y4(VS.80).aspx

Brian

"Newbie Coder" <ne*********@sp ammeplease.comw rote in message
news:uW******** *****@TK2MSFTNG P06.phx.gbl...
MFC Application VC++.NET 2003

I have a certain registry key (HKCU\Software\ MyKey) that contains between
30
& 64 string values

I need to write a '*' to all those 30 - 64 string values under that
particular key.

Example:

HKCU\Software\M yKey

Key name Value

MyKey1 http://www.somesite.com
MyKey2 http://www.someothersite.com

Becomes:

MyKey1 *
MyKey2 *
...

Any ideas?

Have searched The Code Project & cannot make head not tail of these
classes
as I am just starting back into C++ after many years

TIA


Apr 3 '07 #2
Bian,

First of all thank you for your reply

The page says Framework 2 specific. I don't want to use the framework
whatsoever

Any other suggestions?

"Brian Muth" <bm***@mvps.org wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
CRegKey is your friend.

http://msdn2.microsoft.com/en-us/lib...y4(VS.80).aspx

Brian

"Newbie Coder" <ne*********@sp ammeplease.comw rote in message
news:uW******** *****@TK2MSFTNG P06.phx.gbl...
MFC Application VC++.NET 2003

I have a certain registry key (HKCU\Software\ MyKey) that contains
between
30
& 64 string values

I need to write a '*' to all those 30 - 64 string values under that
particular key.

Example:

HKCU\Software\M yKey

Key name Value

MyKey1 http://www.somesite.com
MyKey2 http://www.someothersite.com

Becomes:

MyKey1 *
MyKey2 *
...

Any ideas?

Have searched The Code Project & cannot make head not tail of these
classes
as I am just starting back into C++ after many years

TIA


Apr 3 '07 #3

"Newbie Coder" <ne*********@sp ammeplease.comw rote in message
news:eM******** ******@TK2MSFTN GP02.phx.gbl...
Bian,

First of all thank you for your reply

The page says Framework 2 specific. I don't want to use the framework
whatsoever

Any other suggestions?
Using Visual Studio .NET 2003, create the C++ project of your choice, taking
care to check the "support for ATL" checkbox. You can use CRegKey just fine.
It does not depend on .NET Framework 1.1. or 2.0.

Brian.
Apr 4 '07 #4
Brian,

In my original post it said MFC application

Why should I re-write many thousand lines of code in order to your
suggestion?

I was hoping that someone would write me a function in order to do this

How did you gain your MVP status?

In my original question I asked for MFC C++.NET 2003 app & you gave me a
link to 2005 (Framework 2) when I am using 1.1
Now, you ask me to totally change my project just so your link works - you
are joking of course.

Sorry, but your replies aren't useful at all!!

--
Newbie Coder
(It's just a name)

"Brian Muth" <bm***@mvps.org wrote in message
news:e2******** ******@TK2MSFTN GP03.phx.gbl...
>
"Newbie Coder" <ne*********@sp ammeplease.comw rote in message
news:eM******** ******@TK2MSFTN GP02.phx.gbl...
Bian,

First of all thank you for your reply

The page says Framework 2 specific. I don't want to use the framework
whatsoever

Any other suggestions?

Using Visual Studio .NET 2003, create the C++ project of your choice,
taking
care to check the "support for ATL" checkbox. You can use CRegKey just
fine.
It does not depend on .NET Framework 1.1. or 2.0.

Brian.


Apr 4 '07 #5
Newbie Coder wrote:
Brian,

In my original post it said MFC application

Why should I re-write many thousand lines of code in order to your
suggestion?

I was hoping that someone would write me a function in order to do this

How did you gain your MVP status?

In my original question I asked for MFC C++.NET 2003 app & you gave me a
link to 2005 (Framework 2) when I am using 1.1
Now, you ask me to totally change my project just so your link works - you
are joking of course.

Sorry, but your replies aren't useful at all!!
Newbie:

What is your problem? Brian told you about CRegKey. You have VS2003.
Look it up in the help. It's there. It's in VC6 also.

David Wilkinson
Apr 4 '07 #6
David,

You have an attitude

If someone asked me how to do it in another language then I'd be the first
one to write the function & paste the code to the user, but that's the
difference between you & I.

There are many so-called MVP who cannot write a line of code if their life
depended on it. Herfried is a perfect example of that.

Back to my original question:

If I search The Code Project I get many, many classes, but I need one
function. Plus, I am starting out back into C++ since I stopped coding in it
around 2001/2002.

--
Newbie Coder
(It's just a name)
"David Wilkinson" <no******@effis ols.comwrote in message
news:eA******** ******@TK2MSFTN GP06.phx.gbl...
Newbie Coder wrote:
Brian,

In my original post it said MFC application

Why should I re-write many thousand lines of code in order to your
suggestion?

I was hoping that someone would write me a function in order to do this

How did you gain your MVP status?

In my original question I asked for MFC C++.NET 2003 app & you gave me a
link to 2005 (Framework 2) when I am using 1.1
Now, you ask me to totally change my project just so your link works -
you
are joking of course.

Sorry, but your replies aren't useful at all!!

Newbie:

What is your problem? Brian told you about CRegKey. You have VS2003.
Look it up in the help. It's there. It's in VC6 also.

David Wilkinson


Apr 4 '07 #7
>
In my original post it said MFC application
My solution applies to MFC applications.
>
Why should I re-write many thousand lines of code in order to your
suggestion?
Why do you believe you need to rewrite any code at all?
>
I was hoping that someone would write me a function in order to do this

How did you gain your MVP status?

In my original question I asked for MFC C++.NET 2003 app & you gave me a
link to 2005 (Framework 2) when I am using 1.1
On the reference I gave you, there is a link to the Microsoft Visual Studio
2003/.NET Framework 1.1 version of the document. So save you from the extra
effort on clicking on that link, here it is for you:

http://msdn2.microsoft.com/en-us/lib...y4(vs.71).aspx

You will find that the information is the same for both environments.

The information on this page is valuable and gives clear instructions on how
to use CRegKey. If you don't want to experiment with the fresh solution I
suggested in my previous post, go directly to your MFC project and insert

#include "atlbase.h"

at the top of your code after any other #include statements. You can now use
CRegKey to your heart's delight.
Now, you ask me to totally change my project just so your link works - you
are joking of course.
The changes to your code are minimal and trivial.
Sorry, but your replies aren't useful at all!!
Then please re-post your questions if you are confused. What has not been
answered?.

Brian

Apr 4 '07 #8

"Newbie Coder" <ne*********@sp ammeplease.comw rote in message
news:uT******** ******@TK2MSFTN GP02.phx.gbl...
David,
Answer below. But first I address your statements.
>
You have an attitude
But yours is worse. Someone took the time to try to help you. If you were
paying for the assistance you would have a reason to complain.
>
If someone asked me how to do it in another language then I'd be the first
one to write the function & paste the code to the user, but that's the
difference between you & I.

There are many so-called MVP who cannot write a line of code if their life
depended on it. Herfried is a perfect example of that.
Asking you to rewrite your project with a different toolkit is not really
much different from demanding that someone else learn the MFC you've chosen.
Except that it's your problem, and anyone helping you is on a volunteer
basis.
>
Back to my original question:

If I search The Code Project I get many, many classes, but I need one
function. Plus, I am starting out back into C++ since I stopped coding in
it
around 2001/2002.
No, you need three functions:

RegOpenKeyEx
RegSetValueEx
RegCloseKey

All provided by windows itself, with no extra runtime library dependencies.
MFC should already be including windows.h for you, just make sure you link
with Advapi32.lib.
>
--
Newbie Coder
(It's just a name)

Apr 5 '07 #9
Ben,

Thanks for the three functions. These are the same as I used to use back in
the VB 6 days.

I wanted to write in a Win32 application with a dialog box

If someone asked this question for VB.NET then I would code them a complete
reply. In this case a re-usable function like so:

Private Sub RemoveSomeValue (ByVal sValue As String)
Dim strKey As String = "Software\MyKey "
Dim reg As RegistryKey = Registry.Curren tUser.OpenSubKe y(strKey,
True)
Try
reg.SetValue(sV alue, "*")
reg.Close()
reg = Nothing
Catch ex As Exception
End Try
End Sub

I wouldn't say look at 'RegistryKey'. How lame is that & what help is it to
the OP? No help because they probably knew that much already

=============== =============== ========

I got a registry class from The Code Project, stripped out all the functions
I didn't need & are left with the one function I want. However, I add the
header to the MFC form & when I try to call the function in that class I get
a compiler error (C2352 Illegal Call To Non Static Member). God knows what
it means. Checked MSDN
(http://msdn2.microsoft.com/en-us/lib...te(vs.71).aspx) & all it
says is to comment it out. What use is that?

So, if you got a total newbie asking the same question as I did & you get a
useless answer like Brian wrote then its absolutely no use whatsoever, is
it? No. Why? Because they don't have a clue to begin with & what I've found
on these programming newsgroups is that if someone answers the thread others
see that its been answered & leave the post alone. Thefore if you get a
useless, no help whatsoever, ridiculous reply like I got originally by Brian
then you have to ask the question again & again & again until it does get
answered correctly.

For C++ I used to ask questions on the GotDotNet website, but its now
closed. Used to get good results... & detailed answers too.

There are so, so, so many MVP's who give out rubbish in order to get another
post listed. Does MVP status mean you can use Google & you cannot write
code? It seems that way to me from what I have seen by using these
newsgroups for a number of years.

So, Ben. Can you see now why I answered Brian like I did?

Header file (RegisterEx.h):

#pragma once
#include "stdafx.h"

class CRegisterEx

{

public:

CRegisterEx(CSt ring path);

~CRegisterEx(vo id);

public:

void WriteString(CSt ring str, CString subPath = "", CString Key = "");

};

CPP Filr (RegisterEx.cpp )

#include "StdAfx.h"

#include "registerex .h"

#include <stdlib.h>

#pragma warning ( disable : 4267 )

#define MAX_BUFFER 2048

char buffer[MAX_BUFFER];

CString pt;

CRegisterEx::CR egisterEx(CStri ng path)

{

pt = path;

}

CRegisterEx::~C RegisterEx(void )

{

}

// Writing strings to the register.

void CRegisterEx::Wr iteString(CStri ng str, CString subPath, CString Key)

{

HKEY hk;

TCHAR szBuf[2048];

CString insidePath = pt;

if (Key)

{

insidePath = insidePath + "\\" + subPath;

}

if (RegCreateKey(H KEY_CURRENT_USE R, _T(insidePath), &hk))

{

// Woops, you don't have privileges

TRACE0("Could not create the registry key.\n\nDo you have the right
privileges?\n") ;

}

strcpy(szBuf, str);

if (RegSetValueEx( hk, _T(Key), 0, REG_EXPAND_SZ, (LPBYTE)szBuf, strlen(str)
+ 1))

{

// Hmm, you did something wrong

TRACE0("Could not set the given String.\n\nDo you have the right
privileges?\n") ;

}
RegCloseKey(hk) ;

}
--
Newbie Coder
(It's just a name)


"Ben Voigt" <rb*@nospam.nos pamwrote in message
news:uz******** ******@TK2MSFTN GP03.phx.gbl...
>
"Newbie Coder" <ne*********@sp ammeplease.comw rote in message
news:uT******** ******@TK2MSFTN GP02.phx.gbl...
David,

Answer below. But first I address your statements.

You have an attitude

But yours is worse. Someone took the time to try to help you. If you
were
paying for the assistance you would have a reason to complain.

If someone asked me how to do it in another language then I'd be the
first
one to write the function & paste the code to the user, but that's the
difference between you & I.

There are many so-called MVP who cannot write a line of code if their
life
depended on it. Herfried is a perfect example of that.

Asking you to rewrite your project with a different toolkit is not really
much different from demanding that someone else learn the MFC you've
chosen.
Except that it's your problem, and anyone helping you is on a volunteer
basis.

Back to my original question:

If I search The Code Project I get many, many classes, but I need one
function. Plus, I am starting out back into C++ since I stopped coding
in
it
around 2001/2002.

No, you need three functions:

RegOpenKeyEx
RegSetValueEx
RegCloseKey

All provided by windows itself, with no extra runtime library
dependencies.
MFC should already be including windows.h for you, just make sure you link
with Advapi32.lib.

--
Newbie Coder
(It's just a name)


Apr 5 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
436
by: Tim Blizard | last post by:
I know this topic has been discussed before but I couldn't find any thread more recent than about 18 months and was interested in what conclusions people had come to recently. Invariably 3 advantages of XML config files are promoted; 1. The .NET framework provides built-in support for reading application configuration data from .config files very easily 2. Using these files makes it possible to deploy an application using
2
2478
by: Dan Sikorsky | last post by:
Should application data be read and written to the Registry to persist state, or should the App.config file be used? If the Registry should be used, what .NET class reads and writes the Registry? If the App.config file should be used, reading a configuration setting is trivial, but there appears to be no write methtod. Please post a write method when replying. --
7
16519
by: Dennis C. Drumm | last post by:
Can my program access the HKEY_LOCAL_MACHINE/Software section of the registry when being used by a user with restricted rights (not with admin rights)? If so, how? I have a program that functions just fine when run by an administrator but generates an exception when run by a restricted user. The program accesses the HKEY_LOCAL_MACHINE/Software section to set or get application settings that are not user specific. Thanks,
3
1408
by: Martin | last post by:
Hi I am attempting to write a small application that will allow users to manage the AddressBar entries within Internet Explorer. The typed URLs in the AddressBar can be found at HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURLs and I have successfully managed to get this list via a Windows C# .NET app with the following code : public Form1()
1
1741
by: Yoshitha | last post by:
Hi I am developing web application through which i've to write and read the values from the registry. When i set impersonate property to "false" it is displaying exception " Requested Registry Access is not allowed" so then i changed impersonate to "true" and it is reading values from the registry and writing into the registry. but when i runing the same aplication in same system now am getting the exception "requested registry access...
8
5493
by: Al Kaufman | last post by:
I have a simple console app that uses: regSubKey = <some registry key> Dim reg As RegistryKey = Registry.ClassesRoot.OpenSubKey(regSubKey) Dim path As String path = CStr(reg.GetValue(""))
3
5743
by: Nikolay Petrov | last post by:
Why I always get 'Requested registry access is not allowed' when i try to Read/Write to Windows Registry from ASP service. I use ASP NET account? Also granted full permissions to required Registry keys. What is the problem? TIA
3
18095
by: Dylan Parry | last post by:
Hi folks, I've just got a new machine at work, so I've spent all day copying across all of my work from my old machine. Now I've come across a problem that I've never seen before. I now get the following error when I attempt to run one of my sites: "Access to the registry key 'Global' is denied"
4
3282
by: Colin Priest | last post by:
I am trying to write a program to switch off serial port enumerations via the associated registry key. My code is: RegistryPermission permission = new RegistryPermission(RegistryPermissionAccess.Write, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\ACPI\\PNP0501"); permission.Demand(); RegistryKey key = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Enum\\ACPI\\PNP0501", true);
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9517
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10428
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10156
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.