what is a Identifier of the object in windows (IPortableDeviceResources GetStream)

weixin_38064768 2017-11-09 03:02:01
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))  ”输入什么?请帮帮我,各位大神。
...全文
39 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38075910 2018-01-21
  • 打赏
  • 举报
回复
Identifer of the object is a string ,it is It is a unique identifier,e.g s10001,s10001 can be a device, it can be a file or folder.
weixin_38065175 2018-01-21
  • 打赏
  • 举报
回复
Identifer of the object is a string ,it is It is a unique identifier,e.g s10001,s10001 can be a device, it can be a file or folder.

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧