Microsoft KB Archive/330040

= PRB: The SHMultiFileProperties Function Does Not Query IDataObject with the Correct Clipboard Format =

Article ID: 330040

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft Win32 Application Programming Interface, when used with:
 * Microsoft Windows 2000 Standard Edition

-



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.

