0

タスクが .url または .lnk (ショートカット) プロパティを変更するコードがありますが、何もしていないようです。

Imports System.IO
Imports Shell32

Module Module1
    Sub Main()
        'References Microsoft Shell Controls and Automation.
        'http://msdn.microsoft.com/en-us/library/bb776890%28v=VS.85%29.aspx
    End Sub
    Public Sub Change_Shortcut()

    Dim shell As Shell32.Shell
    Dim folder As Shell32.Folder
    Dim folderItem As Shell32.FolderItem
    Dim shortcut As Shell32.ShellLinkObject

    shell = New Shell32.Shell

    folder = shell.NameSpace("C:\Users\GrzegoP\Desktop\xxx") 'Shortcut path
    If Not folder Is Nothing Then
        folderItem = folder.ParseName("o2.url") 'Shortcut name
        If Not folderItem Is Nothing Then
            shortcut = folderItem.GetLink
            If Not shortcut Is Nothing Then
                shortcut.Path = "www.o2.ie" 'new shortcut address
                shortcut.Save()
                MsgBox("Shortcut changed")
            Else
                MsgBox("Shortcut link within file not found")
            End If
        Else
            MsgBox("Shortcut file not found")
        End If
    Else
        MsgBox("Desktop folder not found")
    End If

End Sub

End Module

どこが間違っているのか、誰かアドバイスをもらえますか?

ありがとう。

4

3 に答える 3

1

この方法では URL ショートカットを作成できないことに注意してください。

http://msdn.microsoft.com/en-us/library/windows/desktop/bb776891%28v=vs.85%29.aspx

代わりに、デスクトップにファイルを作成し、xxx.urlその中に次のテキスト行を書き込む必要があります。

[InternetShortcut]
URL=http://www.o2.ie

Windows はそれを Web サイトのショートカットに変換します。

于 2013-08-26T16:22:26.007 に答える
0

私の問題に対する簡単な解決策...

行で:shortcut.Path = "www.o2.ie"

http://住所の前に入れるのを忘れていました。

于 2013-08-26T16:24:19.160 に答える