Windows 98に搭載されたWSH(Windows Scripting Host)の機能を呼び出してショートカットを作成します。
'--------------------------------------------------------
'
'--------------------------------------------------------
Private SubCommand1_Click()
DimstrExePathAs String
DimstrFolderAs String
DimobjWSHShellAs Object
DimobjShortcutAs Object
IfRight(App.Path, 1) = "\"Then
strExePath = App.Path & App.EXEName
Else
strExePath = App.Path & "\" & App.EXEName
End If
SetobjWSHShell = CreateObject("WScript.Shell")
' ショートカットを登録したいフォルダのパス名を検索します。
strFolder = objWSHShell.SpecialFolders("Desktop")'デスクトップの場合
'strFolder = objWSHShell.SpecialFolders("Startup")'スタートアップの場合
SetobjShortcut = objWSHShell.CreateShortcut(strFolder & "\テスト.lnk")
WithobjShortcut
.TargetPath = objWSHShell.ExpandEnvironmentStrings(strExePath)'リンク先
'.WorkingDirectory = objWSHShell.ExpandEnvironmentStrings("C:")'作業フォルダ
'.IconLocation = objWSHShell.ExpandEnvironmentStrings("C:\Windows\notepad.exe, 0")'アイコン,アイコン番号
.WindowStyle = 4'実行時の大きさ 3:最大化 4:通常 7:最小化
.Save
End With
End Sub
DownLoad vbtips113.lzh 6KB (VB6.0)