Imports IWshRuntimeLibrary
Module MainModule
Public Function CreateShortCut(ByVal shortcutName As String, ByVal creationDir As String, ByVal targetFullpath As String, ByVal workingDir As String, ByVal iconFile As String, ByVal iconNumber As Integer) As Boolean
Try
If Not IO.Directory.Exists(creationDir) Then
Dim retVal As DialogResult = MsgBox(creationdir & " does not exist. Do you wish to create it?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo)
If retVal = DialogResult.Yes Then
IO.Directory.CreateDirectory(creationDir)
Else
Return False
End If
End If
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
shortCut = CType(WshShell.CreateShortcut(creationDir & "\" & shortcutName & ".lnk"), IWshRuntimeLibrary.IWshShortcut)
shortCut.TargetPath = targetFullpath
shortCut.WindowStyle = 1
shortCut.Description = shortcutName
shortCut.WorkingDirectory = workingDir
shortCut.IconLocation = iconFile & ", " & iconNumber
shortCut.Save()
Return True
Catch ex As System.Exception
Return False
End Try
End Function
views:
475answers:
2
+2
A:
It means you're using an instance of a class to qualify one of its shared members instead of the class itself. For example:
Class C
Public Shared x As Integer
End Class
Module M
Sub S(instance as C)
dim x1 = instance.X 'warning
dim x2 = C.X 'proper
End Sub
End Module
Strilanc
2009-12-29 01:14:01
can you please explain how i would fix it
Alex Bridges
2009-12-29 01:17:07
Which line are you getting the warning on?
Strilanc
2009-12-29 01:21:38
Alex Bridges
2009-12-29 01:22:46
I'd guess that WshShell is an instance of some class. Hover over it to see the type, and replace WshShell with the type.
Strilanc
2009-12-29 01:24:27
well all i get when i hover over it is the error
Alex Bridges
2009-12-29 01:26:48
Oh, right. Place the text cursor within it and hit ctrl+i.
Strilanc
2009-12-29 01:27:55
it says "Interface wshShell" what does that mean? and btw thanks for the help i really apreciate it
Alex Bridges
2009-12-29 01:30:35
Strilanc
2009-12-29 01:33:04
tried that still got the same error... :\
Alex Bridges
2009-12-29 01:36:45
Well, I'm afraid I can't really help more. It really looks like you have to figure out what type wshShell is and replace 'wshShell' with that type's name. If ctrl+i did not work, maybe 'Go to reference' from the context menu will.
Strilanc
2009-12-29 01:41:00
Okay, thanks for trying to help.
Alex Bridges
2009-12-29 01:42:43
A:
You need to create an instance of WshShell, I think:
Dim NewWshShell As New WshShell
now use newWshShell in place of WshShell
MattYerbs
2010-01-25 12:28:37