what is a Identifier of the object in windows (IPortableDeviceResources GetStream)
void TransferContentFromDevice(
_In_ IPortableDevice* device)
{
//<SnippetTransferFrom1>
HRESULT hr = S_OK;
DWORD optimalTransferSizeBytes = 0;
PWSTR originalFileName = nullptr;
WCHAR selection[SELECTION_BUFFER_SIZE] = {0};
ComPtr<IPortableDeviceContent> content;
ComPtr<IPortableDeviceResources> resources;
ComPtr<IPortableDeviceProperties> properties;
ComPtr<IStream> objectDataStream;
ComPtr<IStream> finalFileStream;
// Prompt user to enter an object identifier on the device to transfer.
wprintf(L"Enter the identifer of the object you wish to transfer.\n>");
hr = StringCchGetsW(selection, ARRAYSIZE(selection));
if (FAILED(hr))
{
wprintf(L"An invalid object identifier was specified, aborting content transfer\n");
}
//</SnippetTransferFrom1>
// 1) get an IPortableDeviceContent interface from the IPortableDevice interface to
// access the content-specific methods.
//<SnippetTransferFrom2>
if (SUCCEEDED(hr))
{
hr = device->Content(&content);
if (FAILED(hr))
{
wprintf(L"! Failed to get IPortableDeviceContent from IPortableDevice, hr = 0x%lx\n", hr);
}
}
//</SnippetTransferFrom2>
// 2) Get an IPortableDeviceResources interface from the IPortableDeviceContent interface to
// access the resource-specific methods.
//<SnippetTransferFrom3>
if (SUCCEEDED(hr))
{
hr = content->Transfer(&resources);
if (FAILED(hr))
{
wprintf(L"! Failed to get IPortableDeviceResources from IPortableDeviceContent, hr = 0x%lx\n", hr);
}
}
//</SnippetTransferFrom3>
// 3) Get the IStream (with READ access) and the optimal transfer buffer size
// to begin the transfer.
//<SnippetTransferFrom4>
if (SUCCEEDED(hr))
{
hr = resources->GetStream(selection, //
Identifier of the object we want to transfer
WPD_RESOURCE_DEFAULT, // We are transferring the default resource (which is the entire object's data)
STGM_READ, // Opening a stream in READ mode, because we are reading data from the
device.
&optimalTransferSizeBytes, // Driver supplied optimal transfer size
&objectDataStream);
if (FAILED(hr))
{
wprintf(L"! Failed to get IStream (representing object data on the device) from IPortableDeviceResources, hr = 0x%lx\n", hr);
}
}
in this code,what is Identifier of the object in windows?if I want to transfer a file(its name is "a.txt" in the portable device boot dir) from the device to PC,what should I do,in another word,what should I input in “ hr = StringCchGetsW(selection,
ARRAYSIZE(selection)) ”
在这段代码中,我不理解Indentifier of the object 指的是什么?如果我想把便携式设备根目录上的一个名字是“a.txt”的文件从设备拷贝到pc,我应该在“ hr = StringCchGetsW(selection, ARRAYSIZE(selection)) ”输入什么?请帮帮我,各位大神。