J'essaye de porter le code dans this article à VB6, mais j'éprouve l'écrasement. Je suis assez sûr que mon erreur est dans mon appel à SHBindToParent
(MSDN entry) depuis SHParseDisplayName
renvoie 0 (S_OK
) et ppidl
est en cours de définition. J'avoue que mon mécanisme de réglage du riid (j'ai utilisé un type équivalent, un UUID
) est assez moche, mais je pense qu'il est plus probable que je fasse quelque chose de mal avec psf
.Comment puis-je savoir qu'un répertoire est le bac de recyclage dans VB6?
Private Declare Function SHParseDisplayName Lib "shell32" (ByVal pszName As Long, ByVal IBindCtx As Long, ByRef ppidl As ITEMIDLIST, sfgaoIn As Long, sfgaoOut As Long) As Long
Private Declare Function SHBindToParent Lib "shell32" (ByVal ppidl As Long, ByRef shellguid As UUID, ByVal psf As Long, ByVal ppidlLast As Long) As Long
Private Sub Main()
Dim hr As Long
Dim ppidl As ITEMIDLIST
Dim topo As String
Dim psf As IShellFolder
Dim pidlChild As ITEMIDLIST
topo = "c:\tmp\" '"//This VB comment is here to make SO's rendering look nicer.
Dim iid_shellfolder As UUID
iid_shellfolder.Data1 = 136422
iid_shellfolder.Data2 = 0
iid_shellfolder.Data3 = 0
iid_shellfolder.Data4(0) = 192
iid_shellfolder.Data4(7) = 70
hr = SHParseDisplayName(StrPtr(topo), 0, ppidl, 0, 0)
Debug.Print hr, Hex(hr)
hr = SHBindToParent(VarPtr(ppidl), iid_shellfolder, VarPtr(psf), VarPtr(pidlChild)) 'Crashes here
End Sub
(Le code C++ cette balise fait référence est référencé dans la question) – Brian