• Winform 创建桌面快捷方式并开机启动


    编辑器加载. 快捷方式实质上是一个扩展名为 .LNK 的文件 方法如下: 首先要添加引用 (如图) 就是那个Windows Script Host Object Model的类库.... 然后在程序中引入命名空间

    usingIWshRuntimeLibrary; 有一些文件操作,所有要引入

    usingSystem.IO; 关键方法如下:

    /// ///创建桌面快捷方式并开机启动的方法 /// privatevoidShortcutAndStartup() { //获取当前系统用户启动目录 stringstartupPath=Environment.GetFolderPath(Environment.SpecialFolder.Startup); //获取当前系统用户桌面目录 stringdesktopPath=Environment.GetFolderPath(Environment.SpecialFolder.Desktop); FileInfofileStartup=newFileInfo(startupPath+"//亿掌通.lnk"); FileInfofileDesktop=newFileInfo(desktopPath+"//亿掌通.lnk"); if(!fileDesktop.Exists) { WshShellshell=newWshShell(); IWshShortcutshortcut=(IWshShortcut)shell.CreateShortcut( Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)+ "//"+"亿掌通.lnk" ); shortcut.TargetPath=Application.StartupPath+"//"+"Upgrade.exe";//启动更新程序★ shortcut.WorkingDirectory=System.Environment.CurrentDirectory; shortcut.WindowStyle=1; shortcut.Description="亿掌通"; shortcut.IconLocation=Application.ExecutablePath; shortcut.Save(); } if(!fileStartup.Exists) { //获取可执行文件快捷方式的全部路径 stringexeDir=desktopPath+"//亿掌通.lnk"; //把程序快捷方式复制到启动目录 System.IO.File.Copy(exeDir,startupPath+"//亿掌通.lnk",true); } } 中...

  • 相关阅读:
    虚拟化资料
    Windows线程+进程通信
    Linux进程+进程间通信IPC
    COM/DOM/COM+
    C# 2.0新特性与C# 3.5新特性[转]
    [CruiseControl]配置文件config.xml
    C#的Delegate和Event
    [BuildRelease Management]Visual Build
    软件培训机构
    可以自动输入密码的Runas
  • 原文地址:https://www.cnblogs.com/ayforver/p/2540271.html
Copyright © 2020-2023  润新知