Just on the off chance anyone around here is familiar with typelibs and interfaces...
All the types are correctly defined (long, uuid, IBindCtx, IShellFolder)... because they're all parts of working implementations from the same typelib of IShellFolder et al. that I use in my project. I know maybe psfParent should be explicitly declared as IShellFolder, but MSDN says I can use either that or pass a fully-qualified pidl, which is what I was doing. The typelib compiles without error.
SHCreateShellItem is returning S_OK but fails to create the object (isi Is Nothing = True). If I pass a valid IShellFolder, VB crashes.
My eventual goal is getting to IThumbnailProvider, which I can't bind to from IShellFolder2.
For reference, this is the source from shodjidl.idl I translated from:
Code:
[
odl,
uuid(43826D1E-E718-42EE-BC55-A1E261C37BFE)
]
interface IShellItem : stdole.IUnknown {
HRESULT BindToHandler(
[in] IBindCtx *pbc,
[in] UUID rbhid,
[in] UUID riid,
[out] void *ppvOut);
HRESULT Compare(
[in] IShellItem *psi,
[in] LONG hint,
[out, retval] LONG *piOrder);
HRESULT GetAttributes(
[in] SFGAO_Flags sfgaoMask,
[out, retval] SFGAO_Flags *psfgaoAttribs);
HRESULT GetDisplayName(
[in] SIGDN sigdnName,
[out, retval] LPWSTR *ppszName);
HRESULT GetParent(
[out] IShellItem *ppsi);
};
Public Declare Function SHCreateShellItem Lib "shell32" (ByVal pidlParent As Long, psfParent As Any, pidl As Long, ppsi As IShellItem)
Dim hRes As Long
Dim isi As IShellItem
hRes = SHCreateShellItem(0, ByVal 0&, ByVal GetPIDLFromPath(Me.hwnd, "C:\temp"), isi)
'lpw = isi.GetDisplayName(0)
n = isi.GetAttributes(SFGAO_CANRENAME Or SFGAO_CANDELETE)
MsgBox hRes & "|||" & CStr(n)
SHCreateShellItem is returning S_OK but fails to create the object (isi Is Nothing = True). If I pass a valid IShellFolder, VB crashes.
My eventual goal is getting to IThumbnailProvider, which I can't bind to from IShellFolder2.
For reference, this is the source from shodjidl.idl I translated from:
Code:
cpp_quote(" HRESULT (WINAPI *BindToHandler)(IShellItem *This,IBindCtx *pbc,REFGUID rbhid,REFIID riid,void **ppvOut);")
cpp_quote(" HRESULT (WINAPI *GetParent)(IShellItem *This,IShellItem **ppsi);")
cpp_quote(" HRESULT (WINAPI *GetDisplayName)(IShellItem *This,SIGDN sigdnName,LPOLESTR *ppszName);")
cpp_quote(" HRESULT (WINAPI *GetAttributes)(IShellItem *This,SFGAOF sfgaoMask,SFGAOF *psfgaoAttribs);")
cpp_quote(" HRESULT (WINAPI *Compare)(IShellItem *This,IShellItem *psi,SICHINTF hint,int *piOrder);")