Results 1 to 31 of 31

Thread: [RESOLVED] "Devices and Drives" ... accessing them via VB6

  1. #1

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Resolved [RESOLVED] "Devices and Drives" ... accessing them via VB6

    Okay, here's one I haven't tried before, and don't see the obvious solution.

    I'm trying to write a "picture backup" program from my phone to my NAS box. I've got a "Folder Tree Copy" program I'm quite happy with, and I've used it often to "hard code" specific source and destination paths to allow for one-click backup/copies. I was thinking I'd do that yet again for my phone, but I ran into this problem. Here's a picture of how my phone shows up:

    Name:  XT1080.png
Views: 3992
Size:  45.9 KB

    I can't find a UNC for it, nor an IP for it. And, I'd rather not map it to a drive, but I can't find a way to do that either. I tried addressing it as "Computer\XT1080" in VB6, but no cigar.

    I'll keep searching, but does anyone know how to skin this cat?

    Thanks,
    Elroy

    EDIT1: The phone is just plugged into my computer via a USB cable ... standard USB on the computer's side and micro-USB on the phone's side. Also, there's probably some driver installed that allows me to see it, but I'd have to do a bit of research to figure out what it is.
    Last edited by Elroy; Mar 19th, 2019 at 10:43 AM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  2. #2

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: "Devices and Drives" ... accessing them via VB6

    Okay, a bit of progress, I suppose. I did manage to figure out that it appears on my Device Manager as a "Portable Device":

    Name:  XT1080Driver.jpg
Views: 3154
Size:  46.0 KB

    And then also, under events, there's a "Device migrated" event where I can get a GUID value:

    Name:  XT1080Guid.jpg
Views: 3564
Size:  36.7 KB

    I'm still not quite sure what to do with this information though. Also, I'm not sure how static that GUID value is.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  3. #3
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: "Devices and Drives" ... accessing them via VB6

    Here is a monster list of shell namespaces w/ GUIDS e.g. Start->Run: shell:::{992CFFA0-F557-101A-88EC-00DD010CCC48} -- opens Network Connections namespace.

    cheers,
    </wqw>

  4. #4

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: "Devices and Drives" ... accessing them via VB6

    Hi Wqweto,

    Yeah, thanks, but I'm still quite confused. How would I use something like that with, say, Dir$(???)? I tried it and it just errors. I tried both your Control Panel GUID and my XT1080 GUID, and neither will work with Dir$(). Do I need to use an API version of Dir$()?

    Thanks,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  5. #5
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,392

    Re: "Devices and Drives" ... accessing them via VB6

    What happens if you double click on it in Windows Explorer? Can you access the "folders" on the phone and see the one where the pictures are stored? If yes, you should be able to click on the path box in Windows Explorer and it should show what it thinks the path is.

  6. #6
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,041

    Re: "Devices and Drives" ... accessing them via VB6

    hi try at the Command prompt
    map to X:\
    Code:
    net use X: \\XT1080
    this is from memory, I could be wrong
    if all goes well you should see the a new X:\
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  7. #7
    Fanatic Member
    Join Date
    Feb 2019
    Posts
    706

    Re: "Devices and Drives" ... accessing them via VB6

    Rather than answering your question directly, you can change how the phone connects to USB. Slide down the screen(where the clock is) to get to the notifications, and look at the bottom. There should be a message that says "Touch for other USB options". I think some of them would connect to the PC as a thumb drive, perhaps with drive letter, which is easier to work with. If you don't see this menu, there is a way to re-enable it. Search YouTube or the web for "Android USB options".

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: "Devices and Drives" ... accessing them via VB6

    We had a thread on this topic a week ago or so, but I can't find it right now.

    Maybe see Android USB Connections Explained: MTP, PTP, and USB Mass Storage

  9. #9
    Hyperactive Member
    Join Date
    Nov 2011
    Posts
    498

    Re: "Devices and Drives" ... accessing them via VB6

    i had the same discussion a few weeks ago how to copy pics from phone to pc based on certain folders.

    see Posts here

    http://www.vbforums.com/showthread.p...-S8&highlight=

    i got so far with my app , until i hit the unicode filenames (ie polish accent )

    you cannot directly access with dir , but you can with namespaces.
    Last edited by k_zeon; Mar 19th, 2019 at 02:50 PM.

  10. #10
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,647

    Re: "Devices and Drives" ... accessing them via VB6

    My browser control should have no problem interacting with these devices; if it does you can look at the methods used.

    I'm using an LG V20, and I can either connect in Photo mode, or file transfer mode,


    and copy, paste, drag drop.. whatever


    In the thread k_zeon linked to, I gave an overview of how it works:
    Quote Originally Posted by fafalone View Post
    Sorry I'm late to the party.

    My shell browser control uses the IShellItem/IDataObject/IFileOperation methods to interact with the file system, and has no trouble browsing through my phone when it's connected in photo transfer mode or file transfer mode, then dragging and dropping or copying/pasting the files onto the computer (I've tested both modes on my Android phone, LG V20). It handles GUID paths and the wacky photo transfer paths, I just dragged from ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_1004&pid_62c5#vs995c53f237e#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\SID-{10001,,54509711360}\{00000008-0001-0001-0000-000000000000}\{0000021F-0001-0001-0000-000000000000}\{00002375-0001-0001-0000-000000000000} right onto my desktop.
    Copy/paste works fine too; it creates a IShellItemArray of the selected items, requests its context menu, then invokes cut or copy.

    You can either use that, or just see the code for how to navigate and interact with the file system in this manner. Doing things this way handles all virtual locations; anything that Explorer can see and do, you can see and do. View/edit all the properties too by duplicating the Explorer details bar--- the property viewing part at least is highly portable and based on other projects; all going through IShellItem/IPropertyStore.


    Here's the basic outline of how it's done:
    -The root directory (e.g. Computer/ThisPC) is loaded via SHGetKnownFolderItem or other way of getting an IShellItem
    -The .EnumItems method gives us the contents to enumerate
    -Each item as its enumerated is split using the IParentAndItem interface to get the parent IShellFolder and pidl and item relative pidl, which is the reference we store
    -The above is repeated as a new folder to navigate into is selected
    -Once we're in the folder we want, we find a valid way to get a file reference.
    --DragDrop: For a phone connected in photo-mode, resolving the path will fail once you get past the device root, so the code combines the two pidl references, this gives us a fully qualified pidl
    ---We create an IShellItemArray from an array of the fully-qualified pidls of the selected files using SHCreateShellItemArrayFromIDLists
    ---The BindToHandler method is then used to request an IDataObject representing the files, which is then handed off to the shell for drag/drop via SHDoDragDrop
    --Copy/Paste via code entirely: Follow the above method to get the IShellItemArray, only this time request IContextMenu instead of IDataObject. Invoke the copy (or cut or any other) verb.
    --I use a slightly different method to throw up the right-click menu; I use the IShellFolder reference to the current folder and an array of relative pidls of the selected files, then request the IContextMenu from the IShellFolder, and get an hMenu from QueryContextMenu for TrackPopupMenu.

    IFileOperation accepts an IShellItemArray, so if you wanted to use that, you'd just pass it off there instead of the above copy/paste or drag/drop.


    The key is always having available relative pidls, and a non-string reference to the current parent folder (IShellFolder, IShellItem, fully qualified pidl). If you've got those, you can get a reference to whatever weird way Explorer is handling non-filesystem objects. Both a reference to pass to copying/editing mechanisms, and a reference you can get the friendly name from, because that's definitely needed, the parsing names are crazy (and don't always work anyway).
    Believe it or not, there actually is usually a very good reason why I use very complicated APIs and COM interfaces to do things that others handle through very simple built-in functions; a method to the madness


    Edit: I was looking at the Devices and Printers window itself... it's pretty much browsed just as in Explorer too. The 'Browse Files' menu is just a shortcut to the object that appears in 'Computer'. Which is true for the other devices with file storage as well, like the USB drive,

    (Note: there's a bug in the current public release that's causing the menu icons and the submenu to break; delete dbg_enumverbs call in ShowShellContextMenu to fix until I update public release.)
    Last edited by fafalone; Mar 19th, 2019 at 06:26 PM.

  11. #11

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: "Devices and Drives" ... accessing them via VB6

    Ok, let me grind through the responses as best I can. To jdc2000, ChrisE, and qvb6.

    Yes, I can browse my phone just fine:

    Name:  cam.png
Views: 2908
Size:  37.6 KB

    Also, there's no way to map it to a drive. "\\XT1080" gets me nothing. If you look at the address bar in the above, you'll see that "Computer\XT1080\Internal storage\DCIM\Camera" address. If I copy-paste that into Windows explorer, I get there. But putting a \\ before Computer breaks it. Furthermore, that path does not work in something like Dir$(), or even if you append a "\*.*" to the end of it. Still no cigar.

    If I go to my USB hub, from "Open Devices and Printers" from my USB icon in my SysTray, I get something like the following:

    Name:  cam2.png
Views: 2996
Size:  53.2 KB

    I can click that XT1080, but then I've just gone full circle and I'm back in Windows explorer. There are no other options on my USB SysTray icon.

    I'll be exploring the subsequent options now, and I'll report back if something works.

    Thank For Trying,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  12. #12

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: "Devices and Drives" ... accessing them via VB6

    Hmmm, ok, this is a mess, at least to my eyes.

    Yes, k_zeon outlined the same problem I'm having on this thread.

    And, so far, I've tried LaVolpe's class and also Fafalone's browser control. Fafalone's control won't seem to browse in past the "Internal Storage" folder. It just shows no more items and nowhere to browse.

    With LaVolpe's class, I can browse on into the Computer\XT1080\Internal storage\DCIM\Camera folder and I can see the files, but I'm still unclear on how to get a fully path specified list of those files, which is what I want. LaVolpe is obviously using some Windows Common Dialog to get in, whereas Fafalone is digging in through API calls. I was disappointed that Fafalone's approach didn't drill in because then I could have gotten my file list.

    I suppose I could explore LaVolpe's approach more, and do some kind of a "Select All" to return all the files, but ugh. I think I'll study k_zeon's thread a bit more and see what he did.

    Again, Thanks. I'll try and keep at it.
    Elroy

    EDIT1: I suspect, even when I get my file list, I'm going to have trouble with FileCopy, and be required to write some API version of that.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  13. #13
    Hyperactive Member
    Join Date
    Nov 2011
    Posts
    498

    Re: "Devices and Drives" ... accessing them via VB6

    Hi Elroy. i am just off to bed right now. But i can send you some codes that i have cobbled together, tomorrow if you pm me.
    maybe we can get something that works

  14. #14
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,647

    Re: "Devices and Drives" ... accessing them via VB6

    That's weird that ucShellBrowse wouldn't open it; that's the exact same structure as my phone shows (\Internal storage\DCIM\Camera, as shown in the picture). You went through 'Computer' right? And most notably, is there background text that says 'This folder is empty'? If you haven't found a better approach, I'd like to take a look at the debug output.

  15. #15
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: "Devices and Drives" ... accessing them via VB6

    Quote Originally Posted by Elroy View Post

    Yes, k_zeon outlined the same problem I'm having on this thread.
    ...
    EDIT1: I suspect, even when I get my file list, I'm going to have trouble with FileCopy, and be required to write some API version of that.
    Seems you've missed my simple code-snippet in post #40 in said thread.
    It doesn't get any easier than that IMO.

    Olaf

  16. #16
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,416

    Re: "Devices and Drives" ... accessing them via VB6

    Has anyone of you thought to remember, that any drive in Windows is a "Device"?

    Start Computer-Management --> Drives
    Rightclick on the Rowheader of a drive - Properties -> Go to Tab "Detail"s --> Objectname of physical Device (i have german Windows, no idea if it's the same captions)
    Plugin your Phone, and look it up

    EDIT: Something else
    https://docs.microsoft.com/en-us/win...d-file-systems
    Last edited by Zvoni; Mar 20th, 2019 at 02:09 AM.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  17. #17
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: "Devices and Drives" ... accessing them via VB6

    Quote Originally Posted by Schmidt View Post
    Seems you've missed my simple code-snippet in post #40 in said thread.
    Using VBScript shell namespace wrappers is what I imagined too would be the easiest proof-of-concept (and possibly production) implementation for copy from/to this virtual folder.

    Just have to figure out the elusive GUID your device's shell extension is implementing, Elroy, and if you get to know what the GUID for iPhone's namespace is for instance, please do share it here :-))

    cheers,
    </wqw>

  18. #18
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,041

    Re: "Devices and Drives" ... accessing them via VB6

    Hi,

    try mapping with powershell

    https://social.technet.microsoft.com...rverpowershell

    well these guys/girls got it going

    https://www.mtpdrive.com/


    I'm a Caveman, would like to try but I don't(and never will) have a mobile Phone


    did you check with 'Disk Management" if the Phone is listed there ? perhaps it's there but with no
    assigned Letter

    start at command prompt an enter diskmgmt.msc
    you might be lucky and it's there but with no letter
    Last edited by ChrisE; Mar 20th, 2019 at 04:01 AM.
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  19. #19
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,416

    Re: "Devices and Drives" ... accessing them via VB6

    Quote Originally Posted by wqweto View Post
    Using VBScript shell namespace wrappers is what I imagined too would be the easiest proof-of-concept (and possibly production) implementation for copy from/to this virtual folder.

    Just have to figure out the elusive GUID your device's shell extension is implementing, Elroy, and if you get to know what the GUID for iPhone's namespace is for instance, please do share it here :-))

    cheers,
    </wqw>
    Code:
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_PNPEntity WHERE DeviceID Like '%USB%'")
    For Each objItem In colItems
        Debug.Print "Device ID: " & objItem.DeviceID
        Debug.Print "Name: " & objItem.Name
        Debug.Print "PNPDeviceID: " & objItem.PNPDeviceID
        Debug.Print "Description: " & objItem.Description
        Debug.Print "ClassGUID: " & objItem.ClassGUID
        Debug.Print
    Next
    For my iPhone (which doesn't appear in Explorer as a Device):
    Device ID: USB\VID_05AC&PID_12A8\D719CD69A0AB3E8A65FACA790E7F19AF6D567B17
    Name: Apple Mobile Device USB Driver
    PNPDeviceID: USB\VID_05AC&PID_12A8\D719CD69A0AB3E8A65FACA790E7F19AF6D567B17
    Description: Apple Mobile Device USB Driver
    ClassGUID: {36fc9e60-c465-11cf-8056-444553540000}


    MS-Docs Win32_PNPEntity:
    https://docs.microsoft.com/de-de/win...in32-pnpentity
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  20. #20
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: "Devices and Drives" ... accessing them via VB6

    @Zvoni: No, it's not the ClassGUID. (You can test it yourself by entering shell::{36fc9e60-c465-11cf-8056-444553540000} in Start->Run dialog -- Windows cannot find it.)

    Or do you mean spelunking Device ID in some way to figure out the GUID of the shell extension folder?

    Edit: I also tried the ClassGUID of Apple iPhone device itself
    Code:
    Device ID: USB\VID_05AC&PID_12A8&MI_00\0
    Name: Apple iPhone
    PNPDeviceID: USB\VID_05AC&PID_12A8&MI_00\0
    Description: Apple iPhone
    ClassGUID: {eec5ad98-8080-425f-922a-dabf3de3f69a}
    cheers,
    </wqw>

  21. #21
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,416

    Re: "Devices and Drives" ... accessing them via VB6

    Quote Originally Posted by wqweto View Post
    @Zvoni: No, it's not the ClassGUID. (You can test it yourself by entering shell::{36fc9e60-c465-11cf-8056-444553540000} in Start->Run dialog -- Windows cannot find it.)

    Or do you mean spelunking Device ID in some way to figure out the GUID of the shell extension folder?

    Edit: I also tried the ClassGUID of Apple iPhone device itself
    Code:
    Device ID: USB\VID_05AC&PID_12A8&MI_00\0
    Name: Apple iPhone
    PNPDeviceID: USB\VID_05AC&PID_12A8&MI_00\0
    Description: Apple iPhone
    ClassGUID: {eec5ad98-8080-425f-922a-dabf3de3f69a}
    cheers,
    </wqw>
    You're right.
    That's the GUID for the DeviceClass which is WPD (WindowsPortableDevice?)
    Anyway, i'm pretty sure we can find in the WMI's what we're looking for
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  22. #22
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,416

    Re: "Devices and Drives" ... accessing them via VB6

    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  23. #23
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,416

    Re: "Devices and Drives" ... accessing them via VB6

    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  24. #24

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: "Devices and Drives" ... accessing them via VB6

    Okay, I've got what I want. Olaf, thanks for pointing me at your code in post #40 of that other thread. That got me there.

    Here's what I came up with (in a Form1):

    Code:
    
    Option Explicit
    '
    #If False Then
        Dim Item, NameSpace, Path, Items, GetFolder, Name, ParseName, Title, CopyHere
    #End If
    '
    Dim mbAlreadyActive As Boolean
    Dim mbCancel        As Boolean
    '
    
    Private Sub cmdCancel_Click()
        mbCancel = True
    End Sub
    
    Private Sub Form_Activate()
        If mbAlreadyActive Then Exit Sub
        mbAlreadyActive = True
        '
        Dim iRet                As Long
        '
        Const ShellApplication  As String = "Shell.Application"
        Dim Computer            As Object   ' The "Computer" when in Windows Explorer (in NameSpace terms).
        Const ComputerGuid      As String = "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"    ' GUID for MyComputer.
        '
        Dim DestinationFolder   As Object   ' The destination folder object in NameSpace terms.
        Const DestFolderName    As String = "\\SERVER\photos\!ElroyPhonePics"   ' MUST exist prior to running this.
        '
        Dim PhoneRootFolder     As Object   ' This is the root of the phone in NameSpace terms.
        Const WpdGuid           As String = "{6ac27878-a6fa-4155-ba85-f98f491d4f33}"    ' GUID for Windows Portable Devices.
        Dim ComputerItem        As Object   ' To scan for WPD-supporting devices (checking the proper GUID in their Path).
        '
        Dim PhonePictureFolder  As Object   ' In NameSpace terms.
        Const SubFolderForPics  As String = "Internal storage\DCIM\Camera"
        '
        Dim PhonePictureItem    As Object   ' Phone pictures in NameSpace terms.
        Dim CopyOptions         As Long
        '
        ' Make sure destination exists.
        If Not bFolderExists(DestFolderName) Then
            MsgBox "The destination folder named..." & vbCrLf & vbCrLf & _
                   DestFolderName & vbCrLf & vbCrLf & _
                   "...wasn't found.  This program will now be terminated.", , App.Title
            Unload Me
            Exit Sub
        End If
        '
        ' Instantiate our Computer and DestinationFolder objects.
        With CreateObject(ShellApplication)
            Set Computer = .NameSpace("Shell:::" & ComputerGuid)
            Set DestinationFolder = .NameSpace(DestFolderName)
        End With
        '
        ' Search for our phone.
        For Each ComputerItem In Computer.Items
            ' We just grab the first Windows Portable Device (WPD), and get out.  This assumes there's only one.
            ' USB drives will NOT count as WPDs.
            If InStr(LCase(ComputerItem.Path), WpdGuid) Then
                'Debug.Print "WPD Name"; ComputerItem.Name & vbCrLf & "WPD Path: "; ComputerItem.Path
                Set PhoneRootFolder = ComputerItem.GetFolder
                Exit For
            End If
        Next
        '
        ' If we found our phone, try to copy all the pictures.
        If IsObject(PhoneRootFolder) Then
            lblPhoneFound.Caption = "Friendly Phone Name is: " & PhoneRootFolder.Title:         lblPhoneFound.Refresh
            lblDestinationPath.Caption = "Destination: " & DestFolderName:                      lblDestinationPath.Refresh
            iRet = MsgBox("Friendly Phone Name is: " & PhoneRootFolder.Title, vbOKCancel, App.Title)
            If iRet <> vbCancel Then
                Set PhonePictureFolder = PhoneRootFolder.ParseName(SubFolderForPics).GetFolder
                CopyOptions = 4&    ' Do not display a progress dialog box.  (https://docs.microsoft.com/en-us/windows/desktop/shell/folder-copyhere)
                For Each PhonePictureItem In PhonePictureFolder.Items
                    lblCopying.Caption = "Checking/Copying: " & vbCrLf & PhonePictureItem.Name: lblCopying.Refresh
                    '
                    ' Check for cancel.
                    DoEvents
                    If mbCancel Then
                        Unload Me
                        Exit Sub
                    End If
                    '
                    ' Check to see if it already exists ... if not, copy.
                    If Not bFileExists(DestFolderName & "\" & PhonePictureItem.Name) Then
                        DestinationFolder.CopyHere PhonePictureItem, CopyOptions
                    End If
                Next
                ' The following is an alternative that would copy all the pictures without stopping.
                'DestinationFolder.CopyHere PhonePictureFolder.Items
                MsgBox "Done.", , App.Title
            End If
        Else
            MsgBox "No phone was found.", , App.Title
        End If
        '
        Unload Me
    End Sub
    
    Private Function bFileExists(fle As String) As Boolean
        On Error GoTo FileExistsError
        ' If no error then something existed.
        bFileExists = (GetAttr(fle) And vbDirectory) = 0
        Exit Function
    FileExistsError:
        bFileExists = False
    End Function
    
    Private Function bFolderExists(sDir As String) As Boolean
        Dim s As String
        s = sDir
        If Right$(s, 1) = "\" Then s = Left$(s, Len(s) - 1)
        On Error GoTo FileExistsError
        ' If no error then something existed.
        bFolderExists = ((GetAttr(s) And vbDirectory) = vbDirectory)
        Exit Function
    FileExistsError:
        bFolderExists = False
    End Function
    
    
    

    And here's a screenshot of my form:

    Name:  CameraCopy.png
Views: 2863
Size:  10.6 KB

    I figure people can work from there if they want to do something similar. I've now got a small EXE on my desktop that I can double-click any time to copy my phone pictures to my NAS box, which is precisely what I wanted.

    @Fafalone: I was quite a ways down the rabbit-hole of looking at your ucShellBrowse code before Olaf pointed out his NameSpace alternative. I actually did manage to drill-down deeper than the "Internal storage" folder of my phone with your code. Briefly, here's what was happening and what I did. When I was trying to drill into that "Internal storage" folder, it wasn't finding the siParent (IShellItem) in that situation. In other words, it could find "Internal storage" as the siChild (IShellItem) but not when it was suppose to be the siParent. Therefore, just to patch it up and make it work, I created an IShellItem at the module level, and saved the siChild of the "XT1080" parent (which was this "Internal storage" folder). Then, when the siParent wasn't found when drilling down, I just forced-Set it to this saved module level IShellItem variable.

    So, if we can get the "Internal storage" folder as a child, shouldn't we be able to get it as a parent? Maybe that will be a clue for you to "smarten up" your UC.

    --------------------

    Ok, I'm marking this one as resolved. Y'all are welcome to continue discussing the topic if you like. Again, all I wanted was a very easy way to backup the pictures from my phone.

    Y'all Take Care,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  25. #25
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,416

    Re: [RESOLVED] "Devices and Drives" ... accessing them via VB6

    Code:
    Sub RevealYourSecrets()
    Dim oShell        As Object
    Dim oSourceFolder As Object
        
         Set oShell = CreateObject("Shell.Application")
         Set oSourceFolder = oShell.BrowseForFolder(0, "Please select the folder.", 0, "")
         Debug.Print "Folder name: " & oSourceFolder.Title
         Debug.Print "Path: " & oSourceFolder.Self.Path
    
    End Sub
    Returns:
    Folder name: Zvoni's iPhone
    Path: ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_05ac&pid_12a8&mi_00#0#{6ac27878-a6fa-4155-ba85-f98f491d4f33}
    And there we have it.

    The thing is: That GUID can also be found in the Registry

    This bears the Question: Can we use FindFirstFile (and its sisters) to traverse the phone?
    Especially if we remember that a harddrive (which has a Driveletter e.g. C:\) also basically has an Address like
    \\\?\ide#disksomecrypticsymbols
    or a standard USB-Drive (DriveLetter E:\)
    \\\?\usbstor#somecrypticsymbols
    Last edited by Zvoni; Mar 20th, 2019 at 08:15 AM.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  26. #26

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: [RESOLVED] "Devices and Drives" ... accessing them via VB6

    @Fafalone:

    Be sure to read my paragraph to you in post #24.

    I'm using your Demo2 project for testing. When I just fire it up, here's the Debug output (which I don't think helps much):

    Code:
    I decided to delete this as it had a bit of personal information in it, and I don't think FaFalone needed it.

    And then, (after clearing Immediate) I explore to my XT1080 phone with your ComboBox. And then I get:

    Code:
    [BR][2019-03-20 08:02:15] CBD->Closeup
    [BR][2019-03-20 08:02:15] CBD->SelChange 
    [BR][2019-03-20 08:02:15] CBWndProc::GetCurSel=9
    [BR][2019-03-20 08:02:15] DirNavigate item=9,sup=False
    [BR][2019-03-20 08:02:15] LVLoadFolder ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_22b8&pid_2e68&mi_00#6&289fbc07&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33},m_sCurPath=C:\Users\Elroy\Desktop\!TempDownload\New folder (2)\Demo2,sPrevPath=,GrpMode=0
    [BR][2019-03-20 08:02:16] PathAttrib=SFGAO_CANLINK,SFGAO_CANRENAME,SFGAO_FOLDER,SFGAO_HASPROPSHEET,SFGAO_HASSUBFOLDER,SFGAO_STORAGEANCESTOR,
    [BR][2019-03-20 08:02:16] pEnum succeeded
    [BR][2019-03-20 08:02:16] ProcessColumns pathidx=9
    [BR][2019-03-20 08:02:16] ub=35last=C:\Users\Elroy\Desktop\!TempDownload\New folder (2)\Demo2,cur=::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_22b8&pid_2e68&mi_00#6&289fbc07&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}
    [BR][2019-03-20 08:02:16] SetColumns(9)=
    [BR][2019-03-20 08:02:16] SetColumns->Finished reconcile
    [BR][2019-03-20 08:02:16] SetColumns->lColCnt=1,set=0
    [BR][2019-03-20 08:02:16] LVLoadFolder returned from ProcessColumns
    [BR][2019-03-20 08:02:16] idxCB=9,lp=9
    [BR][2019-03-20 08:02:16] Loaded 0 files and 1 folders
    [BR][2019-03-20 08:02:16] MonitorPidl=106234120 ForPath=::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_22b8&pid_2e68&mi_00#6&289fbc07&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}
    [BR][2019-03-20 08:02:16] C:\Users\Elroy\Desktop\!TempDownload\New folder (2)\Demo2
    [BR][2019-03-20 08:02:16] ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_22b8&pid_2e68&mi_00#6&289fbc07&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}<---nHistIdx

    And here's a pic of your Demo2 at that point:

    Attachment 166769

    And then, (again clearing Immediate) I double-click that "Internal storage" folder, and get:

    Code:
    [BR][2019-03-20 08:04:16] No IShellItem
    [BR][2019-03-20 08:04:16] Set IC flag = TRUE, item=0
    [BR][2019-03-20 08:04:16] LVSetSelection full path=::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_22b8&pid_2e68&mi_00#6&289fbc07&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\SID-{10001,,27357200384}
    [BR][2019-03-20 08:04:16] NM_CLICK on ucWndProc
    [BR][2019-03-20 08:04:16] LVItemClick 0
    [BR][2019-03-20 08:04:16] Got dblclk/ret
    [BR][2019-03-20 08:04:17] LVSetSelection full path=::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_22b8&pid_2e68&mi_00#6&289fbc07&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\SID-{10001,,27357200384}
    [BR][2019-03-20 08:04:17] LVDoubleClick idx=0,lp=0,file=Internal storage
    [BR][2019-03-20 08:04:17] Failed to get siItem
    [BR][2019-03-20 08:04:17] LVDoubleClick.OpenFolder
    [BR][2019-03-20 08:04:17] sFull=::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_22b8&pid_2e68&mi_00#6&289fbc07&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\SID-{10001,,27357200384}
    [BR][2019-03-20 08:04:17] AddStandardFSItem::Using alt icon method
    [BR][2019-03-20 08:04:17] LVLoadFolder ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_22b8&pid_2e68&mi_00#6&289fbc07&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\SID-{10001,,27357200384},m_sCurPath=::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_22b8&pid_2e68&mi_00#6&289fbc07&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33},sPrevPath=C:\Users\Elroy\Desktop\!TempDownload\New folder (2)\Demo2,GrpMode=0
    [BR][2019-03-20 08:04:17] Failed to get siParent
    [BR][2019-03-20 08:04:17] Loaded 0 files and 0 folders
    [BR][2019-03-20 08:04:17] MonitorPidl=0 ForPath=::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_22b8&pid_2e68&mi_00#6&289fbc07&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\SID-{10001,,27357200384}
    [BR][2019-03-20 08:04:17] C:\Users\Elroy\Desktop\!TempDownload\New folder (2)\Demo2
    [BR][2019-03-20 08:04:17] ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_22b8&pid_2e68&mi_00#6&289fbc07&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}
    [BR][2019-03-20 08:04:17] ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_22b8&pid_2e68&mi_00#6&289fbc07&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\SID-{10001,,27357200384}<---nHistIdx

    At this point, I can't drill-down any deeper. Here's a screenshot of Demo2 at this point:

    Attachment 166771

    Again, like I stated above, I was able to save the "child" when I was at the XT1080 level, and then use it to patch up the "parent" when I tried to drill-down, and sort of get it going. But I'll leave it to you to make a more permanent fix.

    Take Care,
    Elroy
    Last edited by Elroy; Mar 21st, 2019 at 07:41 AM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  27. #27
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: [RESOLVED] "Devices and Drives" ... accessing them via VB6

    Elroy's and Zvoni's ideas can be combined to filter on objItem.PNPClass="WPD" and to construct path to phone's namespace based on objItem.DeviceID with something like this:

    sPath = "::" & ComputerGuid & "\\\?" & LCase(Replace(objItem.DeviceID, "\", "#") & "#" & WpdGuid)

    Then under this phone namespace there are the storage items (e.g. Internal, Card, etc.) w/ DCIM root folder and under it you get the actual 100APPLE, 101APPLE, etc. image/video containing folders.

    Here is the code

    thinBasic Code:
    1. ' Enjoy VBScript w/ no Option Explicit
    2. Const ComputerGuid = "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
    3. Const WpdGuid  = "{6ac27878-a6fa-4155-ba85-f98f491d4f33}"
    4. Set WshShell = CreateObject("Shell.Application")
    5.  
    6. strComputer = "."
    7. Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!" & strComputer & "\root\cimv2")
    8. Set colItems = objWMIService.ExecQuery("Select * from Win32_PNPEntity WHERE PNPClass='WPD'")
    9. For Each objItem In colItems
    10.   WScript.echo "DeviceID: " & objItem.DeviceID
    11.   For Each v In objItem.Properties_
    12.     If IsArray(v.Value) Then
    13.       WScript.echo "  " & v.Name & "=[" & Join(v.Value, ", ") & "]"
    14.     ElseIf LenB(C_Str(v.Value)) <> 0 Then
    15.       WScript.echo "  " & v.Name & "=" & C_Str(v.Value)
    16.     End If
    17.   Next
    18.   sPath = "::" & ComputerGuid & "\\\?" & LCase(Replace(objItem.DeviceID, "\", "#") & "#" & WpdGuid)
    19.   Set oPhone = WshShell.NameSpace(sPath)
    20.   WScript.echo oPhone.Title
    21.   WScript.echo sPath
    22.   For Each oStorage In oPhone.Items
    23.     WScript.echo "  " & oStorage.Name
    24.     WScript.echo "  " & oStorage.Path
    25.   Next
    26. Next
    27.  
    28. Private Function C_Str(v)
    29.   On Error Resume Next
    30.   C_Str = CStr(v)
    31. End Function
    . . . to get something like this

    Code:
    DeviceID: USB\VID_05AC&PID_12A8&MI_00\0
      Caption=Apple iPhone
      ClassGuid={eec5ad98-8080-425f-922a-dabf3de3f69a}
      CompatibleID=[USB\Class_06&SubClass_01&Prot_01, USB\Class_06&SubClass_01, USB\Class_06]
      ConfigManagerErrorCode=0
      ConfigManagerUserConfig=False
      CreationClassName=Win32_PnPEntity
      Description=Apple iPhone
      DeviceID=USB\VID_05AC&PID_12A8&MI_00\0
      HardwareID=[USB\VID_05AC&PID_12A8&REV_0903&MI_00, USB\VID_05AC&PID_12A8&MI_00]
      Manufacturer=Apple Inc.
      Name=Apple iPhone
      PNPClass=WPD
      PNPDeviceID=USB\VID_05AC&PID_12A8&MI_00\0
      Present=True
      Service=WUDFWpdMtp
      Status=OK
      SystemCreationClassName=Win32_ComputerSystem
      SystemName=********-PC
    Wqw iPhone
    ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_05ac&pid_12a8&mi_00#0#{6ac27878-a6fa-4155-ba85-f98f491d4f33}
      Internal Storage
      ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_05ac&pid_12a8&mi_00#0#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\SID-{10004,Internal Storage,128000000000}
    cheers,
    </wqw>

  28. #28
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,647

    Re: [RESOLVED] "Devices and Drives" ... accessing them via VB6

    Thanks Elroy, I see what's going on; not the first time there's been an issue like that, guess the existing fallback didn't catch it. I'll have to grab a few more phones as I still don't understand the difference between your 'Internal storage' and mine... or perhaps it's a Windows 10 thing will check that too.

  29. #29
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,416

    Re: [RESOLVED] "Devices and Drives" ... accessing them via VB6

    Probably, because the Internal Storage of an iPhone is again a "Device" for an iPhone itself
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  30. #30
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,647

    Re: [RESOLVED] "Devices and Drives" ... accessing them via VB6

    Actually just confirmed that the issue is because of Windows 10. Hooked my phone up to my laptop and got the same result as Elroy, loads the root folder, but doesn't load the contents of 'Internal storage'. Will get a fix out soon.

  31. #31

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: [RESOLVED] "Devices and Drives" ... accessing them via VB6

    Quote Originally Posted by fafalone View Post
    Thanks Elroy, I see what's going on; not the first time there's been an issue like that, guess the existing fallback didn't catch it. I'll have to grab a few more phones as I still don't understand the difference between your 'Internal storage' and mine... or perhaps it's a Windows 10 thing will check that too.
    Well, since your phone is now doing it too, you probably don't need me to test. But send me a PM when you get it fixed and I'd be delighted to test it on my phone. At that point, I'd probably just report my results over in your CodeBank thread.

    Take Care,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width