473,624 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String data not properly read from Windows Registry

Hi
i have made a Key under the HKEY_LOCAL_MACH INE\Software\My
Toolbar\Setting .
i have placed some values under the Setting key.
i m trying to access the values under that key and want to map them to
a dialog box ,means they should be visible in their corresponding Edit
controls when i display the dialog.i have used the following code in
OnInitDialog() function to map the values to their corresponding
controls but when the dialog displayed some values are repeatedly shown

in different controls.tell me where i m doing a mistake .

CRegKey regKey;
TCHAR szPath[] = _T("SOFTWARE\\M ySpace.com
ToolBar\\Settin g");
TCHAR szBuff[1024];
DWORD dwSize=dwSize = sizeof(szBuff)/sizeof(szBuff[0]);
LONG err=regKey.Open (HKEY_LOCAL_MAC HINE,szPath);
if (err!=ERROR_SUC CESS)
regKey.Close();
regKey.QueryVal ue(szBuff, _T("FirstName") , &dwSize);
m_FirstName = szBuff;
regKey.QueryVal ue(szBuff, _T("LastName") , &dwSize);
m_LastName= szBuff;
regKey.QueryVal ue(szBuff, _T("PresentAddr ess"), &dwSize);
m_PresentAddres s= szBuff;
regKey.QueryVal ue(szBuff, _T("PermanentAd dress"), &dwSize);
m_PermanentAddr ess = szBuff;
regKey.QueryVal ue(szBuff, _T("City"), &dwSize);
m_City= szBuff;
regKey.QueryVal ue(szBuff, _T("Country"), &dwSize);
m_Country = szBuff;
regKey.QueryVal ue(szBuff, _T("ZipCode"), &dwSize);
m_Zip= szBuff;
regKey.QueryVal ue(szBuff, _T("PhoneNo"), &dwSize);
m_Phone=szBuff;
regKey.QueryVal ue(szBuff, _T("MobileNo") , &dwSize);
m_Mobile = szBuff;
regKey.QueryVal ue(szBuff, _T("AutofillEma il"), &dwSize);
m_EmailAddress = szBuff;
UpdateData(fals e);
when the dialog displayed often LastName value from registry is
displayed in the m_PresentAddres s and m_PermanentAddr ess edit
controls.and City Value fron registry id
also displayed in m_Country edit control.in the same way some values
are retrieving from registry and when i try to map them with edit
controls on the Dialog box .why did they are ?

Jun 20 '06 #1
3 1129
> i have made a Key under the HKEY_LOCAL_MACH INE\Software\My
Toolbar\Setting .
i have placed some values under the Setting key.
i m trying to access the values under that key and want to map them to
a dialog box ,means they should be visible in their corresponding Edit
controls when i display the dialog.i have used the following code in
OnInitDialog() function to map the values to their corresponding
controls but when the dialog displayed some values are repeatedly shown

in different controls.tell me where i m doing a mistake .

CRegKey regKey;
TCHAR szPath[] = _T("SOFTWARE\\M ySpace.com
ToolBar\\Settin g");
TCHAR szBuff[1024];
DWORD dwSize=dwSize = sizeof(szBuff)/sizeof(szBuff[0]);
LONG err=regKey.Open (HKEY_LOCAL_MAC HINE,szPath);
if (err!=ERROR_SUC CESS)
regKey.Close();
regKey.QueryVal ue(szBuff, _T("FirstName") , &dwSize);
m_FirstName = szBuff;
regKey.QueryVal ue(szBuff, _T("LastName") , &dwSize);
m_LastName= szBuff;
regKey.QueryVal ue(szBuff, _T("PresentAddr ess"), &dwSize);
m_PresentAddres s= szBuff;


2 things:
- you don't check the return value of QueryValue. shame on you.
- you don't re-initialize the dwSize value before each call to QueryValue.
from MSDN: "pdwCount
The size of the string data. Its value is initially set to the size of the
szValue buffer."
you should initialize it to the max string size before each call.

another thing is that QueryValue is depreceated in favor of this method:
LONG QueryValue(
LPCTSTR pszValueName,
DWORD* pdwType,
void* pData,
ULONG* pnBytes
) throw( );

also, this looks weird:
DWORD dwSize=dwSize = sizeof(szBuff)/sizeof(szBuff[0]);

--

Kind regards,
Bruno.
br************* *********@hotma il.com
Remove only "_nos_pam"
Jun 20 '06 #2

"CrimeMaste r" <aj******@gmail .com> wrote in message
news:11******** *************@c 74g2000cwc.goog legroups.com...
Hi
i have made a Key under the HKEY_LOCAL_MACH INE\Software\My
Toolbar\Setting .
i have placed some values under the Setting key.
i m trying to access the values under that key and want to map them to
a dialog box ,means they should be visible in their corresponding Edit
controls when i display the dialog.i have used the following code in
OnInitDialog() function to map the values to their corresponding
controls but when the dialog displayed some values are repeatedly shown

in different controls.tell me where i m doing a mistake .

regKey.QueryVal ue(szBuff, _T("City"), &dwSize);
m_City= szBuff;


In addition to what Bruno sais,
why don't you use
LONG result = regKey.QueryStr ingValue(_T("Ci ty"), szBuff, &dwSize);

Jun 20 '06 #3

Egbert Nierop (MVP for IIS) wrote:
"CrimeMaste r" <aj******@gmail .com> wrote in message
news:11******** *************@c 74g2000cwc.goog legroups.com...
Hi
i have made a Key under the HKEY_LOCAL_MACH INE\Software\My
Toolbar\Setting .
i have placed some values under the Setting key.
i m trying to access the values under that key and want to map them to
a dialog box ,means they should be visible in their corresponding Edit
controls when i display the dialog.i have used the following code in
OnInitDialog() function to map the values to their corresponding
controls but when the dialog displayed some values are repeatedly shown

in different controls.tell me where i m doing a mistake .

regKey.QueryVal ue(szBuff, _T("City"), &dwSize);
m_City= szBuff;


In addition to what Bruno sais,
why don't you use
LONG result = regKey.QueryStr ingValue(_T("Ci ty"), szBuff, &dwSize);

Thanks dear
But not discourage me
its working.

Crime Master.

Jun 21 '06 #4

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

Similar topics

3
2140
by: Varun | last post by:
I have a solution which contains windows,web,mobile presentations. Now i want to share the connection string in the web.config file. i want to write a method in a common layer where i can retrieve the connection string for all the presentations layers How can i do that? Any suggestions or urls are suggested? Thank you
1
474
by: Zack | last post by:
Hi, Have a quick question. Having a problem connecting from the IIS server (windows 2000 sp3) which hosts the asp.net application to retrieve data from an SQL server (windows nt 4, sql 7). The error keeps coming up SQL server does not exist or access denied. I've checked the permissions, etc and it seems to be fine. I used query analyzer from the windows 2000 (has enterprise connectivity tools) machine and it works. Here is the...
5
1861
by: Mike | last post by:
I'm trying to connect to a SQL db, I have the db setup as a DSN on my machine, here is my connection string that i'm trying to use. string dbConn = "Provider=sqloeldb;data source=Tech;Initial Catalog=Tech;Integrate Security=SSPI;"; on my page I get this error; SQL Server does not exist or access denied.
12
3459
by: Charlie | last post by:
Hi: My host will not allow me use a trusted connection or make registry setting, so I'm stuck trying find a way to hide connection string which will be stored in web.config file. If I encrypt string externally, can it be used in it's encrypted form to connect to SQL Server? If I decrypt back to string for use in connection string during runtime, I have to supply a key. If I do that, hacker could use key to break encryption. How do I...
4
2204
by: Krista Lemieux | last post by:
Hello, I know this is probably a hudge topic to discuss and there are lots of different ways of implementation, but I still would like to ask and hear the most commonly used techniques for this. Basically I have an ASP.NET application, and my connection string currently is stored in a constant public variable in one of my classes. The reason for that is so that I only have one place to change the connection string when I deploy it on a...
14
3490
by: WebMatrix | last post by:
Hello, I have developed a web application that connects to 2 different database servers. The connection strings with db username + password are stored in web.config file. After a code review, one developer suggested that it's a security flaw; therefore connection strings should be kept somewhere else or encrypted. My argument is that web.config file is protected by IIS and Windows security which is the case. And another argument is that...
9
4978
by: nbs.tag | last post by:
hey guys heres my question. I was told by a little birdie that .net 2.0 has the ability to read a connection string directly from a registry key. so in the registry key a string value of say : database=northwind;user=username;password=pw; is stored at software/myApp/connSTR in the registry, i was told its possible to just place <connectionStrings> <add name="asd"
9
2273
by: KarlM | last post by:
After reading some articles regarding confuguration data I'm a bit confused. Where is the right place for storing configuration data? - XML-files? - registry? - INI-files? (from a users point of view, ini-files are more comfortable to read and edit) Where should I store user specific config data? Where should I store machine specific config data?
9
1984
by: kirk | last post by:
I have program.cs, my "main" form and then a "settings" form. My "main" form existed for awhile and I had constants, instantiations, properties, etc within it created. I went to create my "settings" form and constantly found myself adjusting my "main" form entities to be static and inevitably just passing in the "main" forms 'this' instance to the "settings" constructor to simplify it all.
0
8233
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
8619
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
8334
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
8474
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7158
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
6108
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
4173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2604
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
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.