使用JACOB的数组属性的setParameter [英] setParameter for an array property with JACOB
本文介绍了使用JACOB的数组属性的setParameter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下VB代码:
Set QuoteRequest = Quotes.Add
With QuoteRequest
.No = 1
.QuoteCode(0)="101"
.Code(0)="NAME1"
.Code(1)="NAME2"
End With
我使用JACOB访问该COM对象.
I use JACOB to access that COM object.
quoteRequest.setProperty("No",1);
quoteRequest.setProperty("QuoteCode(0)","101");
quoteRequest.setProperty("Code(0)", "NAME1");
quoteRequest.setProperty("Code(1)", "NAME2");
但这会导致异常
com.jacob.com.ComFailException: Can't map to dispid: QuoteCode(0)
如何传递该财产?
推荐答案
import com.jacob.com.*;
import com.jacob.activeX.*;
static void setProperty(Dispatch d, String sName, String sIndex, String sValue) {
Variant av[] = { new Variant(sIndex), new Variant(sValue) };
Dispatch.invokev(d, sName, Dispatch.Put, av, NO_INT_ARGS).safeRelease();
av[0].safeRelease(); av[1].safeRelease();
}
那是我使用的代码.对我有用,但是我对Jacob进行了一些更改,以强制对未使用的变体进行装袋.很难说我到底做了什么,那是在几年前:)
That's the code I used. Works for me, however I was doing some changes to Jacob, to force garbaging of unused variants. Hard to say what I exactly did, it was years ago :)
这篇关于使用JACOB的数组属性的setParameter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文