RT

解决方案 »

  1.   

    将 FileFullName 换成一个URL就可以.
    '
    '建立文件快捷方式.
    '函数:CreateLink
    '参数:
    '       FileFullName       对应的文件全称.
    '       IconLocation       图标路径
    '       LinkFolder         快捷方式的系统位置(枚举).
    '       UserLinkFolder     用户自定义快捷方式位置.
    '       LinkName           快捷方式名称.
    '       WorkingDirectory   工作目录.
    '       Hotkey             热键.
    '       WindowStyle        运行方式(枚举).
    '返回值:无.
    '例子:
    '注:如果 UserLinkFolder 不为空.则 LinkFolder 无效,即:用户自定义位置优先.
    Public Function CreateLink(FileFullName As String, _
                               Optional IconLocation As String = "", _
                               Optional LinkFolder As SmSysFolder = SmDeskTop, _
                               Optional UserLinkFolder As String = "", _
                               Optional LinkName As String = "", _
                               Optional WorkingDirectory As String = "", _
                               Optional Hotkey As String = "", _
                               Optional WindowStyle As SmWinStyle = SmNormalFocus)    Dim GetName As New SmFileCls
        Dim WSH_shell As New IWshRuntimeLibrary.IWshShortcut_Class 'IWshRuntimeLibrary.WshShell
        Dim UrlLink As New IWshRuntimeLibrary.IWshShortcut_Class 'IWshRuntimeLibrary.WshShortcut
        Dim LinkPath As String
        Dim CreateDir As New SmFileCls    On Error Resume Next
        
        If Len(Trim$(WorkingDirectory)) = 0 Then
           WorkingDirectory = GetName.FilePath(FileFullName)
        End If
        If Len(Trim$(LinkName)) = 0 Then
           LinkName = GetName.Filename(FileFullName)
        End If
        If UCase$(Right$(LinkName, 3)) <> "LNK" Then
           LinkName = LinkName & ".LNK"
        End If
        '/-----------------------------------------
        If Len(Trim$(UserLinkFolder)) > 0 Then
           LinkPath = UserLinkFolder
        ElseIf IsNumeric(LinkFolder) Then
           LinkPath = GetFolder(LinkFolder)
        Else
           Exit Function
        End If
        '/------------------------------------------
        If Right$(LinkPath, 1) <> "\" Then LinkPath = LinkPath & "\"
        If Len(Dir$(LinkPath, vbDirectory + vbHidden + vbReadOnly + vbSystem + vbAlias + vbNormal)) = 0 Then
           If Not CreateDir.CreateDir(LinkPath) Then
              Exit Function
           End If
        End If
        LinkPath = LinkPath & LinkName
        Set UrlLink = WSH_shell.CreateShortcut(LinkPath)
        With UrlLink
             .TargetPath = FileFullName
             .IconLocation = IconLocation
             .Hotkey = Hotkey
             .WorkingDirectory = WorkingDirectory   '起始位置
             .WindowStyle = WindowStyle             '开始样式
        End With
        UrlLink.Save '保存快捷方式
        Set WSH_shell = Nothing
        Set UrlLink = Nothing
        Set GetName = Nothing
        Set CreateDir = Nothing
    End Function
      

  2.   

    Option Explicit
    '需要引用 Windows Script Host Object Model
    Private Sub Command1_Click()
        Dim mWshShell As New IWshRuntimeLibrary.wshshell
        Dim mWshURLShortcut As IWshRuntimeLibrary.WshURLShortcut
        Set mWshURLShortcut = mWshShell.CreateShortcut("d:\weburl.url")
        mWshURLShortcut.TargetPath = "http://www.csdn.net/"
        mWshURLShortcut.Save
        Set mWshURLShortcut = Nothing
        Set mWshShell = Nothing
    End Sub
      

  3.   

    或者你直接根据文件格式写也可以,它的格式类似下面(其实就是个ini文件):
    [InternetShortcut]
    URL=http://www.csdn.net/
    Modified=4048DA507D0EC40102
    或者:
    [DEFAULT]
    BASEURL=http://www.j3j4.com/
    [InternetShortcut]
    URL=http://www.j3j4.com/
    Modified=F0083086CE02C40143
      

  4.   

    参考:
    http://www.china-askpro.com/msg17/qa93.shtml