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

  • 问题

  • 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))  ”输入什么?请帮帮我,各位大神。

    2017年11月9日 3:02

答案

  • 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.
    • 已标记为答案 WriteDove 2018年1月21日 1:30
    2018年1月21日 1:29

全部回复

  • 你好,

    这个论坛主要讨论Visual Studio IDE相关使用问题,由于您的问题和Indentifier of the object  有关, 我会帮助您将这个帖子移动到一般性问题讨论区,供大家讨论交流得出合理的解决方案。


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2017年11月10日 2:57
  • 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.
    • 已标记为答案 WriteDove 2018年1月21日 1:30
    2018年1月21日 1:29