-
Mar 19th, 2019, 10:38 AM
#1
[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:
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.
-
Mar 19th, 2019, 10:54 AM
#2
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":
And then also, under events, there's a "Device migrated" event where I can get a GUID value:
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.
-
Mar 19th, 2019, 11:07 AM
#3
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>
-
Mar 19th, 2019, 11:47 AM
#4
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.
-
Mar 19th, 2019, 12:00 PM
#5
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.
-
Mar 19th, 2019, 12:40 PM
#6
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.
-
Mar 19th, 2019, 02:01 PM
#7
Fanatic Member
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".
-
Mar 19th, 2019, 02:19 PM
#8
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
-
Mar 19th, 2019, 02:43 PM
#9
Hyperactive Member
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.
-
Mar 19th, 2019, 03:26 PM
#10
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:
Originally Posted by fafalone
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.
-
Mar 19th, 2019, 04:49 PM
#11
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:
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:
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.
-
Mar 19th, 2019, 06:09 PM
#12
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.
-
Mar 19th, 2019, 07:02 PM
#13
Hyperactive Member
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
-
Mar 19th, 2019, 07:22 PM
#14
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.
-
Mar 19th, 2019, 07:36 PM
#15
Re: "Devices and Drives" ... accessing them via VB6
Originally Posted by Elroy
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
-
Mar 20th, 2019, 02:04 AM
#16
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
-
Mar 20th, 2019, 02:21 AM
#17
Re: "Devices and Drives" ... accessing them via VB6
Originally Posted by Schmidt
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>
-
Mar 20th, 2019, 03:22 AM
#18
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.
-
Mar 20th, 2019, 03:56 AM
#19
Re: "Devices and Drives" ... accessing them via VB6
Originally Posted by wqweto
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
-
Mar 20th, 2019, 04:22 AM
#20
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>
Last edited by wqweto; Mar 20th, 2019 at 04:26 AM.
-
Mar 20th, 2019, 04:53 AM
#21
Re: "Devices and Drives" ... accessing them via VB6
Originally Posted by wqweto
@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
-
Mar 20th, 2019, 07:35 AM
#22
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
-
Mar 20th, 2019, 07:42 AM
#23
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
-
Mar 20th, 2019, 07:58 AM
#24
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:
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.
-
Mar 20th, 2019, 08:09 AM
#25
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
-
Mar 20th, 2019, 08:09 AM
#26
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.
-
Mar 20th, 2019, 12:57 PM
#27
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:
' Enjoy VBScript w/ no Option Explicit Const ComputerGuid = "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" Const WpdGuid = "{6ac27878-a6fa-4155-ba85-f98f491d4f33}" Set WshShell = CreateObject("Shell.Application") strComputer = "." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_PNPEntity WHERE PNPClass='WPD'") For Each objItem In colItems WScript.echo "DeviceID: " & objItem.DeviceID For Each v In objItem.Properties_ If IsArray(v.Value) Then WScript.echo " " & v.Name & "=[" & Join(v.Value, ", ") & "]" ElseIf LenB(C_Str(v.Value)) <> 0 Then WScript.echo " " & v.Name & "=" & C_Str(v.Value) End If Next sPath = "::" & ComputerGuid & "\\\?" & LCase(Replace(objItem.DeviceID, "\", "#") & "#" & WpdGuid) Set oPhone = WshShell.NameSpace(sPath) WScript.echo oPhone.Title WScript.echo sPath For Each oStorage In oPhone.Items WScript.echo " " & oStorage.Name WScript.echo " " & oStorage.Path Next Next Private Function C_Str(v) On Error Resume Next C_Str = CStr(v) 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>
Last edited by wqweto; Mar 20th, 2019 at 01:02 PM.
-
Mar 21st, 2019, 12:28 AM
#28
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.
-
Mar 21st, 2019, 01:18 AM
#29
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
-
Mar 21st, 2019, 04:15 AM
#30
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.
-
Mar 21st, 2019, 07:36 AM
#31
Re: [RESOLVED] "Devices and Drives" ... accessing them via VB6
Originally Posted by fafalone
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|