forked from lee-soft/ViPad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShellLinkClass2.cls
112 lines (85 loc) · 2.52 KB
/
ShellLinkClass2.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ShellLinkClass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Private m_oWScriptShell As Object
Private m_oShortcut As Object
Private Sub Class_Initialize()
Set m_oWScriptShell = GetGlobalWScriptShellObject()
End Sub
Public Function CreateShortcut(ByVal szPath As String) As Boolean
On Error GoTo Handler
Set m_oShortcut = m_oWScriptShell.CreateShortcut(szPath)
CreateShortcut = True
Exit Function
Handler:
End Function
Public Function Resolve(ByVal szPath As String) As Boolean
On Error GoTo Handler
If Not FileExists(szPath) Then Exit Function
Set m_oShortcut = m_oWScriptShell.CreateShortcut(szPath)
Resolve = True
Exit Function
Handler:
End Function
Public Function Save()
If m_oShortcut Is Nothing Then
Exit Function
End If
m_oShortcut.Save
End Function
Public Property Let Arguments(newArguements As String)
If m_oShortcut Is Nothing Then
Exit Property
End If
m_oShortcut.Arguments = newArguements
End Property
Public Property Get Arguments() As String
On Error Resume Next
If m_oShortcut Is Nothing Then
Exit Property
End If
Arguements = m_oShortcut.Arguments
End Property
Public Property Let WorkingDirectory(ByVal newDirectory As String)
If m_oShortcut Is Nothing Then
Exit Property
End If
m_oShortcut.WorkingDirectory = newDirectory
End Property
Public Property Let Target(ByVal newTarget As String)
If m_oShortcut Is Nothing Then
Exit Property
End If
m_oShortcut.TargetPath = newTarget
End Property
Public Property Get Target() As String
If m_oShortcut Is Nothing Then
Exit Property
End If
Target = m_oShortcut.TargetPath
End Property
Public Function GetIconLocation(ByRef szSBS As String) As Long
On Error GoTo Handler
Dim szIconLocation() As String
If m_oShortcut Is Nothing Then
Exit Function
End If
If InStr(CStr(m_oShortcut.IconLocation), ",") > 0 Then
szIconLocation = Split(m_oShortcut.IconLocation, ",")
szSBS = CStr(szIconLocation(0))
GetIconLocation = CLng(szIconLocation(1))
Else
szSBS = m_oShortcut.IconLocation
End If
Handler:
End Function