gpt4 book ai didi

java - 雅各布 com.jacob.com.ComFailException : Can't map name to dispid: CardNumber[0] git hub ZkemSDK project

转载 作者:太空宇宙 更新时间:2023-11-04 10:01:12 24 4
gpt4 key购买 nike

我正在做一个连接门禁和考勤机的项目我发现这个项目在 github 中使用 java 连接到相同类型但为了我想设置 CardNumber 属性,我有一个异常(exception)“com.jacob.com.ComFailException:无法将名称映射到 dispid:CardNumber [0]”有人可以帮我吗

https://github.com/lookskystar/ZKKQProject/blob/master/ZKKQProject/src/com/zkkq/uitl/ZkemSDK.java

public class ZkemSDK 
{
private static ActiveXComponent zkem ;

public ZkemSDK(){

zkem = new ActiveXComponent("zkemkeeper.ZKEM.1");
System.out.println("done ");
}
public boolean connect(String address,int port, int machineNum) throws Exception{

boolean result = zkem.invoke("Connect_NET",address,port).getBoolean();
}

public boolean SetUserInfo(int machineNum,int enrollNo2,String userName,String password,int privelage ,boolean flag) {

Variant dwUserName = new Variant(userName,true);
Variant dwPassword = new Variant(password,true);
Variant dwPrivelage = new Variant(privelage,true);
Variant dwEnrollNo = new Variant(enrollNo2,true);
Variant dwMachineNum= new Variant(machineNum,true);

/****/

zkem.setProperty("CardNumber[0]",454545);
/****/

Variant vResult = Dispatch.call(zkem,"SetUserInfo",dwMachineNum, dwEnrollNo, dwUserName, dwPassword, dwPrivelage,true);


return true;
}
}

最佳答案

我发现有人重写 setProperty 以便能够添加数组在这个链接中 setParameter for an array property with JACOB 我的代码是这样的

public static void setProperty(Dispatch d, String sName, String sIndex, String sValue) {
Variant av[] = { new Variant(sIndex), new Variant(sValue) };
int j[]= {0};
Dispatch.invokev(d, sName, Dispatch.Put, av,j).safeRelease();
av[0].safeRelease(); av[1].safeRelease();
}

通话就像这样

this.setProperty(zkem,"CardNumber","0","2599970");

此行之前

Variant vResult = Dispatch.call(zkem,"SetUserInfo",dwMachineNum, dwEnrollNo, dwUserName, dwPassword, dwPrivelage,true);

关于java - 雅各布 com.jacob.com.ComFailException : Can't map name to dispid: CardNumber[0] git hub ZkemSDK project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53468600/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com