Active X Library and Com object

From: SimonW (bozzzza_at_lycos.co.uk)
Date: 06/28/04


Date: Mon, 28 Jun 2004 16:58:31 +0100

Hi All,

I created a com server by creating a new active X library then placed then
a new com object. I then created a Method for the Interface through the
type library editor and it generated this code :-

ICoTest = interface(IUnknown)
    ['{06DE66DE-9220-464A-BABC-26833D994759}']
    function AddNumbers(First: Integer; Second: Integer; out Answer:
OleVariant): HResult; stdcall;
  end;

In the implementation class I filled in the following code :-

function TCoTest.AddNumbers(First, Second: Integer;
  out Answer: OleVariant): HResult;
begin
    try
        Answer := First+Second;
        result := S_OK;
    except
        result := E_FAIL;
    end;
end;

I then compiled and registered the type library which generates the
following code for the function :-

function TCoTest.AddNumbers(First: Integer; Second: Integer; out Answer:
OleVariant): HResult;
begin
  DefaultInterface.AddNumbers(First, Second, Answer);
end;

So far so good.

On using this interface method in com client, Delphi informs me that
the 'Return value of function 'TCotest.AddNumbers' might be undefined'

Ok looking at the code I realise there is no result, in the function that
has been created by the type library, why, and how would I stop this
messaging from appearing?

Also is there a pointer type in the type library editor for integers? I
couldn't find one, hence the reason I used OleVariant for the out parameter.

TIA

Simon.



Relevant Pages

  • Re: #import generates different code
    ... Yes I have tried generating Raw wrappers and a similar issue is occuring. ... IDispatch and use the directive interface it works. ... > What directives are you using for #import now? ... >> by checking the returned HRESULT. ...
    (microsoft.public.vc.language)
  • Re: about casting
    ... One very strange thing is that I looked in the code to try to find if some other interface class is sent into some ... I looked more into the code and found that in some places is IStringList used as a parameter instead of IStringList2. ... HRESULT ErrorMessage; ...
    (microsoft.public.vc.mfc)
  • Re: #import generates different code
    ... "Unlike interface members, dispinterface members cannot use the retval ... HRESULT or SCODEs to long. ... > Yes I have tried generating Raw wrappers and a similar issue is occuring. ... >> What directives are you using for #import now? ...
    (microsoft.public.vc.language)
  • connection point event is not fire from com component
    ... I have a com component and fire event to an MFC application using ... HRESULT CScribbleExtractor::Extract ... //Create an instance of the interface defined in the COM DLL ... //Variable for the connection point cookie ...
    (microsoft.public.vc.atl)
  • Re: CoCreateInstance and "Class not registered" error...
    ... present in the registry under HKCR/Classes. ... an in-proc server, but does its threading model match the ... interface from this dll. ... HRESULT hresult ...
    (microsoft.public.vc.atl)