zoukankan      html  css  js  c++  java
  • 在我的电脑里面创建图标

    public static void CreateShortCutByMyComputer(Guid id, string name, string description, string path, string icon)
            {
                RegistryKey root = Registry.ClassesRoot;
                RegistryKey clsid = root.OpenSubKey("CLSID", true);
                RegistryKey key = CreateOrGetSubKey(clsid, string.Format("{{{0}}}", id));
                key.SetValue("", name);
                key.SetValue("InfoTip", description);
                key.SetValue("LocalizedString", name);
                key.SetValue("System.ItemAuthors", description);
                key.SetValue("TileInfo", "prop:System.ItemAuthors");
    
                RegistryKey defaultIcon = CreateOrGetSubKey(key, "DefaultIcon");
                defaultIcon.SetValue("", icon);
                RegistryKey inProcServer32 = CreateOrGetSubKey(key, "InProcServer32");
                inProcServer32.SetValue("", @"%SystemRoot%system32shell32.dll");
                inProcServer32.SetValue("ThreadingModel", "Apartment");
                RegistryKey shell = CreateOrGetSubKey(key, "Shell");
                RegistryKey open = CreateOrGetSubKey(shell, "Open");
                RegistryKey command = CreateOrGetSubKey(open, "Command");
                command.SetValue("", path);
                RegistryKey shellFolder = CreateOrGetSubKey(key, "ShellFolder");
                shellFolder.SetValue("Attributes", new byte[] { 00, 00, 00, 00 }, RegistryValueKind.Binary);
    
    
                RegistryKey hcu = Registry.CurrentUser;
                RegistryKey ns = hcu.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Explorer").OpenSubKey("MyComputer").OpenSubKey("NameSpace", true);
                RegistryKey v = CreateOrGetSubKey(ns, string.Format("{{{0}}}", id));
                v.SetValue("", name);
            }
    
            public static void RemoveShortCutByMyComputer(Guid id)
            {
                RegistryKey root = Registry.ClassesRoot;
                RegistryKey clsid = root.OpenSubKey("CLSID", true);
                clsid.DeleteSubKeyTree(string.Format("{{{0}}}", id), true);
    
                RegistryKey hcu = Registry.CurrentUser;
                RegistryKey ns = hcu.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Explorer").OpenSubKey("MyComputer").OpenSubKey("NameSpace", true);
                ns.DeleteSubKey(string.Format("{{{0}}}", id), true);
            }
    

      

  • 相关阅读:
    2013-9-29 通信原理学习笔记
    《大数据时代》阅读笔记
    《人人都是产品经理》阅读笔记一
    2013-8-13 信道接入技术研究学习
    2013-8-6 ubuntu基本操作
    2013-7-30 802.1X企业级加密
    2013-7-29 杂记
    2013-7-28 802.11n帧聚合
    2013-7-27 802.1X学习
    vue+node+mongoDB前后端分离个人博客(入门向)
  • 原文地址:https://www.cnblogs.com/xsi640/p/3548312.html
Copyright © 2011-2022 走看看