Share via


IWMDMOperation::GetObjectAttributes (deprecated)

banner art

This is preliminary documentation and subject to change.

This topic documents a feature of the Windows Media Device Manager SDK. We recommend that you migrate your application to use the Windows Portable Devices API. For more information, see the Windows Portable Devices SDK.

The GetObjectAttributes method allows the application to specify attributes for an object being written to a device. Windows Media Device Manager calls this method before a file is written to the device in order to learn the file's attributes.

Syntax

HRESULT GetObjectAttributes(
  DWORD*  pdwAttributes,
  _WAVEFORMATEX*  pFormat
);

Parameters

pdwAttributes

[out]  Pointer to a DWORD that specifies the attributes defined in the IWMDMStorage::GetAttributes method.

pFormat

[out]  Pointer to a _WAVEFORMATEX structure that specifies the audio format for files with audio data attributes.

Return Values

The application should return one of the following HRESULT values.

Return code Description
S_OK The read operation should continue.
WMDM_E_USER_CANCELLED The read operation should be cancelled without finishing.
E_FAIL An unspecified error occurred, and the read operation should be cancelled without finishing.

If the application returns either E_FAIL or WMDM_E_USER_CANCELLED, the operation is cancelled and the End method is called. If the application is using block mode and returns WMDM_E_USER_CANCELLED, then Windows Media Device Manager will return that error to the application.

Remarks

When transferring data to the device, you should provide object attributes for optimal transferrence.

Example Code

The following C++ code implements the GetObjectAttributes method. It tries to determine if the file being read (m_File) is a file or folder, and set the returned attributes accordingly.

HRESULT GetObjectAttributes(DWORD* pdwAttributes, _WAVEFORMATEX* pFormat)
{
    // TODO: Display the message: IWMDMOperation event--GetObjectAttributes.
    *pdwAttributes = WMDM_FILE_ATTR_FILE | 
        WMDM_STORAGE_ATTR_REMOVABLE | 
        WMDM_FILE_ATTR_AUDIO;

    BY_HANDLE_FILE_INFORMATION fileInformation;
    if (GetFileInformationByHandle(m_File, &fileInformation))
    {
        if (fileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
            *pdwAttributes |= WMDM_FILE_ATTR_FOLDER;
        else
            *pdwAttributes |= WMDM_FILE_ATTR_FILE;

        if (fileInformation.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
            *pdwAttributes |= FILE_ATTRIBUTE_READONLY;
    }

    return S_OK;
}

Requirements

Header: Defined in mswmdm.h.

Library: mssachlp.lib

See Also