Unable to get IFileSystemBindData

Windows specific forum
Everything
Enthusiast
Enthusiast
Posts: 225
Joined: Sat Jul 07, 2018 6:50 pm

Unable to get IFileSystemBindData

Post by Everything »

Please tell me how to get a pointer to the IFileSystemBindData interface.
I'm clearly doing something wrong.

Code: Select all

EnableExplicit

Global Desktop.IShellFolder
Global *PIDL
Global TestFile$     = "X:\New.txt"


Procedure do()
    
    Protected strBuf.s = Space(#MAX_PATH)

    Protected w32fd.WIN32_FIND_DATA
    #GetFileExInfoStandard = 0
    If GetFileAttributesEx_(@TestFile$, #GetFileExInfoStandard, @w32fd) = 0
        Debug "GetFileAttributesEx err" : End
    EndIf
    
    
    ;------------------------------------------------------------------------------------------------------------
    ; problematic code
    ;------------------------------------------------------------------------------------------------------------
    Protected IUnknown.IUnknown
    If Not Desktop\QueryInterface(?IID_IUnknown, @IUnknown) = #S_OK
        Debug "QueryInterface 1 err" : End
    EndIf 
    Debug Hex(IUnknown) 
    
    Protected IFileSystemBindData.IFileSystemBindData
    If Not IUnknown\QueryInterface(?IID_IFileSystemBindData, @IFileSystemBindData) = #S_OK
        Debug "QueryInterface 2 err" : End
    EndIf 
    Debug Hex(IFileSystemBindData)
    IFileSystemBindData\SetFindData(@w32fd)
    ;------------------------------------------------------------------------------------------------------------
    
    
    Protected IBindCtx.IBindCtx
    If Not CreateBindCtx_(0, @IBindCtx) = #S_OK
        Debug "CreateBindCtx err"  : End
    EndIf

    Structure BIND_OPTS
        cbStruct.l             ; The size of this structure, in bytes
        grfFlags.l             ; 
        grfMode.l              ;
        dwTickCountDeadline.l  ; limit the execution time of an operation when speed is of primary importance
    EndStructure
    Protected bo.BIND_OPTS
    bo\cbStruct = SizeOf(BIND_OPTS)
    bo\grfMode  = $00001000 ; #STGM_CREATE
    If Not IBindCtx\SetBindOptions(@bo) = #S_OK : Debug "SetBindOptions err" : End : EndIf
    
    
    #STR_FILE_SYS_BIND_DATA = "File System Bind Data"
    If Not IBindCtx\RegisterObjectParam(#STR_FILE_SYS_BIND_DATA, @IFileSystemBindData) = #S_OK : Debug "SetBindOptions err" : End : EndIf 
    

    If Desktop\ParseDisplayName(#Null, @IBindCtx, TestFile$, #Null, @*PIDL, #Null) = #S_OK 
        Debug "PIDL Size: "+Str(ILGetSize_(@*PIDL))
    EndIf  

    If SHGetPathFromIDList_(*PIDL, @strBuf) = 0
        Debug "SHGetPathFromIDList fail"
    EndIf    
    Debug strBuf
    
    CoTaskMemFree_(*PIDL)
    
EndProcedure


OleInitialize_(0)
If Not SHGetDesktopFolder_(@Desktop.IShellFolder) = #S_OK
    Debug "SHGetDesktopFolder err" : End
EndIf 

If OpenWindow(0, 0, 0, 100, 100, "", #PB_Window_SystemMenu)
    Global hwnd = WindowID(0)
EndIf 
do()

Repeat
    Define Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Desktop\Release()


DataSection 

  CompilerIf Not Defined(IID_IUnknown, #PB_Label)
    IID_IUnknown:   ; {00000000-0000-0000-C000-000000000046}
      Data.l $00000000
      Data.w $0000,$0000
      Data.b $C0,$00,$00,$00,$00,$00,$00,$46 
  CompilerEndIf
  
  CompilerIf Not Defined(IID_IFileSystemBindData, #PB_Label)
    IID_IFileSystemBindData: ; {01E18D10-4D8B-11D2-855D-006008059367}
      Data.l $01E18D10
      Data.w $4D8B,$11D2
      Data.b $85,$5D,$00,$60,$08,$05,$93,$67
  CompilerEndIf

EndDataSection