2 ygtjcng1 ygtjcng1 于 2015.06.14 19:45 提问

VB调用C++动态链接库 3C

现在有个C++动态链接库,有头文件,但是我想在VB里面调用。怎么在VB里面调用啊、麻烦帮忙把下面的3个函数转成能在VB里面用的语句。

之前没接触过VB,现在因为时间紧,需要临时突击下。麻烦帮忙解答下啊。

#ifndef C_DLL
#define C_DLLEXPORT extern "C" __declspec(dllexport)
#define C_DLLIMPORT extern "C" __declspec(dllimport)
#endif

C_DLLEXPORT int Setup(HANDLE hCom, DWORD baudRate= 9600, BYTE parity=NOPARITY, BYTE datasize=8, BYTE stopbits=ONESTOPBIT, DWORD timeOut= 1000, DWORD readBufferSizes=256, DWORD writeBufferSizes=256);

C_DLLEXPORT int Write(HANDLE hCom, char* pbuffer);

C_DLLEXPORT int Read (HANDLE hCom, char* pbuffer);

5个回答

songhtao
songhtao   Rxr 2015.06.14 19:56
oyljerry
oyljerry   Ds   Rxr 2015.06.14 20:50
caozhy
caozhy   Ds   Rxr 2015.06.14 20:57

Declare Function Setup Lib "yourdllname.dll" (byval hCom as long, byval baudRate as long, byval parity as byte, byval datasize as byte, byval stopbits as byte, byval timeOut as long, byval readBufferSizes as long, byval writeBufferSizes as long) as long
Declare Function Write Lib "yourdllname.dll" (byval hCom as long, byval pbuffer() as byte) as long
Declare Function Read Lib "yourdllname.dll" (byval hCom as long, byval pbuffer() as byte) as long

caozhy
caozhy 回复ygtjcng1: 可以,传数组没问题
2 年多之前 回复
ygtjcng1
ygtjcng1 指针类型能直接这么引用么?
2 年多之前 回复
ygtjcng1
ygtjcng1   2015.06.15 08:42

指针类型变量怎么改类型啊.

frank_20080215
frank_20080215   2015.06.14 20:54

regsrv32 X.dll, 然后在VB中引用这个dll

Csdn user default icon
上传中...
上传图片
插入图片