Norm
8/24/2011 3:35:00 AM
Hi,
I had asked this question before and thought I had it solved. :-(, but
apparently not. I have a program that lists the desktop shortcuts and
lets you click on them to run them. This program works fine in the 32
bit version of Win7 and earlier OS's, but does not work in Win7 64 bit.
I know it must have something to do with the virtualization that
Windows does, but have not been able to figure out what to do. If I
make a desktop shortcut on the taskbar all the shortcuts work just
fine, but through my program trying to run the .lnk does not work for
any of the shortcuts. If I resolve the path to the executable and run
it that way some of them work, but not all of them.
I am using ShellExecute to start the .lnk's and get a return of 42,
which should mean no error, but the programs do not start or if they do
shutdown before they show up in the task manager.
Below is the code I am using:
Dim i As Long
Dim ExPath As String
Dim mnuPath As String
Dim lRet As Long
mnuPath = CP.Caption(ItemNumber)
If mnuPath = "Close Menu" Then Exit Sub
For i = 0 To lstDeskPath.ListCount - 1
If InStr(1, lstDeskPath.List(i), mnuPath, vbTextCompare) > 0 Then
'Get target path from shortcut
ExPath = ResolveLink(lstDeskPath.List(i))
ExPath = """" & ExPath & """"
Debug.Print ExPath
Debug.Print lstDeskPath.List(i)
'Shell out the target path
lRet = ShellExecute(Me.hwnd, "Open", lstDeskPath.List(i),
vbNullString, vbNullString, 1)
Debug.Print lRet
'If error display message box
If lRet < 32 Then
SingleButtonMsg "Unable To Open The File" & vbCrLf &
vbCrLf & _
ExPath, Me.hwnd, 5
Exit Sub
End If
'If Right$(ExPath, 4) = ".exe" Then 'Right$(ExPath,
Len(ExPath) - (Len(ExPath) - 4)) = ".exe" Then
'Shell ExPath, vbNormalFocus
'Else
'lRet = ShellExecute(Me.hwnd, "Open", ExPath, "", "",
1)
'End If
'MsgBox "ShellExecute failed, lret = " & lRet & ",
LastDllError = " & Err.LastDllError
Exit For
End If
Next i