Foxtable(狐表)用户栏目专家坐堂 → 发快捷方式到桌面


  共有700人关注过本帖树形打印复制链接

主题:发快捷方式到桌面

帅哥哟,离线,有人找我吗?
xxfoxtable
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1696 积分:15861 威望:0 精华:0 注册:2017/6/1 23:12:00
发快捷方式到桌面  发帖心情 Post By:2024/1/29 21:21:00 [只看该作者]

        '发快捷方式到桌面
        Dim appName = My.Application.Info.CompanyName & My.Application.Info.ProductName
        Dim desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
        Dim fileDesktop As FileInfo = New FileInfo(desktopPath + "\\" & appName & ".lnk")
        If Not fileDesktop.Exists Then
            Dim shell = New WshShell()
            Dim shortcut = CType(shell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\" & appName & ".lnk"), IWshShortcut)
            shortcut.WorkingDirectory = System.Environment.CurrentDirectory
            shortcut.WindowStyle = 1
            shortcut.Description = appName
            shortcut.IconLocation = Application.ExecutablePath
            shortcut.TargetPath = Application.StartupPath + "\\" + My.Application.Info.AssemblyName & ".exe"
            shortcut.Save()
        End If

WshShell()与 IWshShortcut划波浪线了,是什么原因呢?百度的代码,不知道怎么写,请老师帮助写一下,谢 谢 ?
[此贴子已经被作者于2024/1/29 21:27:30编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106603 积分:542186 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2024/1/29 21:40:00 [只看该作者]

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=183178&skin=0

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=160730&skin=0

 回到顶部
帅哥哟,离线,有人找我吗?
xxfoxtable
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1696 积分:15861 威望:0 精华:0 注册:2017/6/1 23:12:00
  发帖心情 Post By:2024/1/29 21:59:00 [只看该作者]

        For Each s As String In FileSys.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Desktop))
            If s.Contains(appName) = True Then
                Return
            End If
        Next

vb.net环境里 filesys显示波浪线

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106603 积分:542186 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2024/1/29 22:06:00 [只看该作者]

这些代码要在Foxtable里使用

 回到顶部
帅哥哟,离线,有人找我吗?
xxfoxtable
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1696 积分:15861 威望:0 精华:0 注册:2017/6/1 23:12:00
  发帖心情 Post By:2024/1/29 22:08:00 [只看该作者]

由于foxtable经常闪退,所以我想用vb.net做一个,能帮忙吗?

 回到顶部
帅哥哟,离线,有人找我吗?
xxfoxtable
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1696 积分:15861 威望:0 精华:0 注册:2017/6/1 23:12:00
  发帖心情 Post By:2024/1/29 22:10:00 [只看该作者]

        '读文件路径
        Dim apppath As String = Directory.GetCurrentDirectory()
        Dim file As New System.IO.StreamReader(apppath & "\wjm.txt")   ’保存可执行文件名
        Dim wj As String = file.ReadToEnd()
        file.Close()
        Dim hqlj As New System.IO.StreamReader(apppath & "\lj.txt")     ‘保存可执行文件上一级目录名
        Dim lujingm As String = hqlj.ReadToEnd()
        file.Close()
        '发快捷方式到桌面
        Dim appName = apppath & lujingm & wj & ".lnk"
        'For Each s As String In FileSys.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Desktop))
        '    If s.Contains(appName) = True Then
        '        Return
        '    End If
        'Next
        Dim FilePath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
        Dim wsh As Object = CreateObject("WScript.Shell")
        Dim PathLink As String = appName
        Dim wshs As Object = wsh.CreateShortcut(PathLink)
        wshs.Save()
        MsgBox("成功")

能帮忙改下吗?解决总闪退的难题,这个可执行文件和保存可执行文件目录处在同一级目录下,先解决这个问题,再研究改文件夹名称

图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看
就想执行一次修复,就改publish目录名,重新发快捷方式到桌面

[此贴子已经被作者于2024/1/29 22:18:45编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106603 积分:542186 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2024/1/29 22:18:00 [只看该作者]

如果要使用1楼的用法:https://www.cnblogs.com/Dongmy/p/16903141.html

如果要改FileSys.GetFiles:https://learn.microsoft.com/zh-cn/dotnet/api/system.io.directory.getfiles?view=netframework-4.0

 回到顶部
帅哥哟,离线,有人找我吗?
xxfoxtable
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1696 积分:15861 威望:0 精华:0 注册:2017/6/1 23:12:00
  发帖心情 Post By:2024/1/29 22:28:00 [只看该作者]

没有基础,难度还是很大呀,看不懂

 回到顶部
帅哥哟,离线,有人找我吗?
xxfoxtable
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1696 积分:15861 威望:0 精华:0 注册:2017/6/1 23:12:00
  发帖心情 Post By:2024/1/29 22:45:00 [只看该作者]

Imports System.IO
Using IWshRuntimeLibrary
Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        '读文件路径
        Dim apppath As String = Directory.GetCurrentDirectory()
        Dim file As New System.IO.StreamReader(apppath & "\wjm.txt")
        Dim wj As String = file.ReadToEnd()
        file.Close()
        Dim hqlj As New System.IO.StreamReader(apppath & "\lj.txt")
        Dim lujingm As String = hqlj.ReadToEnd()
        file.Close()
        '发快捷方式到桌面
        Dim appName = apppath & lujingm & wj & ".lnk"
        Dim desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
        Dim fileDesktop As FileInfo = New FileInfo(desktopPath + "\\" & appName & ".lnk")
        If Not fileDesktop.Exists Then
            Dim shell = New WshShell()
            Dim shortcut = CType(shell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\" & appName & ".lnk"), IWshShortcut)
            shortcut.WorkingDirectory = System.Environment.CurrentDirectory
            shortcut.WindowStyle = 1
            shortcut.Description = appName
            shortcut.IconLocation = Application.ExecutablePath
            shortcut.TargetPath = Application.StartupPath + "\\" + My.Application.Info.AssemblyName & ".exe"
            shortcut.Save()
        End If
        MsgBox("成功")
    End Sub
End Class   这样引用还是不行


图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看已经做引用了

[此贴子已经被作者于2024/1/29 22:46:15编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
xxfoxtable
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1696 积分:15861 威望:0 精华:0 注册:2017/6/1 23:12:00
  发帖心情 Post By:2024/1/29 22:51:00 [只看该作者]

 Dim fileDesktop As FileInfo = New FileInfo(desktopPath + "\\" & appName & ".lnk")
显示不支持的路径格式

 回到顶部
总数 13 1 2 下一页