Recent

Author Topic: COM library once again  (Read 489 times)

korba812

  • Sr. Member
  • ****
  • Posts: 446
COM library once again
« on: October 13, 2024, 09:30:11 pm »
I am playing around with creating a COM library and have some questions/ doubts.

1. The dispinterface generated with "Import Type Library" tool contains methods from parent interfaces.
Code: Pascal  [Select][+][-]
  1. // IDemo : IDemo - demo interface
  2.  
  3.  IDemo = interface(IDispatch)
  4.    ['{B621769D-04FD-420C-AFDD-35227C29B9BF}']
  5.     // DoSomething : Do something with DemoEmu1
  6.    function DoSomething(SomeValue:DemoEnum1): WideString;safecall;
  7.   end;
  8.  
  9.  
  10. // IDemo : IDemo - demo interface
  11.  
  12.  IDemoDisp = dispinterface
  13.    ['{B621769D-04FD-420C-AFDD-35227C29B9BF}']
  14.     // QueryInterface :  
  15.    procedure QueryInterface(var riid:{!! GUID !!} OleVariant;out ppvObj:{!! Ppointer !!} OleVariant);dispid 1610612736;
  16.     // AddRef :  
  17.    function AddRef: LongWord;dispid 1610612737;
  18.     // Release :  
  19.    function Release: LongWord;dispid 1610612738;
  20.     // GetTypeInfoCount :  
  21.    procedure GetTypeInfoCount(out pctinfo:UInt);dispid 1610678272;
  22.     // GetTypeInfo :  
  23.    procedure GetTypeInfo(itinfo:UInt;lcid:LongWord;out pptinfo:{!! Ppointer !!} OleVariant);dispid 1610678273;
  24.     // GetIDsOfNames :  
  25.    procedure GetIDsOfNames(var riid:{!! GUID !!} OleVariant;var rgszNames:{!! PShortInt !!} OleVariant;cNames:UInt;lcid:LongWord;out rgdispid:Integer);dispid 1610678274;
  26.     // Invoke :  
  27.    procedure Invoke(dispidMember:Integer;var riid:{!! GUID !!} OleVariant;lcid:LongWord;wFlags:Word;var pdispparams:{!! DISPPARAMS !!} OleVariant;out pvarResult:OleVariant;out pexcepinfo:{!! EXCEPINFO !!} OleVariant;out puArgErr:UInt);dispid 1610678275;
  28.     // DoSomething : Do something with DemoEmu1
  29.    function DoSomething(SomeValue:DemoEnum1): WideString;dispid 0;
  30.   end;
  31.  
Are they needed? I get warnings during compilation.
Code: [Select]
comdemo_1_0_tlb.pas(68,14) Warning: An inherited method is hidden by "QueryInterface(var OleVariant;out OleVariant);"
comdemo_1_0_tlb.pas(74,14) Warning: An inherited method is hidden by "GetTypeInfoCount(out LongWord);"
comdemo_1_0_tlb.pas(76,14) Warning: An inherited method is hidden by "GetTypeInfo(LongWord;LongWord;out OleVariant);"
comdemo_1_0_tlb.pas(78,14) Warning: An inherited method is hidden by "GetIDsOfNames(var OleVariant;var OleVariant;LongWord;LongWord;out LongInt);"
comdemo_1_0_tlb.pas(80,14) Warning: An inherited method is hidden by "Invoke(LongInt;var OleVariant;LongWord;Word;var OleVariant;out OleVariant;out OleVariant;out LongWord);"

2. When compiling methods that are in safecall convention, I get a warning that the function result is not set. I understand that such a method is converted to a function resturned of type HRESULT, is wrapped in try..except, etc. So why this warning?
Code: [Select]
udemo.pas(43,16) Warning: Function result does not seem to be set
Same warning occurs when compiling:
Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. procedure Foo; safecall;
  4. begin
  5. end;
  6.  
  7. begin
  8. end.
  9.  
Code: [Select]
project1.lpr(3,11) Warning: Function result does not seem to be set

3. Is there a generally accepted way to communicate additional information about failure/error/exception of a method call? The information provided by IErrorInfo is insufficient and I would like to provide more information. Probably this can be done in many ways.


 

TinyPortal © 2005-2018