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

  • 相关阅读:
    了解xss
    kail Windows10 远程连接解决办法
    信息收集二级域名或ip收集
    mpvue引用Echarts不渲染问题
    IIS状态码
    apicloud的tapmode用法
    JavaScript交换两个变量值的七种解决方案
    IIS express 服务的开启, 支持多个iis express
    asp.net解决跨域访问问题
    Flex 布局
  • 原文地址:https://www.cnblogs.com/lzjsky/p/2626670.html
Copyright © 2011-2022 走看看