Source Code Untuk Membuat Shortcut Di Destkop Dengan VB 6
Hallo Sobat CT beberapa dari teman saya bertanya kepada saya bagaimana cara membuat shortcut program yang telah kita buat di visual basic?
Untuk itu saya akan memberikan contoh source code nya untuk membuat shortcut pada destkop ...
Cara pembuatannya pun cukup sederhana :
1. Buat Form Baru
2. Buat 2 buah command button, rename Command1 menjadi fungsi dan Command2 caption rename jadi Create Shortcut
3. Buat 1 Listbox
4. Buat 1 Textbox
Berikut ini codingnya
Dim WShell As Object
Dim NameExe As String
Private Sub Command1_Click()
With CommonDialog1
.FileName = "*.exe"
.ShowOpen
If .FileName = "" Then Exit Sub
If Dir(.FileName) = "" Then Exit Sub
Text1 = .FileName
NameExe = Left(.FileTitle, Len(.FileTitle) - 4)
End With
End Sub
Private Sub Command2_Click()
Dim wShortcut As Object
Dim i As Integer
If Dir(Text1) = "" Or Trim(NameExe) = "" Or List1.ListCount = -1 Then
MsgBox "Error"
Else
For i = 0 To List1.ListCount - 1
Set wShortcut = WShell.CreateShortcut(List1.List(i) & "\" & NameExe & ".lnk")
wShortcut.TargetPath = Text1
wShortcut.Save
Next
MsgBox "Shortcut telah dibuat..", , "Membuat Shortcut"
End If
End Sub
Private Sub Form_Load()
Dim temp
Set WShell = CreateObject("WScript.Shell")
List1.Clear
For Each temp In WShell.SpecialFolders
If LCase(Right(temp, 17)) = "all users\desktop" Then List1.AddItem temp
Next
End Sub
Semoga bermanfaat jika ada yang perlu ditanyakan silahkan berkomentar ..
Untuk itu saya akan memberikan contoh source code nya untuk membuat shortcut pada destkop ...
Cara pembuatannya pun cukup sederhana :
1. Buat Form Baru
2. Buat 2 buah command button, rename Command1 menjadi fungsi dan Command2 caption rename jadi Create Shortcut
3. Buat 1 Listbox
4. Buat 1 Textbox
Dim WShell As Object
Dim NameExe As String
Private Sub Command1_Click()
With CommonDialog1
.FileName = "*.exe"
.ShowOpen
If .FileName = "" Then Exit Sub
If Dir(.FileName) = "" Then Exit Sub
Text1 = .FileName
NameExe = Left(.FileTitle, Len(.FileTitle) - 4)
End With
End Sub
Private Sub Command2_Click()
Dim wShortcut As Object
Dim i As Integer
If Dir(Text1) = "" Or Trim(NameExe) = "" Or List1.ListCount = -1 Then
MsgBox "Error"
Else
For i = 0 To List1.ListCount - 1
Set wShortcut = WShell.CreateShortcut(List1.List(i) & "\" & NameExe & ".lnk")
wShortcut.TargetPath = Text1
wShortcut.Save
Next
MsgBox "Shortcut telah dibuat..", , "Membuat Shortcut"
End If
End Sub
Private Sub Form_Load()
Dim temp
Set WShell = CreateObject("WScript.Shell")
List1.Clear
For Each temp In WShell.SpecialFolders
If LCase(Right(temp, 17)) = "all users\desktop" Then List1.AddItem temp
Next
End Sub
Semoga bermanfaat jika ada yang perlu ditanyakan silahkan berkomentar ..
0 comments:
Post a Comment