Hello
What I want is to get the path of the selected item by pressing a Button1 from IExplorerBrowser.
Implement this interface IExplorerPaneVisibility to IExplorerBrowser.
I found this code and it shows me the browser.
But I cannot do the mentioned operations. I tried to do it, but was unsuccessful.
Imports System.Runtime.InteropServices
Public Class Form1
Public Enum HRESULT As Integer
DRAGDROP_S_CANCEL = &H40101
DRAGDROP_S_DROP = &H40100
DRAGDROP_S_USEDEFAULTCURSORS = &H40102
DATA_S_SAMEFORMATETC = &H40130
S_OK = 0
S_FALSE = 1
E_NOINTERFACE = &H80004002
E_NOTIMPL = &H80004001
OLE_E_ADVISENOTSUPPORTED = &H80040003
E_FAIL = &H80004005
MK_E_NOOBJECT = &H800401E5
End Enum
Public Enum EXPLORER_BROWSER_OPTIONS As Integer
EBO_NONE = 0
EBO_NAVIGATEONCE = &H1
EBO_SHOWFRAMES = &H2
EBO_ALWAYSNAVIGATE = &H4
EBO_NOTRAVELLOG = &H8
EBO_NOWRAPPERWINDOW = &H10
EBO_HTMLSHAREPOINTVIEW = &H20
EBO_NOBORDER = &H40
EBO_NOPERSISTVIEWSTATE = &H80
End Enum
Public Enum EXPLORER_BROWSER_FILL_FLAGS As Integer
EBF_NONE = 0
EBF_SELECTFROMDATAOBJECT = &H100
EBF_NODROPTARGET = &H200
End Enum
Public Structure RECT
Public Left As Integer
Public Top As Integer
Public Right As Integer
Public Bottom As Integer
End Structure
Public Enum FOLDERVIEWMODE As Integer
FVM_AUTO = -1
FVM_FIRST = 1
FVM_ICON = 1
FVM_SMALLICON = 2
FVM_LIST = 3
FVM_DETAILS = 4
FVM_THUMBNAIL = 5
FVM_TILE = 6
FVM_THUMBSTRIP = 7
FVM_CONTENT = 8
FVM_LAST = 8
End Enum
<StructLayout(LayoutKind.Sequential)>
Public Structure FOLDERSETTINGS
Public ViewMode As UInteger
Public fFlags As UInteger
End Structure
<ComImport>
<Guid("dfd3b6b5-c10c-4be9-85f6-a66969f402f6")>
<InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
Public Interface IExplorerBrowser
Function Initialize(hwndParent As IntPtr, ByRef prc As RECT, ByRef pfs As FOLDERSETTINGS) As HRESULT
Function Destroy() As HRESULT
Function SetRect(ByRef phdwp As IntPtr, rcBrowser As RECT) As HRESULT
Function SetPropertyBag(pszPropertyBag As String) As HRESULT
Function SetEmptyText(pszEmptyText As String) As HRESULT
Function SetFolderSettings(pfs As FOLDERSETTINGS) As HRESULT
'IExplorerBrowserEvents *psbe
Function Advise(psbe As IntPtr, ByRef pdwCookie As Integer) As HRESULT
Function Unadvise(dwCookie As Integer) As HRESULT
Function SetOptions(dwFlag As EXPLORER_BROWSER_OPTIONS) As HRESULT
Function GetOptions(ByRef pdwFlag As EXPLORER_BROWSER_OPTIONS) As HRESULT
Function BrowseToIDList(pidl As IntPtr, uFlags As UInteger) As HRESULT
'IUnknown *punk,
Function BrowseToObject(punk As IntPtr, uFlags As UInteger) As HRESULT
Function FillFromObject(punk As IntPtr, dwFlags As EXPLORER_BROWSER_FILL_FLAGS) As HRESULT
Function RemoveAll() As HRESULT
Function GetCurrentView(ByRef riid As Guid, ByRef ppv As IntPtr) As HRESULT
End Interface
Public Const SBSP_ABSOLUTE = &H0
<DllImport("User32.dll", SetLastError:=True)>
Public Shared Function GetClientRect(hWnd As IntPtr, ByRef lpRect As RECT) As Boolean
End Function
<DllImport("User32.dll", SetLastError:=True)>
Private Shared Function MoveWindow(hWnd As IntPtr, X As Integer, Y As Integer, nWidth As Integer, nHeight As Integer, bRepaint As Boolean) As Boolean
End Function
<DllImport("user32", SetLastError:=True, CharSet:=CharSet.Auto)>
Public Shared Function FindWindowEx(ByVal hWndParent As IntPtr, ByVal hWndChildAfter As IntPtr, ByVal lpszClass As String, ByVal lpszWindow As String) As IntPtr
End Function
<DllImport("Shell32.dll", SetLastError:=True)>
Public Shared Function SHGetKnownFolderIDList(ByRef rfid As Guid, dwFlags As Integer, hToken As IntPtr, ByRef ppidl As IntPtr) As HRESULT
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim CLSID_ExplorerBrowser As New Guid("71f96385-ddd6-48d3-a0c1-ae06e8b055fb")
Dim ExplorerBrowserType As Type = Type.GetTypeFromCLSID(CLSID_ExplorerBrowser, True)
Dim ExplorerBrowser As Object = Activator.CreateInstance(ExplorerBrowserType)
Dim pExplorerBrowser As IExplorerBrowser = DirectCast(ExplorerBrowser, IExplorerBrowser)
Dim fs As FOLDERSETTINGS
fs.ViewMode = FOLDERVIEWMODE.FVM_DETAILS
fs.fFlags = 0
Dim rc As RECT
GetClientRect(Me.Handle, rc)
Dim hr As HRESULT = pExplorerBrowser.Initialize(Me.Handle, rc, fs)
If (hr = HRESULT.S_OK) Then
pExplorerBrowser.SetOptions(EXPLORER_BROWSER_OPTIONS.EBO_SHOWFRAMES Or
EXPLORER_BROWSER_OPTIONS.EBO_ALWAYSNAVIGATE Or
EXPLORER_BROWSER_OPTIONS.EBO_NOTRAVELLOG Or
EXPLORER_BROWSER_OPTIONS.EBO_NOWRAPPERWINDOW Or
EXPLORER_BROWSER_OPTIONS.EBO_HTMLSHAREPOINTVIEW Or
EXPLORER_BROWSER_OPTIONS.EBO_NOBORDER Or
EXPLORER_BROWSER_OPTIONS.EBO_NOPERSISTVIEWSTATE)
Dim pidlInit As IntPtr
Dim FOLDERID_ComputerFolder As New Guid("0AC0837C-BBF8-452A-850D-79D08E667CA7")
SHGetKnownFolderIDList(FOLDERID_ComputerFolder, 0, IntPtr.Zero, pidlInit)
pExplorerBrowser.BrowseToIDList(pidlInit, SBSP_ABSOLUTE)
End If
End Sub
Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles Me.Resize
Dim hWndBrowserControl As IntPtr = FindWindowEx(Me.Handle, IntPtr.Zero, "ExplorerBrowserControl", Nothing)
MoveWindow(hWndBrowserControl, 0, 0, Me.ClientSize.Width, Me.ClientSize.Height, True)
End Sub
End Class
I hope you can help me.
Thanks a lot.