home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d123456 / DFS.ZIP / ShellFix.txt < prev    next >
Text File  |  2000-03-19  |  6KB  |  131 lines

  1. The Bugs in SHLOBJ.PAS and How to Fix Them.
  2.  
  3.  
  4. Note: This only applies to Delphi 2.  Delphi 3 has fixed all of these bugs.
  5.  
  6. There are currently available two units that provide access to the
  7. Win95/NT 4.0 Shell Namesapce API.  Unfortunately, both of them have errors in
  8. several of the function declarations.  To use this component you will have to
  9. correct these errors.  You can do this in one of three ways.
  10.  
  11. 1) Get Pat Ritchey's ShellObj unit and make the modifications to it.
  12. 2) Directly modify Borland's ShlObj.pas file in \Delphi\Source\RTL\Win\.
  13. 3) Copy Borland's ShlObj.pas file to a directory in your Library Path
  14.    (Tools | Options | Library Path) and modify that one.
  15.  
  16. I prefer and suggest option 3.  Pat will not be supporting ShellObj now that
  17. Borland is officially distributing ShlObj, and I don't like modifing RTL code
  18. directly.  It makes applying patches a royal pain because I always forget to
  19. copy the original back over it before patching.
  20.  
  21. Rename your modified copy to MyShlObj.pas (don't forget the UNIT clause name),
  22. unless you directly modified the RTL source.  If you did that, make sure you
  23. recompile it and update the \Delphi\Lib\ShlObj.dcu file and change the USES
  24. clause in SystemTreeView.pas from MyShlObj to ShlObj.
  25.  
  26. 1) For ShellObj unit users ONLY, do the following steps (Delphi 2.01 ShlObj
  27.    users should skip to step 2):
  28.  
  29.    a) Search for the BindToObject declaration and change it to:
  30.      // BDS.  riid should have been a pointer to a TIID.
  31.      function BindToObject(pidl:PITEMIDLIST; pbcReserved:pointer;
  32.                           const riid:TIID; var ppvOut:pointer):HResult; virtual; stdcall; abstract;
  33.  
  34.    b) Change GetDisplayNameOf to:
  35.      // Changed lpName to a var parameter for compatiblity with v2.01 SHLOBJ.
  36.      function GetDisplayNameOf(pidl: PITEMIDLIST; uFlags:DWORD;
  37.                                var lpName: TSTRRET):HResult; virtual; stdcall; abstract;
  38.  
  39.    c) Change the name of the type 'BFFCallBack' to 'TFNBFFCallBack'
  40.       everywhere it occurs.  This is for compatibility with ShlObj.
  41.  
  42.    d) Change the SHBrowseForFolder to:
  43.      // Changed lpbi to var param for SHLOBJ compatibility.
  44.      function SHBrowseForFolder(var lpbi:TBROWSEINFO):PItemIDList; stdcall;
  45.  
  46.    e) Change InvokeCommand to:
  47.      // Changed lpici to var param for SHLOBJ compatibility.
  48.      function InvokeCommand(var lpici: TCMInvokeCommandInfo): HResult; virtual; stdcall; abstract;
  49.  
  50.    f) Search for SHGetMalloc declaration and change it to:
  51.      // Needs the stdcall directive
  52.      function SHGetMalloc(var ppMalloc: IMalloc): HResult; stdcall;
  53.  
  54.    g) Search for the SHGetMalloc implementation and change to:
  55.      // That was not supposed to go into effect until next windows release according to
  56.      // Microsoft SHLOBJ.H code comments.  Back to what it is supposed to be.
  57.      function SHGetMalloc; external shell32 name 'SHGetMalloc';
  58.  
  59.  
  60. 2) Change BindToStorage to:
  61.  
  62.     // BDS.  riid should have been a pointer to a TIID.
  63.     function BindToStorage(pidl:PITEMIDLIST; pbcReserved:pointer;
  64.                            const riid:TIID; var ppvObj:pointer):HResult; virtual; stdcall; abstract;
  65.  
  66. 3) Change CreateViewObject to:
  67.  
  68.     // BDS.  riid should have been a pointer to a TIID.
  69.     function CreateViewObject(hwndOwner:HWND; const riid:TIID;
  70.                               var ppvOut: pointer):HResult; virtual; stdcall; abstract;
  71.  
  72. 4) Change GetUIObjectOf to:
  73.  
  74.     // BDS.  riid should have been a pointer to a TIID.
  75.     // BDS.  SHLOBJ: prgfInOut is always NIL, so a VAR parameter makes no sense.
  76.     function GetUIObjectOf(hwndOwner:HWND; cidl:UINT; var apidl: PItemIDList;
  77.                            const riid:TIID; prgfInOut: PUINT; var ppvOut:pointer):HResult; virtual; stdcall; abstract;
  78.  
  79. 5) This stuff is completely missing:
  80.    a) Add this block right before the "implementation" section:
  81.  
  82. { SHGetDataFromIDList }
  83.  
  84. const
  85.   SHGDFIL_FINDDATA       = 1;
  86.   SHGDFIL_NETRESOURCE    = 2;
  87.   SHGDFIL_DESCRIPTIONID  = 3;
  88.  
  89.   SHDID_ROOT_REGITEM          = 1;
  90.   SHDID_FS_FILE               = 2;
  91.   SHDID_FS_DIRECTORY          = 3;
  92.   SHDID_FS_OTHER              = 4;
  93.   SHDID_COMPUTER_DRIVE35      = 5;
  94.   SHDID_COMPUTER_DRIVE525     = 6;
  95.   SHDID_COMPUTER_REMOVABLE    = 7;
  96.   SHDID_COMPUTER_FIXED        = 8;
  97.   SHDID_COMPUTER_NETDRIVE     = 9;
  98.   SHDID_COMPUTER_CDROM        = 10;
  99.   SHDID_COMPUTER_RAMDISK      = 11;
  100.   SHDID_COMPUTER_OTHER        = 12;
  101.   SHDID_NET_DOMAIN            = 13;
  102.   SHDID_NET_SERVER            = 14;
  103.   SHDID_NET_SHARE             = 15;
  104.   SHDID_NET_RESTOFNET         = 16;
  105.   SHDID_NET_OTHER             = 17;
  106.  
  107. type TSHDescriptionID = packed record
  108.   dwDescriptionId: DWORD;
  109.   clsid: TGUID; {???}
  110. end;
  111.  
  112. function SHGetDataFromIDListA(const psf: IShellFolder; pidl: PItemIDList;
  113.                               nFormat: integer; pv: pointer; cb: integer): HResult; stdcall;
  114. function SHGetDataFromIDListW(const psf: IShellFolder; pidl: PItemIDList;
  115.                               nFormat: integer; pv: pointer; cb: integer): HResult; stdcall;
  116. function SHGetDataFromIDList(const psf: IShellFolder; pidl: PItemIDList;
  117.                              nFormat: integer; pv: pointer; cb: integer): HResult; stdcall;
  118.  
  119.   b) Add this somewhere in the implementation section:
  120.  
  121. function SHGetDataFromIDListA; external shell32 name 'SHGetDataFromIDListA';
  122. function SHGetDataFromIDListW; external shell32 name 'SHGetDataFromIDListW';
  123. function SHGetDataFromIDList; external shell32 name 'SHGetDataFromIDListA';
  124.  
  125.  
  126.  
  127. Regards,
  128. Brad Stowers
  129. bstowers@pobox.com
  130. May 18, 1997
  131.