Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 208
Lawrence Barsanti Avatar asked Jun 13 '12 14:06

Lawrence Barsanti


People also ask

Can windows open iPhone photos?

Import to your Windows PCYou can import photos to your PC by connecting your device to your computer and using the Windows Photos app: Update to the latest version of iTunes on your PC. Importing photos to your PC requires iTunes 12.5.1 or later. Connect your iPhone, iPad, or iPod touch to your PC with a USB cable.

Why can't I transfer photos from iPhone to PC?

The first possible reason is an unable USB connection, a corrupted USB drive, or a system glitch, so you can't view iPhone photos on PC. If you have enabled the "iCloud Photo Library" and "Optimize iPhone Storage" options on your iPhone, some of your iPhone photos are stored on iCloud.


1 Answers

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();
like image 71
Petesh Avatar answered Sep 30 '22 03:09

Petesh