zoukankan      html  css  js  c++  java
  • C#.net 创建网页快捷方式

    如果您的站点设置了favicon.ico,那么正常情况下该站点创建出来的快捷链接图标将是favicon.ico,

    如图:

    using System.Runtime.InteropServices;
    using IWshRuntimeLibrary;

    // 添加引用:COM下Windows Script Host Object Model

            public bool Createlnk()
            {
                string app = "http://hi.baidu.com/cqjfb";
                string location1 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites) + "\\邪恶的小嘴的空间.url";
                string location2 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory) + "\\邪恶的小嘴的空间.url";
                string location3 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Programs) + "\\邪恶的小嘴的空间.url";

                try
                {
                    // Create a Windows Script Host Shell class
                    IWshShell_Class shell = new IWshShell_ClassClass();
                    // Define the shortcut file
                    IWshURLShortcut shortcut = shell.CreateShortcut(location1) as IWshURLShortcut;
                    shortcut.TargetPath = app;
                    // Save it
                    shortcut.Save();

                    shortcut = shell.CreateShortcut(location2) as IWshURLShortcut;
                    shortcut.TargetPath = app;
                    // Save it
                    shortcut.Save();

                    shortcut = shell.CreateShortcut(location3) as IWshURLShortcut;
                    shortcut.TargetPath = app;
                    // Save it
                    shortcut.Save();

                    return true;
                }

                catch (COMException ex)
                {
                    Console.WriteLine(ex.Message);
                    return false;
                }
            }

    如果要自定义快捷链接的图标,请使用
    http://hi.baidu.com/cqjfb/blog/item/6a009653672683828e543066.html
    中的方式创建快捷链接,可以实现自定义图标。:

  • 相关阅读:
    Programming Collecive Intelligence 笔记 Making Recommendations
    Managing Gigabytes文本压缩
    Hadoop The Definitive Guide 笔记二
    POS Tagging with NLTK
    MG查询
    MG索引构造
    对SharePoint 2010的job failover的一些比较深入的说明
    SharePoint 2010中Search功能的数据库连接字符串在哪里?
    记解决一个数据库删不掉的问题
    SharePoint升级失败?
  • 原文地址:https://www.cnblogs.com/lzjsky/p/2626670.html
Copyright © 2011-2022 走看看