EnableExplicit

XIncludeFile #IncludePath + "FolderContextMenuEx.pb"

Procedure FolderContextMenu(hWnd.i, xDirOrFile.s)
  Define.i xLong1
  Define.i xLong2
  Define *DirW
  Define *FilW
  
  Repeat
    xLong2 = xLong1
    xLong1 = FindString(xDirOrFile, "\", xLong2 + 1)
    Until xLong1 = 0

  If xLong2
    *DirW = LocalAlloc_(0, (Len(xDirOrFile) + 1) << 1)
    If *DirW
      PokeS(*DirW, xDirOrFile, -1, #PB_Unicode)
      *FilW = *DirW + (xLong2 << 1)
      PokeW(*FilW - 2, 0)
      FolderContextMenuEx(hWnd, *DirW, *FilW)
      LocalFree_(*DirW)
      EndIf
    EndIf
  EndProcedure
;
;If OpenWindow(0, 0, 0, 320, 100,"Test")
;  FolderContextMenu(WindowID(0), "D:\DEV\Software\CleanupEmptyDirs\shared")
;  EndIf
; IDE Options = PureBasic 5.11 (Windows - x64)
; CursorPosition = 26
; FirstLine = 3
; Folding = -
; EnableXP