Can images be read from an iPhone programmatically using CreateFile in Windows?

前端 未结 2 968
北海茫月
北海茫月 2021-01-06 00:22

When an iPhone is connected to a Win7 computer, the images can be viewed using Explorer (and the open file dialog of my app). However, the file location does not contain a

2条回答
  •  半阙折子戏
    2021-01-06 01:05

    The folder is actually what is referred to as a 'Virtual Folder' and does not have a full path on the file system. You will need to use the shell item returned from the open dialog to get the content of the file rather than using CreateFile.

    The data should be accessible, but you should follow the instructions from the MSDN documentation. I'm sure there are probably better examples (as this only gives guidelines).

    edit the rough process is to get the IShellItem from IFileOpenDialog, then to bind to the stream and then read the stream (assuming reading only) - bear in mind that this code is pretty much without error handling or checking or safety:

    if (pitem->GetDisplayName(SIGDN_NORMALDISPLAY, &destName) == S_OK) {
        std::cout << destName << std::endl;
        CoTaskMemFree(destName);
    }
    IStream *pistream;
    if (pitem->BindToHandler(0, BHID_Stream, IID_PPV_ARGS(&pistream)) == S_OK) {
        char input[1024];
        long to_read = 1024;
        unsigned long read;
        while (S_OK == pistream->Read(input, to_read, &read)) {
           std::cout << input << std::endl;
        }
        pistream->Release();
    }
    pitem->Release();
    

提交回复
热议问题