[已解决]Dll函数返回值类型为结构体指针,如何获取返回值结构体内的值
本帖最后由 风过无痕 于 2021-6-26 10:09 编辑最近在做一个海康威视监控的查看工具,SDK也能初始化成功了,但是就是到设备注册一步卡住了,实在没有头绪了,特来寻求帮助:
LONG NET_DVR_Login_V30(
char *sDVRIP,
WORD wDVRPort,
char *sUserName,
char *sPassword,
LPNET_DVR_DEVICEINFO_V30 lpDeviceInfo);
红色处是一个结构体,dllcall的话该如何调用呢?
NET_DVR_DEVICEINFO_V30struct{
BYTE sSerialNumber;BYTE byAlarmInPortNum;
BYTE byAlarmOutPortNum;BYTE byDiskNum;BYTE byDVRType;
BYTE byChanNum;BYTE byStartChan;BYTE byAudioChanNum;
BYTE byIPChanNum;BYTE byZeroChanNum;BYTE byMainProto;
BYTE bySubProto;BYTE bySupport;BYTE bySupport1;
BYTE bySupport2;WORD wDevType;BYTE bySupport3;
BYTE byMultiStreamProto;BYTE byStartDChan;
BYTE byStartDTalkChan;BYTE byHighDChanNum;BYTE bySupport4;
BYTE byLanguageType;BYTE byVoiceInChanNum;
BYTE byStartVoiceInChanNo;BYTE byRes3;BYTE byMirrorChanNum;
WORD wStartMirrorChanNo;BYTE byRes2;
}NET_DVR_DEVICEINFO_V30,*LPNET_DVR_DEVICEINFO_V30;
DllStructCreate('byte;byte......')创建结构体,DllStructGetPtr传指针 返回了结构体后,用这个函数就可以获取你需要的结构体内的值 本帖最后由 风过无痕 于 2021-6-11 21:44 编辑
Xxkwwz 发表于 2021-6-11 15:46
返回了结构体后,用这个函数就可以获取你需要的结构体内的值
目前就是不知如何返回结构体,很懵。 繁星 发表于 2021-6-11 00:28
DllStructCreate('byte;byte......')创建结构体,DllStructGetPtr传指针
看了好多示例,也尝试用DllStructCreate创建了结构体,但是得到数据总是不对。 谢谢分享! 本帖最后由 wyl0205 于 2021-6-25 19:23 编辑
Local$tagSTRUCT = _
"BYTEsSerialNumber;" & _
"BYTEbyAlarmInPortNum;" & _
"BYTEbyAlarmOutPortNum;" & _
"BYTEbyDiskNum;" & _
"BYTEbyDVRType;" & _
"BYTEbyChanNum;" & _
"BYTEbyStartChan;" & _
"BYTEbyAudioChanNum;" & _
"BYTEbyIPChanNum;" & _
"BYTEbyZeroChanNum;" & _
"BYTEbyMainProto;" & _
"BYTEbySubProto;" & _
"BYTEbySupport;" & _
"BYTEbySupport1;" & _
"BYTEbySupport2;" & _
"WORDwDevType;" & _
"BYTEbySupport3;" & _
"BYTEbyMultiStreamProto;" & _
"BYTEbyStartDChan;" & _
"BYTEbyStartDTalkChan;" & _
"BYTEbyHighDChanNum;" & _
"BYTEbySupport4;" & _
"BYTEbyLanguageType;" & _
"BYTEbyVoiceInChanNum;" & _
"BYTEbyStartVoiceInChanNo;" & _
"BYTEbyRes3;" & _
"BYTEbyMirrorChanNum;" & _
"WORDwStartMirrorChanNo;" & _
"BYTEbyRes2;"
Local $tSTRUCT = DllStructCreate($tagSTRUCT)
DllCall($hDLL, "LONG", 'NET_DVR_Login', "str", '192.168.1.227', 'WORD', "8000", "str", "test", "str", "123456", "struct*", $tSTRUCT)
MsgBox(0, "连接成功", "序列号" & DllStructGetData($tSTRUCT, 1)
页:
[1]