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