Click here to Skip to main content
11,802,076 members (62,208 online)
Click here to Skip to main content

Implementing IShellBrowser to host IShellView

, 4 Jun 2001 CPOL 247.2K 3.8K 65
Rate this:
Please Sign up or sign in to vote.
Imitating the Windows Explorer
<!-- Article image -->

Sample Image - screen.gif

<!-- Main HTML starts here -->


I wondered how I can simulate the Windows explorer listview of files. Here is what I found. It might be useful to someone. If you create a simple listview control and populate it with files/folders, you'll notice that you can't:

  • Easily detect changes to files (rename, delete, copy/move...etc) while user is viewing the list
  • Send To menu is not populated if you try to use the shell's menu for your items
  • There doesn't seem to be a way of getting the column names used in shellview (filename, size, owner, times, and many others)

I found that Windows explorer and File Open dialog expose IShellBrowser, which is used by IShellFolder/IShellView to create the listview of files. So, I created a simple app with WTL. Implemented basic IShellBrowser methods and exposed it to IShellView through IShellFolder::CreateViewObject. Finally, to create the listview I called IShellView::CreateViewWindow. I didn't try to merge the menus.
Things I couldn't get to work:

  • Toolbar buttons (they were added to my toolbar, but bitmaps were messed up). They do function however.
  • The most important one for me was that I couldn't easily detect when user wanted to open/explore/search the selected folder so I could sync the file tree.

The IShellBrowser::BrowseObject was never even called, so I didn't implement it, but it should be implemented because most NSEs use this method. I did find that the shellview sends WM_DDE* messages and if you respond properly you'll get the info about the action user taken. The needed messages are WM_DDE_INITIATE, WM_DDE_EXECUTE, WM_DDE_TERMINATE. WM_DDE_EXECUTE will give you string such as
"[ViewFolder("C:\Documents and Settings\leon\Desktop\billing", :428:780, 1)]". I have no idea what the 428:780 stand for. But action would be ViewFolder/ExploreFolder/FindFolder. It would be nice if Microsoft documented this stuff then we could use it. But as things stand now they even say in the MSDN:

"You do not implement this interface directly. IShellBrowser is implemented by Windows Explorer and by the Windows File Open common dialog box."

But then why did they tell us about WM_GETISHELLBROWSER? Anyway, maybe it would be useful to someone, so here it is.

Some useful points:

  • To get drag drop functioning in shellview, call OleInitialize/OleUninitialize
  • Make sure you respond properly to WM_GETISHELLBROWSER or CreateView might crash
  • Details listview seems to work only with FVM_DETAILS and FWF_SNAPTOGRID combination
  • ICommDlgBrowser can be supported to have a simple listview like in common file dialog boxes (without webview)
  • Don't name your executable as explorer.exe or unpleasant things will happen

Useful links



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Leon Finker
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralShowing only folders in tree Pin
Nethen30-Oct-10 23:49
memberNethen30-Oct-10 23:49 
GeneralAwesome code! Pin
T800G10-Oct-09 1:43
memberT800G10-Oct-09 1:43 
QuestionContext Menu Problem Pin
rImrose29-May-09 6:40
memberrImrose29-May-09 6:40 
QuestionHow can I embed the whole Explorer window in my window Pin
Javed Akhtar Ansari3-Oct-08 0:55
memberJaved Akhtar Ansari3-Oct-08 0:55 
GeneralrIt wasn't worked Pin
jalalymm15-Apr-07 1:56
memberjalalymm15-Apr-07 1:56 
QuestionHow to get thumbnail from windown Explorer? Pin
thanhthuyvn_vtajkhskjakjd16-Oct-06 22:13
memberthanhthuyvn_vtajkhskjakjd16-Oct-06 22:13 
Generalerror Pin
kiranin10-Sep-06 21:21
memberkiranin10-Sep-06 21:21 
QuestionIs there any solution to implement this project on a dailog-based application? Pin
Aki Wang19-Jul-06 15:28
memberAki Wang19-Jul-06 15:28 
GeneralNever ending dialog pops up Pin
R.D.H.2-May-06 6:24
memberR.D.H.2-May-06 6:24 
QuestionHow to get the path for each icon in the Desktop folder Pin
giftsana22-Mar-06 15:27
membergiftsana22-Mar-06 15:27 
AnswerRe: How to get the path for each icon in the Desktop folder Pin
giftsana27-Mar-06 19:18
membergiftsana27-Mar-06 19:18 
GeneralSetting the path Pin
cowtongue215-Feb-06 17:06
membercowtongue215-Feb-06 17:06 
Questionwhy cannot use &quot;delete&quot; key to delete file? Pin
tianzuo3-Nov-05 21:36
membertianzuo3-Nov-05 21:36 
GeneralStatus bar messages and Multi Thread Pin
Guybrush19-Mar-05 11:55
memberGuybrush19-Mar-05 11:55 
GeneralWM_DDE* messages seems are not sent Pin
alerma19-Oct-04 9:15
memberalerma19-Oct-04 9:15 
GeneralRe: WM_DDE* messages seems are not sent Pin
RickyV19-Oct-04 14:09
memberRickyV19-Oct-04 14:09 
GeneralRe: WM_DDE* messages seems are not sent Pin
alerma20-Oct-04 1:35
memberalerma20-Oct-04 1:35 
GeneralRe: WM_DDE* messages seems are not sent Pin
RickyV20-Oct-04 14:12
memberRickyV20-Oct-04 14:12 
GeneralRe: WM_DDE* messages seems are not sent Pin
Leon Finker20-Oct-04 14:40
memberLeon Finker20-Oct-04 14:40 
GeneralDetecting cut/paste operations Pin
orangerobin1-Oct-04 2:41
sussorangerobin1-Oct-04 2:41 
Generalusing the same ishellview Pin
RickyV20-Sep-04 21:27
memberRickyV20-Sep-04 21:27 
GeneralRe: using the same ishellview Pin
Leon Finker21-Sep-04 13:55
memberLeon Finker21-Sep-04 13:55 
GeneralRe: using the same ishellview Pin
RickyV21-Sep-04 15:03
memberRickyV21-Sep-04 15:03 
GeneralBrowseObject Pin
quinthar13-Nov-04 22:21
memberquinthar13-Nov-04 22:21 
GeneralRe: BrowseObject Pin
RickyV28-Nov-04 20:21
memberRickyV28-Nov-04 20:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.151002.1 | Last Updated 5 Jun 2001
Article Copyright 2001 by Leon Finker
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid