Writing Data from an Application to a Portable Device
An application's principal means of writing data is by using the Insert method of the IWMDMStorageControl interface. The Insert method takes five parameters.
The first parameter controls processing, storage control, and content modes for the operation. The modes are combined using a bitwise OR. For definitions of these modes and an explanation of their use, see IWMDMStorageControl::Insert. One processor mode, one storage control mode, and one content mode must be specified.
The second parameter is a string indicating where to find the content that is to be copied by the Insert method.
The next two parameters are used for the callback methods of the optional IWMDMOperation interface and IWMDMProgress interface. These two parameters can be NULL.
The last parameter is a pointer to an IWMDMStorage interface that will contain the inserted content.
To insert content on a storage medium, use IWMDMEnumStorage::Next to access the proper storage medium, query for the IWMDMStorageControl interface, and call the Insert method. The following example code shows the progression from the IWMDMDevice interface:
hr = pIDevice->EnumStorage(&pIEnumStorage);
if SUCCEEDED(hr)
{
hr = pIEnumStorage->Next(ulNumStorage, &pIStorage, &ulNumFetched);
if SUCCEEDED(hr)
{
hr = pIStorage->QueryInterface(IID_IWMDMStorageControl,
(void**)&pIWMDMStorageControl);
if SUCCEEDED(hr)
{
hr = pIWMDMStorageControl->Insert(
WMDM_MODE_BLOCK | WMDM_STORAGECONTROL_INSERTINTO,
L"C:\WMData\FileToCopy.wma",
NULL, NULL,
&pIStorage);
if (E_BUSY & hr)
wprintf(L"Device Busy\n");
if (WMDM_E_INTERFACEDEAD & hr)
wprintf(L"Storage media previously deleted.\n");
if SUCCEEDED(hr)
wprintf(L"Insert Succeeded\n");
}
}
}
See Also