苏飞论坛

标题: 我写了个注册表类为什么在 Registry.ClassesRoot上报错 [打印本页]

作者: 头文字C    时间: 2013-12-14 21:45
标题: 我写了个注册表类为什么在 Registry.ClassesRoot上报错
我用的是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");
            }
            
        }
    }
}









欢迎光临 苏飞论坛 (http://www.sufeinet.com/) Powered by Discuz! X3.4