No. Not IE.
// there are issues with this style
// 1. you can only select one file
// 2. If folder is already opened, it doesn't select the file
Declare Function ShellExecuteW lib "shell32" (hwnd as Integer, lpOperation as WString, lpFile as WString, lpParameters as WString, lpDirectory as Integer, nShowCmnd as Integer) as Integer
Dim err as Integer
Dim param As String
param = "/select, """ + f.AbsolutePath + """"
err = ShellExecuteW(Window(0).WinHWND, "Open", "explorer", param, 0, 1)
EDIT – a better version has been written by Julian Samphire
He’s given me permission to post it here. Note there are two methods. One takes an array of file paths. The second overloads things to accept paramarry that then calls into the version that takes an array
Public Function ShowSelectedInExplorer(path As String, files() As String) as Int32
Declare Function CoInitialize Lib "Ole32.dll" Alias "CoInitialize" (pvReserved As Integer) As Int32
Declare Function ILCreateFromPathW Lib "Shell32.dll" Alias "ILCreateFromPathW" (pszPath As WString) As Ptr
Declare Function SHOpenFolderAndSelectItems Lib "Shell32.dll" Alias "SHOpenFolderAndSelectItems" (pidlFolder As Ptr, cidl As UInt32, apidl As Ptr, dwFlags As UInt32) As Int32
Declare Sub ILFree Lib "Shell32.dll" Alias "ILFree" (pidl As Ptr)
Call CoInitialize(0)
Dim pidl As Ptr = ILCreateFromPathW(path)
If pidl = Nil Then
Return 0 'If path wasn't found then return
End If
Dim mb As New MemoryBlock(COM.SIZEOF_PTR * (files.Ubound + 1))
'Get a pidl for each file and store it
For i As Integer = 0 To files.Ubound
mb.Ptr(i * COM.SIZEOF_PTR) = ILCreateFromPathW(files(i))
Next
Dim ok As Int32 = SHOpenFolderAndSelectItems(pidl, files.Ubound + 1, mb, 0)
ILFree(pidl)
Return ok
End Function
Public Function ShowSelectedInExplorer(path As String, ParamArray files As String) as Int32
'Build an array from the param array and pass it back to ShowSelectedInExplorer so we can support both methods
Dim arrayOfFiles() As String
For Each f As String In files
arrayOfFiles.Append(f)
Next
Return ShowSelectedInExplorer(path, arrayOfFiles)
End Function