PRB: IShellFolder::CreateViewObject() causes access violation (157247)



The information in this article applies to:

  • Microsoft Platform Software Development Kit (SDK) 1.0

This article was previously published under Q157247

SYMPTOMS

Calling IShellFolder::CreateViewObject() for a file system folder causes an Access Violation.

CAUSE

Using the file system implementation of IShellFolder::CreateViewObject() results in the shell sending a yet-to-be documented message, the WM_GETISHELLBROWSER message (currently WM_USER+7) to the hWndOwner. The shell assumes the HWND passed in as the owner responds properly to the WM_GETISHELLBROWSER message. If it doesn't, there is an access violation in Shell32.DLL.

RESOLUTION

The shell expects that the hWndOwner will supply the IShellBrowser interface to it in response to the WM_GETISHELLBROWSER message.

For example, if your window is a dialog, the following snippet of code would respond correctly to the message:
   ...
       #ifndef WM_GETISHELLBROWSER
           #define WM_GETISHELLBROWSER (WM_USER+7)
       #endif
   ...
       IShellBrowser *m_psb;
   ...
       BOOL DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
       {
           switch(uMsg)
           {
   ...
           case WM_GETISHELLBROWSER:
               SetWindowLong(hDlg, DWL_MSGRESULT, (LONG)m_psb);
               return TRUE; 
   ...
				

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Modification Type:MinorLast Reviewed:7/11/2005
Keywords:kbExtension kbNameSpace kbprb KB157247