c#检测注册表,请高手指点~~
来源:百度知道 编辑:UC知道 时间:2024/06/17 12:58:20
求救~~
本人之前没做过关于注册表的程序,请高手指点一下~~~急啊!!!!!!
Microsoft.Win32.RegistryKey pregkey;
pregkey = Registry.LocalMachine.OpenSubKey("SOFTWARE", true).OpenSubKey("CardScan", true);
if (null != pregkey)
{
if (null == pregkey.GetValue(keys))
{
pregkey.SetValue(keys, "TRUE");
pregkey.Close();
return true;
}
}
using Microsoft.Win32;
代码:
string currentExePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
RegistryKey key = Registry.LocalMachine.OpenSubKey( @"SOFTWARE\CardScan", RegistryKeyPermissionCheck.ReadWriteSubTree );
if ( key == null ) key = Registry.LocalMachine.CreateSubKey( @"SOFTWARE\CardScan", RegistryKeyPermissionCheck.ReadWriteSubTree );
string v = key.GetValue( "ScanExe", string.Empty ).ToString();
if ( string.IsNullOrEmpty( v ) || v != currentExePath )