Recent

Author Topic: IMoniker possible error in definition  (Read 11430 times)

440bx

  • Hero Member
  • *****
  • Posts: 4478
IMoniker possible error in definition
« on: April 03, 2024, 11:19:15 am »
Hello,

the IMoniker interface in ActiveX is defined as:
Code: Pascal  [Select][+][-]
  1.     PIMoniker = ^IMoniker;
  2.     IMoniker = Interface (IPersistStream)
  3.       ['{0000000f-0000-0000-C000-000000000046}']
  4.       Function BindToObject (const pbc:IBindCtx;const mktoleft:IMoniker; const RiidResult:TIID;Out vresult):HResult;StdCall;
  5. //    Function RemoteBindToObject (const pbc:IBindCtx;const mktoleft:IMoniker;const RiidResult:TIID;Out vresult):HResult;StdCall;
  6.       Function BindToStorage(Const Pbc:IBindCtx;Const mktoLeft:IMoniker; const Riid:TIID;Out vobj):HResult; StdCall;
  7. //    Function RemoteBindToStorage(Const Pbc:IBindCtx;Const mktoLeft:IMoniker;const Riid:TIID;Out vobj):HResult; StdCall;
  8.       Function Reduce (const pbc:IBindCtx; dwReduceHowFar:DWord; mktoLeft: PIMoniker; Out mkReduced:IMoniker):HResult; StdCall;
  9.       Function ComposeWith(Const MkRight:IMoniker;fOnlyIfNotGeneric:BOOL; OUT mkComposite:IMoniker):HResult; StdCall;
  10.       Function Enum(fForward:Bool;Out enumMoniker:IEnumMoniker):HResult;StdCall;
  11.       Function IsEqual(Const mkOtherMoniker:IMoniker):HResult;StdCall;
  12.       Function Hash   (Out dwHash:Dword):HResult;StdCall;
  13.       Function IsRunning(Const bc:IBindCtx;Const MkToLeft:IMoniker;Const mknewlyRunning:IMoniker):HResult;StdCall;
  14.       Function GetTimeOfLastChange(Const bc:IBindCtx;Const mkToLeft:IMoniker; out ft : FileTime):HResult; StdCall;
  15.       Function Inverse(out mk : IMoniker):HResult; StdCall;
  16.  
  17.  
  18.       Function CommonPrefixWith (Const mkOther:IMoniker):HResult; StdCall;
  19.  
  20.  
  21.       Function RelativePathTo(Const mkother:IMoniker; Out mkRelPath : IMoniker):HResult;StdCall;
  22.       Function GetDisplayName(Const bc:IBindCtx;const mktoleft:IMoniker;Out szDisplayName: pOleStr):HResult; StdCall;
  23.       Function ParseDisplayName(Const bc:IBindCtx;Const mkToLeft:IMoniker;szDisplayName:POleStr;out cheaten:ULong;out mkOut:IMoniker):HResult; StdCall;
  24.       Function IsSystemMoniker(Out dwMkSys:DWord):HResult;StdCall;
  25.       End;
  26.  
Note the definition of the CommonPrefixWith method has only one parameter.

the C++ interface in objidl.h defines it as:
Code: C  [Select][+][-]
  1.     MIDL_INTERFACE("0000000f-0000-0000-C000-000000000046")
  2.     IMoniker : public IPersistStream
  3.     {
  4.     public:
  5.         virtual /* [local] */ HRESULT STDMETHODCALLTYPE BindToObject(
  6.             /* [annotation][unique][in] */
  7.             _In_  IBindCtx *pbc,
  8.             /* [annotation][unique][in] */
  9.             _In_opt_  IMoniker *pmkToLeft,
  10.             /* [annotation][in] */
  11.             _In_  REFIID riidResult,
  12.             /* [annotation][iid_is][out] */
  13.             _Outptr_  void **ppvResult) = 0;
  14.        
  15.         virtual /* [local] */ HRESULT STDMETHODCALLTYPE BindToStorage(
  16.             /* [annotation][unique][in] */
  17.             _In_  IBindCtx *pbc,
  18.             /* [annotation][unique][in] */
  19.             _In_opt_  IMoniker *pmkToLeft,
  20.             /* [annotation][in] */
  21.             _In_  REFIID riid,
  22.             /* [annotation][iid_is][out] */
  23.             _Outptr_  void **ppvObj) = 0;
  24.        
  25.         virtual HRESULT STDMETHODCALLTYPE Reduce(
  26.             /* [unique][in] */ __RPC__in_opt IBindCtx *pbc,
  27.             /* [in] */ DWORD dwReduceHowFar,
  28.             /* [unique][out][in] */ __RPC__deref_opt_inout_opt IMoniker **ppmkToLeft,
  29.             /* [out] */ __RPC__deref_out_opt IMoniker **ppmkReduced) = 0;
  30.        
  31.         virtual HRESULT STDMETHODCALLTYPE ComposeWith(
  32.             /* [unique][in] */ __RPC__in_opt IMoniker *pmkRight,
  33.             /* [in] */ BOOL fOnlyIfNotGeneric,
  34.             /* [out] */ __RPC__deref_out_opt IMoniker **ppmkComposite) = 0;
  35.        
  36.         virtual HRESULT STDMETHODCALLTYPE Enum(
  37.             /* [in] */ BOOL fForward,
  38.             /* [out] */ __RPC__deref_out_opt IEnumMoniker **ppenumMoniker) = 0;
  39.        
  40.         virtual HRESULT STDMETHODCALLTYPE IsEqual(
  41.             /* [unique][in] */ __RPC__in_opt IMoniker *pmkOtherMoniker) = 0;
  42.        
  43.         virtual HRESULT STDMETHODCALLTYPE Hash(
  44.             /* [out] */ __RPC__out DWORD *pdwHash) = 0;
  45.        
  46.         virtual HRESULT STDMETHODCALLTYPE IsRunning(
  47.             /* [unique][in] */ __RPC__in_opt IBindCtx *pbc,
  48.             /* [unique][in] */ __RPC__in_opt IMoniker *pmkToLeft,
  49.             /* [unique][in] */ __RPC__in_opt IMoniker *pmkNewlyRunning) = 0;
  50.        
  51.         virtual HRESULT STDMETHODCALLTYPE GetTimeOfLastChange(
  52.             /* [unique][in] */ __RPC__in_opt IBindCtx *pbc,
  53.             /* [unique][in] */ __RPC__in_opt IMoniker *pmkToLeft,
  54.             /* [out] */ __RPC__out FILETIME *pFileTime) = 0;
  55.        
  56.         virtual HRESULT STDMETHODCALLTYPE Inverse(
  57.             /* [out] */ __RPC__deref_out_opt IMoniker **ppmk) = 0;
  58.        
  59.  
  60.  
  61.         virtual HRESULT STDMETHODCALLTYPE CommonPrefixWith(
  62.             /* [unique][in] */ __RPC__in_opt IMoniker *pmkOther,
  63.             /* [out] */ __RPC__deref_out_opt IMoniker **ppmkPrefix) = 0;
  64.  
  65.  
  66.        
  67.         virtual HRESULT STDMETHODCALLTYPE RelativePathTo(
  68.             /* [unique][in] */ __RPC__in_opt IMoniker *pmkOther,
  69.             /* [out] */ __RPC__deref_out_opt IMoniker **ppmkRelPath) = 0;
  70.        
  71.         virtual HRESULT STDMETHODCALLTYPE GetDisplayName(
  72.             /* [unique][in] */ __RPC__in_opt IBindCtx *pbc,
  73.             /* [unique][in] */ __RPC__in_opt IMoniker *pmkToLeft,
  74.             /* [out] */ __RPC__deref_out_opt LPOLESTR *ppszDisplayName) = 0;
  75.        
  76.         virtual HRESULT STDMETHODCALLTYPE ParseDisplayName(
  77.             /* [unique][in] */ __RPC__in_opt IBindCtx *pbc,
  78.             /* [unique][in] */ __RPC__in_opt IMoniker *pmkToLeft,
  79.             /* [in] */ __RPC__in LPOLESTR pszDisplayName,
  80.             /* [out] */ __RPC__out ULONG *pchEaten,
  81.             /* [out] */ __RPC__deref_out_opt IMoniker **ppmkOut) = 0;
  82.        
  83.         virtual HRESULT STDMETHODCALLTYPE IsSystemMoniker(
  84.             /* [out] */ __RPC__out DWORD *pdwMksys) = 0;      
  85.     };
Note that the method "CommonPrefixWith" has two parameters.

to whoever it may be of interest, the jwaactivex.pas file has the correct definition.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 15509
  • Censorship about opinions does not belong here.
Re: IMoniker possible error in definition
« Reply #1 on: April 03, 2024, 11:28:37 am »
It is of interest, but it is a known issue that FPC does not really conform. At least to me.
My great hero has found the key to the highway. Rest in peace John Mayall.
Playing: "Broken Wings" in your honour. As well as taking out some mouth organs.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11729
  • FPC developer.
Re: IMoniker possible error in definition
« Reply #2 on: April 03, 2024, 11:58:00 am »
Fixed in trunk.

Thaddy

  • Hero Member
  • *****
  • Posts: 15509
  • Censorship about opinions does not belong here.
Re: IMoniker possible error in definition
« Reply #3 on: April 03, 2024, 12:01:57 pm »
Tnx Marco, I know you authored this.
My great hero has found the key to the highway. Rest in peace John Mayall.
Playing: "Broken Wings" in your honour. As well as taking out some mouth organs.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11729
  • FPC developer.
Re: IMoniker possible error in definition
« Reply #4 on: April 03, 2024, 12:08:39 pm »
The original interface support (and specially its OUT) support was very long in the coming (2.0.4-2.4.x and even 3.0.x), so probably in the early days interfaces were more added to get test code running than to be run.
(and COM in general was not very practical for 32-bit till 3.2.x changed to SEH anyway, which is only a few years back)


Thaddy

  • Hero Member
  • *****
  • Posts: 15509
  • Censorship about opinions does not belong here.
Re: IMoniker possible error in definition
« Reply #5 on: April 03, 2024, 02:02:49 pm »
That is correct.
My great hero has found the key to the highway. Rest in peace John Mayall.
Playing: "Broken Wings" in your honour. As well as taking out some mouth organs.

 

TinyPortal © 2005-2018