PRB: The SHMultiFileProperties Function Does Not Query IDataObject with the Correct Clipboard Format (330040)



The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), when used with:
    • the operating system: Microsoft Windows 2000

This article was previously published under Q330040

SYMPTOMS

When an application calls the SHMultiFileProperties function to display the shell's properties dialog box for one or more files, SHMultiFileProperties does not query the provided IDataObject for the list of files in the CFSTR_SHELLIDLIST clipboard format.

CAUSE

On Windows 2000, Shell32.dll maintains an array of registered clipboard formats. When a custom IDataObject implementation is passed to SHMultiFileProperties, the clipboard format array of Shell32.dll may not have been initialized. The result is that SHMultiFileProperties will call the IDataObject::GetData method with 0 as the clipboard format ID.

RESOLUTION

Before calling SHMultiFileProperties, the calling application must make sure that Shell32.dll has initialized its clipboard format array. The following function forces Shell32.dll to initialize its clipboard format array by creating an IDataObject for My Computer.
STDAPI_(void) ForceShellToRegisterClipboardFormats(void)
{
   LPITEMIDLIST pidlDrives;
   IShellFolder* psfDesktop;
   IDataObject* pdata;
   HRESULT hr;

   hr = SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidlDrives);
   if (SUCCEEDED(hr))
   {
      hr = SHGetDesktopFolder(&psfDesktop);
      if (SUCCEEDED(hr))
      {
         hr = psfDesktop->GetUIObjectOf(NULL, 
                                        1, 
                                        (LPCITEMIDLIST*)&pidlDrives,
                                        IID_IDataObject, 
                                        NULL, 
                                        (void**)&pdata);
         if (SUCCEEDED(hr))
         {
            pdata->Release();
         }
         psfDesktop->Release();
      }
      ILFree(pidlDrives);
   }
}
				

MORE INFORMATION

This problem does not occur on Windows XP.

REFERENCES

For more information about this function, see the Platform SDK documentation, or the following MSDN Library Web site:

Modification Type:MajorLast Reviewed:10/30/2003
Keywords:kbnofix kbprb kbShellGrp KB330040 kbAudDeveloper