"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uT**************@TK2MSFTNGP03.phx.gbl...
"Lalit" <xy*@xyz.comwrote in message
news:ux**************@TK2MSFTNGP05.phx.gbl...
>Thanks for the reply, I got a code from code project to read registry
values
using WMI.
I stunk on one more problem now. I was able to get version number of com
dll but I want to get version of .Net dll and for .Net dlls it return
NULL
in Version property.
Any Idea?
Lalit
And here is another sample that ilustrates how you can read an expanded
value from a remote systems registry. The sample reads the expanded %windir%
value from the system's environment, this value expands to the path where
the current running OS is stored.
static void GetExpandedWindir()
{
ConnectionOptions co = new ConnectionOptions();;
co.Username = "administrator";
co.Password = "xxxxx";
string remMachine = "ssssss";
ManagementPath p = new ManagementPath(@"StdRegProv");
ManagementScope scope = new ManagementScope(@"\\" + remMachine +
@"\root\default", co);
using (ManagementClass regClass = new ManagementClass(scope, p, null))
{
ManagementBaseObject inputArgs =
regClass.GetMethodParameters("GetExpandedStringVal ue");
inputArgs["sSubKeyName"] = @"SYSTEM\CurrentControlSet\Control\Session
Manager\Environment";
inputArgs["sValueName"] = "windir";
ManagementBaseObject outParams =
regClass.InvokeMethod("GetExpandedStringValue", inputArgs, null);
uint ret = (uint)(outParams.Properties["ReturnValue"].Value);
if(ret == 0)
Console.WriteLine("Success: {0}",
(string)(outParams.Properties["sValue"].Value));
else Console.WriteLine("Failed with error code: {0}", ret);
}
}
Willy.