zoukankan      html  css  js  c++  java
  • 使用 COM 类库创建链接桌面快捷方式

    用到的 COM 类库:

    Windows Script Host Object Model --> Interop.IWshRuntimeLibrary.dll

    示例代码:

    private static void _BuildLink()
    {
        var startUrl = "http://localhost:8888";
        var location = Environment.GetFolderPath( Environment.SpecialFolder.DesktopDirectory ) + "\\谷歌链接.url";
    
        try
        {
            IWshShell_Class shell = new IWshShell_ClassClass();
            IWshURLShortcut shortcut = shell.CreateShortcut( location ) as IWshURLShortcut;
    
            if (shortcut == null) return;
            
            shortcut.TargetPath = startUrl;
            shortcut.Save();
    
    
        }
        catch(COMException ex)
        {
            Console.WriteLine(ex.Message);
        }
    }

    注意:

    如果直接复制代码并不能运行,会看到如下错误:

    无法嵌入互操作类型“IWshRuntimeLibrary.IWshShell_ClassClass”。请改用适用的接口。 

    此时需要在此项目的“引用”中找到“IWshRuntimeLibrary”并右键选择“属性”,将“嵌入互操作类型”设置为“False”。

  • 相关阅读:
    按钮水波纹效果
    点击水波纹效果
    实现图片上传预览效果
    css 实现鼠标滑过流光效果
    插件地址参考
    移动前端经验
    移动端开发需要加的meta
    25款css动画库
    oracle 中的next_day函数
    Oracle replace函数
  • 原文地址:https://www.cnblogs.com/jroger/p/4181776.html
Copyright © 2011-2022 走看看