Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共13 条记录, 每页显示 10 条, 页签: [1] [2]
[浏览完整版]

标题:发快捷方式到桌面

1楼
xxfoxtable 发表于: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楼
有点蓝 发表于: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
3楼
xxfoxtable 发表于: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楼
有点蓝 发表于:2024/1/29 22:06:00
这些代码要在Foxtable里使用
5楼
xxfoxtable 发表于:2024/1/29 22:08:00
由于foxtable经常闪退,所以我想用vb.net做一个,能帮忙吗?
6楼
xxfoxtable 发表于: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楼
有点蓝 发表于: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
8楼
xxfoxtable 发表于:2024/1/29 22:28:00
没有基础,难度还是很大呀,看不懂
9楼
xxfoxtable 发表于: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编辑过]
10楼
xxfoxtable 发表于:2024/1/29 22:51:00
 Dim fileDesktop As FileInfo = New FileInfo(desktopPath + "\\" & appName & ".lnk")
显示不支持的路径格式
共13 条记录, 每页显示 10 条, 页签: [1] [2]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03027 s, 2 queries.