2012-06-13 3 views
3

iPhone이 Win7 컴퓨터에 연결되면 Explorer (그리고 내 응용 프로그램의 열린 파일 대화 상자)를 사용하여 이미지를 볼 수 있습니다. 그러나 파일 위치에는 드라이브 문자가 없습니다. 등 2GByte의, USB 드라이브의 일반적인 예를 Computer\Apple iPhone\Internal Storage\DCIM\800AAAAA\IMG_0008.JPG 대신 E:\DCIM\800AAAAA\IMG_0008.JPG를 들어Windows에서 CreateFile을 사용하여 프로그래밍 방식으로 이미지를 iPhone에서 읽을 수 있습니까?

...

내가 아이폰에서 이미지를 읽어 CreateFileW를 사용하여 시도했지만 그것은 '실패 (오류 코드 : 3) 시스템이 지정된 경로를 찾을 수 없습니다.' Chrome으로 액세스하려고했는데 실패했습니다.

제안 사항?

답변

2

실제로 폴더는 '가상 폴더'라고하며 파일 시스템에 전체 경로가 없습니다. 열려있는 대화 상자에서 반환 된 셸 항목을 사용하여 CreateFile을 사용하지 않고 파일의 내용을 가져와야합니다.

데이터에 액세스 할 수 있어야하지만 the MSDN documentation의 지침을 따라야합니다. 아마도 더 좋은 예가있을 것이라고 확신합니다 (이는 지침 만 제공하기 때문에). 이 코드는 오류 처리 또는 검사를 사용하거나 사용하지 않고 꽤 많은 것을 곰을 염두에 -

편집 거친 프로세스는 스트림을 읽기 (읽기 전용 가정) 다음 스트림에 결합하고, IFileOpenDialog에서 IShellItem를 얻는 것입니다 안전 :

대부분의 경우 이러한 장치는 쉘 네임 스페이스 확장으로 Windows 탐색기에 삽입
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(); 
+0

감사합니다. –

0

되지는 드라이브 문자가있는 USB 스틱을 좋아한다. CopyFile (..), FindFirst() 또는 GetFileInfo (..)와 같은 일반 파일 명령의 대부분은 이러한 셸 네임 스페이스 확장에이 아닌 을 직접 사용할 수 있습니다. CopyHere(..) 만 작동합니다. 당신이

Public Const MyComputer As Integer = &H11& 

Sub EnumMyComputer() 
    Dim oItem As Object 
    Dim res As Integer 

    For Each oItem In DirectCast(CreateObject("Shell.Application").Namespace(MyComputer).Items, System.Collections.IEnumerable) 
    Debug.Print(oItem.Type.ToString) 
    if oItem.Type.ToString="Tragbares Medienwiedergabegerät" then '<- check, adopt! 
     res = EnumNamespaceItems(oItem, "", oItem.Name.ToString, 0) 
    End If 
    Next oItem 
End Sub 

Function EnumNamespaceItems(oItem As Object, SrcCPath As String, SrcDPath As String, folderLevel As Integer) As Integer 
    Dim y As Object 
    Dim tempFullFileName As String 

    Debug.Print(StrDup(folderLevel, " ") & "\" & oItem.Name.ToString & " (" & oItem.Path.ToString & ")") 
    For Each y In DirectCast(oItem.GetFolder.items, System.Collections.IEnumerable) 
    'Debug.Print(StrDup(folderLevel, " ") & SrcDPath & y.Name.ToString) 
    If y.IsFolder = True Then 
     Dim n1 As Integer 
     n1 = EnumNamespaceItems(y, SrcCPath & y.Path.ToString & "\", SrcDPath & y.Name.ToString & "\", 1 + folderLevel) 
     If n1 < 0 Then 'failure: Cancel 
     EnumNamespaceItems = n1 
     Exit Function 
     End If 
    Else 'it's a file: 
     Debug.Print(StrDup(folderLevel, " ") & " " & y.Name.ToString) 
     tempFullFileName = System.IO.Path.GetTempPath() & y.Name.ToString 
     ' CopyFile is not possible here if SrcCPath is like "::{…}…": 
     ' My.Computer.FileSystem.CopyFile(SrcCPath & y.Name.ToString , fFile.FullName) 
     Dim suc As Integer = CopyHereFileWait(y, My.Computer.FileSystem.SpecialDirectories.Temp) 
     If suc >= 0 Then 'now we can do things like this: 
     Dim MyFileInfo As System.IO.FileInfo = My.Computer.FileSystem.GetFileInfo(tempFullFileName) 
     Dim fileDate As Date = MyFileInfo.LastWriteTime 
     End If 'suc 
    End If 'else y.IsFolder 
    Next y 
    EnumNamespaceItems = 0 
End Function 


Function CopyHereFileWait(sourceNamespaceObject As Object, targetFolder As String) As Integer 
    Dim fsMyStream As System.IO.FileStream 
    Dim n1 As Integer 
    Dim taregetFullFileName As String 

    n1 = Len(targetFolder) 
    If Mid(targetFolder, n1, 1) = "\" Then 
    targetFolder = Microsoft.VisualBasic.Left(targetFolder, n1 - 1) 
    End If 
    taregetFullFileName = targetFolder & "\" & sourceNamespaceObject.Name.ToString 
    Dim oNsTargetFolder As Object 
    oNsTargetFolder = CreateObject("Shell.Application").Namespace(CStr(targetFolder)) 
    oNsTargetFolder.copyHere(sourceNamespaceObject) 
    'returns immediately and is doing the work in the background 
    n1 = 0 
    Do 
    Threading.Thread.Sleep(50) 'ms 
    Try 
     fsMyStream = System.IO.File.Open(taregetFullFileName, IO.FileMode.Open, IO.FileAccess.ReadWrite) 
     fsMyStream.Close() 
     CopyHereFileWait = n1 
     Exit Function 
    Catch ex As Exception 
     Debug.Print(ex.Message) 
    End Try 
    n1 = n1 + 1 
    Loop While n1 < 400 'timeout 400*50ms = 20s 
    CopyHereFileWait = -n1 
End Function 

추가 할 수 있습니다 : 는 내가의 디지털 카메라에있는 파일을 열거하고 이제 안드로이드 장치에서 vb.net 프로그램 및 내 Windows PC에 내 사진을 복사하는 방법을 알아 내기 위해 오랜 시간이 필요 y.Name.ToString = "DCIM"(folderLevel = 1 인 경우) 및 ".jpg"가있는 파일의 폴더를 확인하십시오.

관련 문제