By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,021 Members | 1,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,021 IT Pros & Developers. It's quick & easy.

reading the registry key

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.