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);
            }
    

      

  • 相关阅读:
    EXT--columnWidth
    EXT经验--查询items的xtype
    修改VS解决方案及工程名,解决如何打开高/版本VS项目
    jQuery Ajax 全解析(转)
    MS SqlSever一千万条以上记录分页数据库优化经验总结【索引优化 + 代码优化】[转]
    .net框架版本说明
    [Ajax] 使用Ajax异步上传图片文件(非Form表单提交)
    CodeSmith 7.01破解下载
    jQuery插件之Cookie
    Oracle笔记 目录索引
  • 原文地址:https://www.cnblogs.com/xsi640/p/3548312.html
Copyright © 2011-2022 走看看