473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Registry Key save to a "Virtual Store" in current root and Local Machin, Help!

Sl1ver
196 100+
I have this piece of code
Expand|Select|Wrap|Line Numbers
  1.  public bool Write(string KeyName, object Value)
  2.         {
  3.             try
  4.             {
  5.                 // Setting
  6.                 string subKey1 = "SOFTWARE\\QwixAssets";
  7.                 RegistryKey rk = Registry.LocalMachine;
  8.                 RegistryKey sk1 = rk.CreateSubKey(subKey1);
  9.                     //rk.CreateSubKey(subKey);
  10.  
  11.                 // Save the value
  12.                 sk1.SetValue(KeyName.ToUpper(), Value);
  13.  
  14.                 return true;
  15.             }
  16.             catch (Exception e)
  17.             {
  18.  
  19.  
  20.                 MessageBox.Show(e.ToString(), "Writing registry " + KeyName.ToUpper().ToString());
  21.                 return false;
  22.             }
  23.         }
  24.  
that used to work but for some reason it writes to current root - virtual store - machine and then the node but it also reads from there and my code for reading(when app starts up) is

Expand|Select|Wrap|Line Numbers
  1. public string GetRegistryValue(string KeyName)
  2.         {
  3.             // Opening the registry key
  4.             string subKey = "SOFTWARE\\QwixAssets";
  5.             RegistryKey rk = Registry.LocalMachine;
  6.             RegistryKey sk = rk.OpenSubKey(subKey);
  7.  
  8.             if (sk == null)
  9.             {
  10.                 MessageBox.Show("Problem in the Registry Source");
  11.                 return null;
  12.             }
  13.             else
  14.             {
  15.                 try
  16.                 {
  17.                     return (string)sk.GetValue(KeyName.ToUpper().ToString());
  18.                 }
  19.                 catch (Exception e)
  20.                 {
  21.                     MessageBox.Show(e.ToString(), "Reading registry " + KeyName.ToUpper().ToString());
  22.                     return null;
  23.                 }
  24.             }
  25.         }
  26.  
Is this a windows 7 thing or is the code just wrong?
Jan 8 '10 #1
5 5063
AKJo
3
How can I get this working in C# Mobile Windows?
Suppose some "using" is needed?
What makes the the registry virtual, and how do you sore it in the real registry?

Thanks in advance for any help
Jan 12 '10 #2
Sl1ver
196 100+
AKJo, i haven't programmed much on windows mobile but this code will read and write to the real registry, i just got a way of saving it on the virtual store, try this code in a project and you will see it will write and read from the registry.

Obviously you will need to massage the code a little bit
Jan 13 '10 #3
AKJo
3
Tkanks for your advice, but my main, or at least first problem is that namespece name "RegistryKey" is not recognised by my compiler.
So obviously I miss a reference to it, but I don't know how to find out what I'm missing.
Jan 13 '10 #4
Sl1ver
196 100+
use...using Microsoft.Win32;
Jan 13 '10 #5
AKJo
3
Thanks Sl1ver,
It make a big difference.
Jan 17 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: mshetty | last post by:
Hi, I get an error "Warning: b::a_method hides the virtual function a::a_method()." on compiling the following code.. #include <iostream.h> class a {
5
by: Duck Dodgers | last post by:
Here is my situation class base { }; class child1 { int data; }; class child2 {
6
by: kelvSYC | last post by:
This little bit of seeminly innocent code seems to give me these two errors, all on the line that declares check(). Is there some part of C++ that I'm missing out on? class Condition { public:...
175
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
9
by: Jacek Dziedzic | last post by:
Hi! I often find that my programs need to store information on "current mode of something" with two or at most several mutually exclusive "modes" to choose from, e.g. - datafile: is it in a)...
4
by: wizwx | last post by:
The followings are a few lines of code from the Template method in "Thinking in C++" vol.2 pp.639 class ApplicationFramework { protected: virtual void customize1() = 0; virtual void...
4
by: Luc The Perverse | last post by:
Hi - I have very little C# programming experience. I am making a software product which calls for an interface almost identical to Windows Explorer - and I wondered if mounting a "virtual drive"...
2
by: barthelemy.von.haller | last post by:
Hello ! I am having a problem which I thought was an easy one but which starts to drive me crazy. Imagine that I have a text displayed in a div. I would like a button to download a text file...
2
by: farid25 | last post by:
I have a web application hosted on windows server 2003 "IIS 6,virtual ip", that is used on the local intranet of my company. now i want to access this web application from a real ip PC how can I do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.