是否可以在Windows中使用CreateFile以编程方式从iPhone读取图像? [英] Can images be read from an iPhone programmatically using CreateFile in Windows?

查看:82
本文介绍了是否可以在Windows中使用CreateFile以编程方式从iPhone读取图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将iPhone连接到Win7计算机时,可以使用资源管理器(和我的应用程序的打开文件对话框)查看图像.但是,文件位置不包含驱动器号.

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 drive letter.

例如,以Computer\Apple iPhone\Internal Storage\DCIM\800AAAAA\IMG_0008.JPG代替E:\DCIM\800AAAAA\IMG_0008.JPG,这在sdcard,USB驱动器等中很常见.

For example Computer\Apple iPhone\Internal Storage\DCIM\800AAAAA\IMG_0008.JPG instead of E:\DCIM\800AAAAA\IMG_0008.JPG which is common of sdcards, usb drives, etc...

我尝试使用CreateFileW从iPhone读取图像,但是失败,并显示(错误代码:3)系统找不到指定的路径."我也尝试过使用Chrome访问它们,但是也失败了.

I've tried using CreateFileW to read images from an iPhone but it fails with '(Error Code: 3) The system cannot find the path specified.' I've also tried accessing them with Chrome and it fails too.

有什么建议吗?

推荐答案

该文件夹实际上是所谓的虚拟文件夹",并且在文件系统上没有完整路径.您将需要使用从打开的对话框返回的外壳项目来获取文件的内容,而不是使用CreateFile.

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).

编辑的大致过程是从IFileOpenDialog获取IShellItem,然后绑定到流,然后读取该流(假定为只读)-请记住,这段代码几乎没有错误处理或检查或安全性:

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();

这篇关于是否可以在Windows中使用CreateFile以编程方式从iPhone读取图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆