vb调用dll如何传递字符串指针
在c++编写的dll头文件中,函数定义如下
int EXPORT_API usb_relay_device_open_with_serial_number(const char *serial_number,unsigned len);
/*open device that serial number is serial number*/
/*return:This funcation return a valid handle to the device on success or NULL on failure*/
/**eg:usb_relay_device_open_with_serial_number("abcde",5")*/
在vb中尝试以下几种方式编写程序(设备序列号为“QAAMZ”)
1、直接传递字符串
声明:
private declare function usb_relay_device_open_with_serial_number Lib“xx路径”(byval SerNum as string,byval lenth as long)as long
调用
dim return as long
return=usb_relay_device_open_with_serial_number(“QAAMZ”,5)
2、传递指针
声明中 byval SerNum as long
其中sernum为序列号数组首字符的指针地址
但都出现“DLL调用约定错误”的提示。
求教~
ps:这个问题的前置提问:https://bbs.csdn.net/topics/392563831
已经解决了利用dll获得设备序列号的问题。