[英]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).在我搜索返回 S_OK 而不是 S_FALSE 的错误时(请参阅我之前的消息),我制作了一个非常小的服务器,只有一个方法发送 S_FALSE(HResult 类型),不幸的是我在小客户端程序中出错:项目 TestTest.exe 已发送异常类 EOleSysError 并带有消息“变量类型无效”(这是引发错误的指令Return:=coll.Method
)。 Any idea?任何的想法? The .ridl .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对于完整的问题,我做了一个 MCVE:服务器:在此处输入链接描述客户端:在此处输入链接描述
I dont think you need the parameter 'value' of type HRESULT
.我认为您不需要HRESULT
类型的参数“值”。 You can delete that parameter: the method will already return HRESULT
.您可以删除该参数:该方法将已经返回HRESULT
。 If you want to test with a parameter, try changing 'value' to BSTR
[in] and pass any string there.如果您想使用参数进行测试,请尝试将 'value' 更改为BSTR
[in] 并在那里传递任何字符串。 It should work.它应该工作。
Return:=coll.Method('place the parameter string here');
Cheers干杯
我不知道为什么你坚持使用HRESULT
返回值,为什么你不创建带有参数value, type : long , modifier : in
HRESULT
方法value, type : long , modifier : in
然后返回你想要的任何东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.