我用的是WPF,为什么在RegistryKey reg = Registry.ClassesRoot;上面报错
是不是还要引用什么文件。提示:错误 2 “GifShow.Registry”并不包含“ClassesRoot”的定义
[C#] 纯文本查看 复制代码 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
namespace GifShow
{
class Registry
{
private static void myMethod_CreateSuffixName(string strHouZhuiMing,
string strName,
string strShuoMingYu,
string strIconPath,
string strEXEpath)
{
if (IntPtr.Size == 4)
{
RegistryKey reg = Registry.ClassesRoot;
reg.CreateSubKey(strHouZhuiMing).SetValue("", strName);
reg.CreateSubKey(strName).SetValue("", strShuoMingYu);
reg.CreateSubKey(strName + @"\DefaultIcon").SetValue("", strIconPath);
reg.CreateSubKey(strName + @"\shell\open\command").SetValue("", strEXEpath + " %1");
reg.CreateSubKey(strName + @"\shell\edit\command").SetValue
("", @"C:\Program Files\Windows NT\Accessories\WORDPAD.EXE" + " %1");
}
else if (IntPtr.Size == 8)
{
RegistryKey reg = Registry.ClassesRoot;
reg.CreateSubKey(strHouZhuiMing).SetValue("", strName);
reg.CreateSubKey(strName).SetValue("", strShuoMingYu);
reg.CreateSubKey(strName + @"\DefaultIcon").SetValue("", strIconPath);
reg.CreateSubKey(strName + @"\shell\open\command").SetValue("", strEXEpath + " %1");
reg.CreateSubKey(strName + @"\shell\edit\command").SetValue
("", @"C:\Program Files (x86)\Windows NT\Accessories\WORDPAD.EXE" + " %1");
}
}
}
}
|