SHDOCVW.DLL goodies with MSIE4


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

If you are someone who likes surprises, I am your friend. I got a pleasent surprise when I was looking thru the Microsoft Internet control (WebBrowser) as most people know it.. I opened the shdocvw.dll which comes along with the Internet explorer 4.0 and surprise, surprise, I found that It contains  Interfaces for the Shell, Shell Link and other stuff which the shell normally handles and which are painful to implement in C or C++.. See the implementation for the CDirDialog for a sample. This is not present in IE 3.x ..

Now, In order to use these Interfaces, You need to some work.:-( well, But this is mucho simpler than the ones we have seen till now.

What I am showing below is just a tip of an Iceberg, You have got a lot of stuff there. Check out the .H and .CPP files generated and the .ODL file which I am pasting here. You can do a lot of stuff with this..

Pay close attention to the description strings along with the funtions . They usually provide a neat pointer as to what the function is supposed to do..

You can generate the .ODL  file by Opening the shdocvw.dll (you can find it in windows\system directory) in the OLEVIEW.EXE which comes along with VC++ 5.0. I think its also downloadable from Microsoft site.

After generating the .ODL file, Create a new MFC  project in VC++ to your taste. .. Then, Add class from .tlb and select shdocvw.dll.. Select all the interfaces listed in the list box shown and ask it to create the wrapper class.

It will be created as shdocvw.h and shdocvw.cpp. These are also there in the ZIP file attached..

Since, these interfaces are undocumented, I must caution you about the fact that this might change.. But, then It might not..

Anyway, Add the following lines to your .CPP file where you want to call the interface functions..

#include "initguid.h"
DEFINE_GUID(CLSID_ShellFolderViewOC ,0x9BA05971,0xF6A8,0x11CF,0xa4,0x43,0x00,0xa0,0xc9,0x0a,0x8f,0x39);

Of course, before calling any functions, Make sure that the SHDOCVW.DLL is of the correct version..4.71.1712.5.

You can use the technique Eran Yariv has pointed out. You might want to do that in the beginning of your program so that you dont have to do that again until the execution is over.

Now, after this,, Its left to you to do what you want to do..

Following is a trivial example of invoking "Start-Run" dialog from your program.


    IShellDispatch disp; //Create a IShellDispatch variable

     WCHAR szValue[80] ;
     CLSID clsid;
     HRESULT sc;
        sc = ::CoCreateInstance( CLSID_Shell, NULL, CLSCTX_SERVER, IID_IDispatch, (void**)&disp ) ; //<== Create an instance of the shell
     if (FAILED (sc))
            CString str;
      str.Format(_T("Failed to create Instance :-( "));
            TRACE( str) ;

     disp.FileRun(); //<== Call FileRun


Another example for IShellDispatch ,,

The following example is to BrowseForFolder and get the Folder interface pointer.


    IShellDispatch disp;
     IDispatch * iDisp;

     WCHAR szValue[80] ;
     CLSID clsid;
     HRESULT sc;
        sc = ::CoCreateInstance( CLSID_Shell, NULL, CLSCTX_SERVER, IID_IDispatch, (void**)&disp ) ;
     if (FAILED (sc))
            CString str;
      str.Format(_T("Failed to create Instance :-( "));
            TRACE( str) ;
     VARIANT var;
     ZeroMemory (&var, sizeof (VARIANT));

      iDisp = disp.BrowseForFolder(NULL,"Whatever",BIF_RETURNFSANCESTORS|BIF_RETURNONLYFSDIRS,var); 
     Folder ifolder(iDisp);
     CString str = ifolder.GetTitle ();


Of course, There is lot to be researched .. I will be doing it and put up an update as I get time.. Hope this will be good for the times to come..

Download File (31KB)


  • How to autoclick button?

    Posted by Legacy on 08/02/2000 07:00am

    Originally posted by: ThanhAn

    In Visual C++ 6.0
    I using tool IShellDispatch to load dialog Internet properties in control panel by ControlpanlItem() function, Now I want auto click "Delete Files" button when this dialog loaded, but I can't do. How to do this?

    I used Sendkeys function in VB is no problem, but in VC this function has not, Are there functions which funtion the same?

  • making tlb isn't necessary....

    Posted by Legacy on 12/10/1999 08:00am

    Originally posted by: Mike DeKoker

    You can find all those resources (plus a whole lot more) in the following files:

    <exdisp.h> <--- Lot of stuff in here!

  • Works great!!! But... I can't seem to register the interfaces on other computers!

    Posted by Legacy on 07/25/1999 07:00am

    Originally posted by: Ziv Ayalon

    I've opened the downloaded file and executed the .exe file...
    so far so good. When I tried to copy the interfaces (I followed the article instructions) to my program - it worked great - but only in my computer.
    When I try to execute my program on other computers, the "CoCreateInstance" Function fails.

    Can anyone please suggest what is wrong in my program? I've probably forgotten to do something, and I can't figure it out... URGH

    Thanx a lot,

    P.S.: Could the problem be that the class CShelldocDlgAutoProxy is essential? I didn't copy it to my program... maybe I should've done that. If it's true, is there an easy way to change the lines there to support
    CMainFrame? (the interfaces are called from my CFrameWnd class.)

  • How can I use ShellLinks from Java and/or J++?

    Posted by Legacy on 07/19/1999 07:00am

    Originally posted by: A R Ward

    Can anyone give me a code fragment (or just some tips... anything and everything helps!) for reading ShellLinks from J++?



  • Important Change with Internet Explorer 5

    Posted by Legacy on 06/29/1999 07:00am

    Originally posted by: Brian Hart

    There is an important change to this information which I think needs posting here. As Girish noted above, it is undocumented and subject to chnage, and what did Microsoft go and do? They went and changed things!

    I have Windows 98 and also Internet Explorer 5. Internet Explorer 5 implements a new SHDOCVW.DLL with a different set of goodies (although they can be used to). If you're wondering about where the goodies mentioned in this article went, they're still there.

    The goodies Girish mentioned in his article are in the type library SHDOC401.DLL, also located in the \Windows\System directory.

    One neat thing is that the new goodies in SHDOCVW.DLL, such as the IShellBrowser and IShellUIHelper interfaces, are documented! This means that if they change, Microsoft will let you know!

  • How Can I use the same in VB 5.0?

    Posted by Legacy on 04/29/1999 07:00am

    Originally posted by: nenvy

    Other than using Shell function, How can i do the same using VB5.0?

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date