次のコードは、[スタート]メニューの実行中のアプリケーションへのショートカットを作成します(あなたはこれを行うために必要なアクセス許可が必要になります):
を第一に、参照の追加] - > [COM]タブ - > [Windowsスクリプトホストオブジェクトモデルを
Imports IWshRuntimeLibrary
Public Function CreateShortcut(ByVal fileName As String, ByVal description As String) As Boolean
Try
Dim shell As New WshShell
'the following is the root of the Start Menu so if you want it in a folder you need to create it
Dim ShortcutDir As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu)
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
' short cut files have a .lnk extension
shortCut = CType(shell.CreateShortcut(ShortcutDir & "\" & fileName & ".lnk"), IWshRuntimeLibrary.IWshShortcut)
' set the shortcut properties
With shortCut
.TargetPath = System.Reflection.Assembly.GetExecutingAssembly.Location()
.WindowStyle = 1
.Description = description
.WorkingDirectory = ShortcutDir
' the next line gets the first Icon from the executing program
.IconLocation = System.Reflection.Assembly.GetExecutingAssembly.Location() & ", 0"
'.Arguments = ""
.Save()
End With
Return True
Catch ex As System.Exception
' add your error handling here
Return False
End Try
End Function
すでに回答がありますように聞こえます。アプリケーションのショートカットを作成します。完了しました。 – JohnFx