Today, I am in a hurry to change the usage of daily supplements
1) using Microsoft. Win32; this is a common method and has many details. This is not the focus.
Code
Public static string getregvalue (string strregpath, string strregkeyname)
{
String STR;
Try
{
Registrykey rk = registry. localmachine. opensubkey (strregpath, true );
If (rk! = NULL)
{
STR = rk. getvalue (strregkeyname). tostring ();
}
Else
{
STR = "unable find the specified registry key or value ";
}
}
Catch (exception E)
{
STR = "unable find the specified registry key or value, Vista may need close UAC! "+ E;
}
Return STR;
}
2) Reference wshom. ocx: This provides a way to reuse various scripts. You can consider this when the methods provided by the framework are not good. For the time being, I just thought it was useful, but I still don't know how to use it.
VaR Reg = new activexobject ("wscript. Shell"); // locate the OCX reference of wscript. Shell
Reg. Read ();
Code
Public static string getregvalue (string strregpath)
{
String strregvalue;
Try
{
Iwshruntimelibrary. wshshell Ws = new iwshruntimelibrary. wshshell ();
Strregvalue = ws. regread (strregpath). tostring ();
}
Catch (exception E)
{
Strregvalue = "unable find the specified registry key or value, Vista may need close UAC! "+ E;
}
Return strregvalue;
}