• C# “快捷方式” 实现程序开机启动


    添加引用:

    COM : Windows Script Host Object Model

    Name: Interop.IWshRuntimeLibrary

    添加命名空间:

    using IWshRuntimeLibrary;

            public static int StartUpByShortCut(string targetPath, string name, string desc)
            {
                try
                {
                    WshShell shell = new WshShell();
    
                    WshShortcut st = shell.CreateShortcut(
                        Environment.GetFolderPath(Environment.SpecialFolder.Startup) +
                        System.IO.Path.DirectorySeparatorChar + name + ".lnk");
    
                    st.Description = desc;
                    st.IconLocation = targetPath + ",0";
                    st.TargetPath = targetPath;
                    st.WindowStyle = 1;
                    st.WorkingDirectory = System.IO.Directory.GetParent(targetPath).FullName;
                    st.Save();
                    return 1;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine(ex.Message);
                    return 0;
                }
            }
  • 相关阅读:
    gulp serve 报错 gulp.ps1
    Jquery选择器
    Jquery动画
    js 雪花
    h5 偏门小方法
    HTML基础
    HTML5介绍
    JavaScript String 简易版烟花
    JavaScript Select和Option列表元素上下左右移动
    H5缓存-Manifest
  • 原文地址:https://www.cnblogs.com/wjshan0808/p/4808971.html
Copyright © 2020-2023  润新知