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
    中的方式创建快捷链接,可以实现自定义图标。:

  • 相关阅读:
    最小生成树问题-prim算法求解
    排序算法7---快速排序算法
    IOS工作笔记(九)
    NSUserDefaults的一些用法
    UIActionSheet的简单使用
    如何处理过多使用懒加载的问题?
    prefix.pch文件的一些简单使用
    IOS工作笔记(八)
    登录时本地保存账号密码及关闭ARC的方法
    IOS页面跳转的方法
  • 原文地址:https://www.cnblogs.com/lzjsky/p/2626670.html
Copyright © 2011-2022 走看看