简体   繁体   中英

Error with ActiveX and MCVE

In my search of the error of the return of S_OK and not S_FALSE (see my previous message), I have made a very small sever with only one method wich send S_FALSE (HResult type), unfortunatly I have an error with the small client program: The project TestTest.exe has send the exception class EOleSysError with the message 'variable type invalid' (it's the instruction Return:=coll.Method which raise the error). Any idea? The .ridl the server code:

function TTest1.Method: HResult;
begin
  Result:=S_FALSE;
end;

and the client code:

procedure TForm1.Button1Click(Sender: TObject);
var
  coll:variant;
  Return:HResult;
begin
  coll:= CreateOLEObject('Project.Test1');
  Return:=coll.Method;
  if Return=S_FALSE then showmessage('OK') else showmessage('ERROR!!!!!!!!!!!!!!!!');
end;

for the full problem I have made an MCVE: the server: enter link description here the client: enter link description here

I dont think you need the parameter 'value' of type HRESULT . You can delete that parameter: the method will already return HRESULT . If you want to test with a parameter, try changing 'value' to BSTR [in] and pass any string there. It should work.

Return:=coll.Method('place the parameter string here');

Cheers

我不知道为什么你坚持使用HRESULT返回值,为什么你不创建带有参数value, type : long , modifier : in HRESULT方法value, type : long , modifier : in然后返回你想要的任何东西。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM