IWMDMStorage::GetAttributes (deprecated)
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 GetAttributes method retrieves the attributes of the storage.
Syntax
HRESULT GetAttributes(
DWORD* pdwAttributes,
_WAVEFORMATEX* pFormat
);
Parameters
pdwAttributes
[out] Pointer to a DWORD specifying one or more of the following attributes, combined with a bitwise OR.
Attribute | Description |
WMDM_STORAGE_ATTR_FILESYSTEM | This object is the top-level storage medium, for example, a storage card or some other type of on-board storage. |
WMDM_STORAGE_ATTR_REMOVABLE | The global storage medium is removable. |
WMDM_STORAGE_ATTR_NONREMOVABLE | The global storage medium is not removable. |
WMDM_STORAGE_ATTR_FOLDERS | The global storage medium supports folders and file hierarchy. |
WMDM_STORAGE_ATTR_HAS_FILES | This storage object contains at least one file as an immediate child. |
WMDM_STORAGE_ATTR_HAS_FOLDERS | This storage object contains at least one folder as an immediate child. |
WMDM_STORAGE_ATTR_CANEDITMETADATA | This storage can edit metadata. |
WMDM_FILE_ATTR_FILE | This is a file on the storage medium. |
WMDM_FILE_ATTR_FOLDER | This is a folder on the storage medium. |
WMDM_FILE_ATTR_LINK | This is a link that creates an association between multiple files. |
WMDM_FILE_ATTR_AUDIO | This file contains audio data. |
WMDM_FILE_ATTR_DATA | This file contains non-audio data. |
WMDM_FILE_ATTR_CANPLAY | This audio file can be played by the device. |
WMDM_FILE_ATTR_CANDELETE | This file can be deleted. |
WMDM_FILE_ATTR_CANMOVE | This file or folder can be moved around on the storage medium. |
WMDM_FILE_ATTR_CANRENAME | This file or folder can be renamed. |
WMDM_FILE_ATTR_CANREAD | This file can be read by the host computer. |
WMDM_FILE_ATTR_MUSIC | This audio file contains music. |
WMDM_FILE_ATTR_AUDIOBOOK | This is an audio book file. |
WMDM_FILE_ATTR_VIDEO | This file contains video data. |
WMDM_FILE_ATTR_HIDDEN | This file is hidden on the file system |
WMDM_FILE_ATTR_SYSTEM | This is a system file |
WMDM_FILE_ATTR_READONLY | This is a read-only file. |
WMDM_STORAGE_ATTR_VIRTUAL | This storage is virtual and does not correspond to an actual storage on the file system of the device. (Folders created based on metadata are one example of virtual storage.) |
WMDM_STORAGE_IS_DEFAULT | This storage is the default location for putting new digital media on the device. |
WMDM_STORAGE_CONTAINS_DEFAULT | This storage contains the default storage where new digital media should be placed. |
pFormat
[out] Optional pointer to a _WAVEFORMATEX structure that specifies the object's audio attributes.
Return Values
The method returns an HRESULT. All the interface methods in Windows Media Device Manager can return any of the following classes of error codes:
- Standard COM error codes
- Windows error codes converted to HRESULT values
- Windows Media Device Manager error codes
For an extenstive list of possible error codes, see Error Codes.
Possible values include, but are not limited to, those in the following table.
Return code | Description |
S_OK | The method succeeded. |
E_INVALIDARG | The pdwAttributes parameter is an invalid or NULL pointer. |
E_FAIL | An unspecified error occurred. |
Example Code
The following C++ function recursively explores a storage if it is a folder with child files or folders.
void RecursiveExploreStorage(IWMDMEnumStorage* pEnumStorage)
{
HRESULT hr = S_OK;
CComPtr<IWMDMStorage> pStorage;
ULONG numRetrieved = 0;
// Loop through all storages in the current storage.
while(pEnumStorage->Next(1, &pStorage, &numRetrieved) == S_OK && numRetrieved == 1)
{
// Get the name of the object. The first time this is called on a device, it will
// retrieve '\' as the root folder name.
const UINT MAX_LEN = 255;
WCHAR name[MAX_LEN];
hr = pStorage->GetName((LPWSTR)&name, MAX_LEN);
// TODO: Display the storage name.
// Get metadata for the storage.
if (SUCCEEDED(hr))
GetMetadata(pStorage);
// Find out something about the item.
DWORD attributes = 0;
_WAVEFORMATEX audioFormat;
hr = pStorage->GetAttributes(&attributes, &audioFormat);
HANDLE_HR(hr, "Got storage attributes in RecursivelyExploreStorage.","Couldn't get storage attributes in RecursivelyExploreStorage.");
// If this is a folder, recurse into it.
if (attributes & WMDM_FILE_ATTR_FILE)
// TODO: Display a message indicating that this is a file.
else if ( (attributes & WMDM_FILE_ATTR_FOLDER) &&
((attributes & WMDM_STORAGE_ATTR_HAS_FILES) ||
(attributes & WMDM_STORAGE_ATTR_HAS_FOLDERS)) )
{
// TODO: Display a message indicating that this is a folder with children.
CComPtr<IWMDMEnumStorage> pEnumSubStorage;
hr = pStorage->EnumStorage(&pEnumSubStorage);
RecursiveExploreStorage(pEnumSubStorage);
}
// Some other useful attributes to check include:
// WMDM_FILE_ATTR_CANDELETE and WMDM_FILE_ATTR_CANPLAY and others to determine what can be done with a storage.
// WMDM_FILE_ATTR_HIDDEN and other attributes to determine display characteristics,
// WMDM_STORAGE_IS_DEFAULT to see if this is the default save location for new files.
pStorage.Release();
} // Get the next storage pointer.
e_Exit:
return;
}
Requirements
Header: Defined in mswmdm.h.
Library: mssachlp.lib
See Also