16,216
社区成员
发帖
与我相关
我的任务
分享
STDMETHODIMP CQtTest::AddSubMethod(long sum, VARIANT* oper1, VARIANT* oper2, long* ret)
{
// TODO: 在此添加实现代码
*ret = 0;
if(oper1->vt != VT_I4)
{
::MessageBox(NULL,L"第一个参数类型错误",L"QtTest",0);
} else if(oper2->vt != VT_I4) {
::MessageBox(NULL,L"第二个参数类型错误",L"QtTest",0);
} else {
oper1->lVal = sum + 1;
oper2->lVal = sum - 1;
*ret = 1;
}
return S_OK;
}
long AddSubMethod(
[in] long sum,
[in, out] VARIANT* oper1,
[in, out] VARIANT* oper2);
int sum = 5;
int x = 0, y = 0;
QVariant v_x, v_y;
v_x.setValue(x); v_y.setValue(y);
int ret = obj.dynamicCall("AddSubMethod(long,QVariant&,QVariant&)", sum, v_x, v_y).toInt();
x = (1 == ret ? v_x.toInt() : -1);
y = (1 == ret ? v_y.toInt() : -1);