[fpc-pascal] wrong definition of SHCreateStdEnumFmtEtc() in unit shlobl

Bernd prof7bit at gmail.com
Tue Aug 21 21:31:31 CEST 2012


While implementing an OLE drag&drop source I stumbled over this:

shlobj.pp, Line 2444

  function SHCreateStdEnumFmtEtc(cfmt:UINT; afmt:array of TFORMATETC;
var ppenumFormatEtc:IEnumFORMATETC):HRESULT;StdCall;external
External_library name 'SHCreateStdEnumFmtEtc';

this must be wrong. I got nothing but crashes until I translated it
myself as follows:

  function SHCreateStdEnumFmtEtc(cfmt:UINT; afmt: PFORMATETC; var
ppenumFormatEtc:IEnumFORMATETC):HRESULT;StdCall;external
External_library name 'SHCreateStdEnumFmtEtc';

and now my program works. Its the array of TFORMATETC, open arrays
implicitly include a length parameter, don't they? If this should work
with an open array then the first parameter (the count) would need to
be removed, wouldn't it?

The original definition is:

HRESULT SHCreateStdEnumFmtEtc(
  _In_   UINT cfmt,
  const FORMATETC afmt[],
  _Out_  IEnumFORMATETC **ppenumFormatEtc
);
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762148%28v=vs.85%29.aspx



More information about the fpc-pascal mailing list