forked from lee-soft/ViStart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShellLinkObject.cls
95 lines (75 loc) · 2.27 KB
/
ShellLinkObject.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
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ShellLinkObject"
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 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)
'Fix target on Windows 8 machines
If g_Windows8 Or g_Windows81 Then
If Not FileExists(Me.Target) Then
If FileExists(Wow64Wrapper(Me.Target)) Then
Me.Target = Wow64Wrapper(Me.Target)
Me.Save
Set m_oShortcut = m_oWScriptShell.CreateShortcut(szPath)
End If
End If
End If
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 Get Arguments() As String
If m_oShortcut Is Nothing Then
Exit Property
End If
Arguements = m_oShortcut.Arguments
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