将网址快捷方式图标写入桌面
问题描述:
使用我的笔记本电脑上的VB Web Developer可以正常工作,但我的网站上出现问题.
按下按钮1会显示错误(无法找到目录桌面")
It works Fine using VB Web Developer om my laptop but having Problems on My Web Site.
Pressing Button 1 brings up the Error ("Cannot Find The Directory DESKTOP")
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
WriteShortcut("http://www.mylighthousecove-fl.org/", IO.Path.Combine _
(My.Computer.FileSystem.SpecialDirectories.Desktop, "LHC Blog.url"))
Catch
''''''''''''''Note '''''''''''Errors out here
End Try
End Sub
Sub WriteShortcut(ByVal url As String, ByVal filename As String)
Try
My.Computer.FileSystem.WriteAllText(filename,String.Format _
("InternetShortcut]{0}URL={1}{0}",vbCrLf, url), False)
Catch
End Try
End Sub
答
放弃下载网址图标并发布用户可以自己做的方法.
如何创建此站点的快捷方式
[在您的计算机上]
1.右键单击{START}按钮
2.单击{浏览}以打开Windows资源管理器
3.向上滚动并选择文件夹{桌面}
4.单击[文件],然后选择{新建}
5.选择{快捷方式]
6.复制以下内容并将其粘贴到TextBox"http://www.xxxxx.org"
7.单击{下一步},然后在名称"文本框中键入以下名称"
Gave up on Downloading a url Icon and Posted a method users can do themselves.
How To Create a Shortcut To This Site
[On Your Computer]
1. Right Click on the {START} Button
2. Click on {Explore} to open the Windows Explorer
3. Scroll up and select the folder{Desktop}
4. Click on [File} and select {New}
5. Select {Shortcut]
6. Copy The following and paste it into the TextBox "http://www.xxxxx.org"
7. Click {Next} and in the Name TextBox type The Following "NAME"
这对我有用,也许对您有用:
私有子项CreateShortCut(ByVal发送者为System.Object,ByVal e为System.EventArgs)
昏暗的外壳作为新的WshShell
Dim ShortcutName As String =快捷方式名称"
Dim DesktopDir As String = _
CType(Shell.SpecialFolders.Item("AllUsersDesktop"),字符串)
作为IWshRuntimeLibrary.IWshShortcut的Dim shortCut
''快捷方式文件的扩展名为.lnk
shortCut = CType(Shell.CreateShortcut(DesktopDir&"\"& _
快捷方式名称& ".lnk"),_
IWshRuntimeLibrary.IWshShortcut)
使用shortCut''设置快捷方式属性
.TargetPath ="http://"&服务器字符串和:8080/more/main.do"
.WindowStyle = 1
.Description =快捷方式说明"
.WorkingDirectory = DesktopDir
''使用反射从应用程序中获取第一个图标
.IconLocation =我想用于快捷方式的特殊图标的路径"& ,0"
.Save()''保存快捷方式文件
结尾为
Me.Close()
结束Sub
This worked for me, perhaps it will work for you:
Private Sub CreateShortCut(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Shell As New WshShell
Dim ShortcutName As String = "Name of shortcurt"
Dim DesktopDir As String = _
CType(Shell.SpecialFolders.Item("AllUsersDesktop"), String)
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
'' short cut files have a .lnk extension
shortCut = CType(Shell.CreateShortcut(DesktopDir & "\" & _
ShortcutName & ".lnk"), _
IWshRuntimeLibrary.IWshShortcut)
With shortCut '' set the shortcut properties
.TargetPath = "http://" & ServerString & ":8080/more/main.do"
.WindowStyle = 1
.Description = "Description of Shortcut"
.WorkingDirectory = DesktopDir
''use reflection to get the first Icon from the app
.IconLocation = "Path of special icon I wanted to use for shortcut" & ", 0"
.Save() '' save the shortcut file
End With
Me.Close()
End Sub