以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 发快捷方式到桌面 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=190302) |
-- 作者: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编辑过]
|
-- 作者:有点蓝 -- 发布时间: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 -- 发布时间: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显示波浪线
|
-- 作者:有点蓝 -- 发布时间:2024/1/29 22:06:00 -- 这些代码要在Foxtable里使用 |
-- 作者:xxfoxtable -- 发布时间:2024/1/29 22:08:00 -- 由于foxtable经常闪退,所以我想用vb.net做一个,能帮忙吗? |
-- 作者: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("成功") 能帮忙改下吗?解决总闪退的难题,这个可执行文件和保存可执行文件目录处在同一级目录下,先解决这个问题,再研究改文件夹名称 就想执行一次修复,就改publish目录名,重新发快捷方式到桌面
[此贴子已经被作者于2024/1/29 22:18:45编辑过]
|
-- 作者:有点蓝 -- 发布时间: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 -- 发布时间:2024/1/29 22:28:00 -- 没有基础,难度还是很大呀,看不懂 |
-- 作者: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 这样引用还是不行 [此贴子已经被作者于2024/1/29 22:46:15编辑过]
|
-- 作者:xxfoxtable -- 发布时间:2024/1/29 22:51:00 -- Dim fileDesktop As FileInfo = New FileInfo(desktopPath + "\\\\" & appName & ".lnk") 显示不支持的路径格式
|