473,320 Members | 1,947 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,320 software developers and data experts.

reading the registry key

my program it's just tools for my little home network.. Only thing I
have left to do is reading the registy key
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\lanmanserver\
"shared"]
to check the path to the shared folder.. this path is always updated so
I will always be able to find the folder if it's moved (i like this
idea!)

but I've had alot of trouble coding it even after tutorials
I just need it to show me the path to the shared folder by reading that
registly key.

I guess Im just asking you to show me how it's done, I truly give up on
this and reading tutorials

Thanks

Mar 8 '06 #1
2 1955
zo****@yahoo.com wrote:
my program it's just tools for my little home network.. Only thing I
have left to do is reading the registy key
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\lanmanserver\
"shared"]
to check the path to the shared folder.. this path is always updated so
I will always be able to find the folder if it's moved (i like this
idea!)

but I've had alot of trouble coding it even after tutorials
I just need it to show me the path to the shared folder by reading that
registly key.

I guess Im just asking you to show me how it's done, I truly give up on
this and reading tutorials


Well, could you show us what you've tried? Ideally, post a short but
complete program which demonstrates the problem - just tries to print
out the value of the registry entry. Then say what *actually* happens
as well.

See http://www.pobox.com/~skeet/csharp/complete.html for more on this.

Jon

Mar 8 '06 #2
On 8 Mar 2006 08:54:52 -0800, zo****@yahoo.com wrote:
my program it's just tools for my little home network.. Only thing I
have left to do is reading the registy key
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\lanmanserver\
"shared"]
to check the path to the shared folder.. this path is always updated so
I will always be able to find the folder if it's moved (i like this
idea!)

but I've had alot of trouble coding it even after tutorials
I just need it to show me the path to the shared folder by reading that
registly key.

I guess Im just asking you to show me how it's done, I truly give up on
this and reading tutorials

Thanks


using System;
using Microsoft.Win32;
namespace MyNameSpace
{
public class Registry
{
public Registry()
{
}
public bool CreateKey(RegistryHive RootKey, string
SubKey)
{
bool blRetVal;
RegistryKey RKey =
RegistryKey.OpenRemoteBaseKey(RootKey,String.Empty );
blRetVal = false;
try
{
RegistryKey RSubKey =
RKey.CreateSubKey(SubKey);
blRetVal = true;
RSubKey.Close();
}
catch
{
blRetVal = false;
}
RKey.Close();
return blRetVal;
}
public object GetValue(RegistryHive RootKey, string
SubKey, string ValueName, object DefaultValue)
{
object oRetVal;
RegistryKey RKey =
RegistryKey.OpenRemoteBaseKey(RootKey,String.Empty );
oRetVal = null;
try
{
RegistryKey RSubKey =
RKey.OpenSubKey(SubKey);
oRetVal = RSubKey.GetValue(ValueName,
DefaultValue);
RSubKey.Close();
}
catch
{
oRetVal = DefaultValue;
}
RKey.Close();
return oRetVal;
}
public bool SetValue(RegistryHive RootKey, string
SubKey, string ValueName, object Value)
{
bool blRetVal;
RegistryKey RKey =
RegistryKey.OpenRemoteBaseKey(RootKey,String.Empty );
blRetVal = false;
try
{
RegistryKey RSubKey =
RKey.OpenSubKey(SubKey,true);
RSubKey.SetValue(ValueName, Value);
RSubKey.Close();
blRetVal = true;
}
catch
{
blRetVal = false;
}
RKey.Close();
return blRetVal;
}
}
}
Leon
Mar 8 '06 #3

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

Similar topics

1
by: Duncan Allen | last post by:
I'm trying to use aspnet_setreg to encrypt user names & password used in the web.config file for use in the indentity element. When the website runs I get the message 'Error reading the password...
5
by: Dhilip Kumar | last post by:
Hi All, I'm writing a Windows Service app using C#. I need to read some configuration settings before the service starts up. These settings will be used by the service in its operation. ...
6
by: Bry | last post by:
I'm having problems writing (and reading) boolean data to the registry. // Write a boolean value to the registry // I've not included the obvious bits of code in these samples bool myBool =...
1
by: Peter John | last post by:
I am using the following code to read from and write to the registry. The writing works fine but reading always fails. Can anyone suggest what is going wrong? Imports Microsoft.Win32 Public...
11
by: Larry Bird | last post by:
I'm trying to read a registry key using VB.Net. I have posted the code below that I'm using: Dim DBConnect As RegistryKey = Registry.CurrentUser.OpenSubKey _ ("Software\VB and VBA Program...
5
by: Scott M. Lyon | last post by:
I've just discovered a bug in some code I wrote a little while ago, and I need you guys' help to fix it. My program imports data from a standard Excel Spreadsheet (just with specific column...
5
by: UJ | last post by:
I have a system that has five programs that all communicate with each other via Message Queues. Works well. One program is a watchdog that will make sure the others are up and going. Currently I...
3
by: Aussie Rules | last post by:
Hi, I want to store some data in the registry, however I have not been able to do this, and think my logic maybe flawed. Firstly I try to open the registry and read in any existing values....
0
by: tmsprowl | last post by:
Greetings! I was wondering if someone could help me with a problem I'm having. My department is just one of many within my organization. My organization has control over the network domain,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.