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

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

问题描述

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

例如 Computer\\Apple iPhone \Internal Storage\DCIM\800AAAAA\IMG_0008.JPG 而不是 E:\DCIM\800AAAAA\IMG_0008.JPG 这是sdcards,usb驱动器等常见的东西。



我尝试使用CreateFileW从iPhone读取图像,但是失败,出现错误代码:3(系统找不到指定的路径)我也试着用Chrome访问它,



有什么建议?

解决方案

被称为虚拟文件夹,在文件系统上没有完整的路径。您需要使用从打开的对话框返回的shell项来获取文件的内容,而不是使用CreateFile。

数据应该可以访问,但是您应该遵循来自 MSDN文档。我确信有可能是更好的例子(因为这只是给出了指导)。
$ b

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

<$ p (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<<输入<的std :: ENDL;
}
pistream-> Release();
}
pitem-> Release();


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.

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

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.

Any suggestions?

解决方案

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

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

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