在VC++.NET中的函数原型为:
extern _declspec(dllexport) bool __stdcall WINAPI bAutoInit(HANDLE hComm,STRUCommInfo *CommInfo,int iSMSFormat,char *szErrInfo);
其中
struct STRUCommInfo
{
int BaudRate;
char szSCA[30];
};
转化到VB中,我改怎么调用这个API函数?
这样使用:
Private Declare Function bAutoInit Lib "SMSCOM.DLL" (ByVal hComm As IntPtr, ByVal CommInfo() As Byte, ByVal iSMSFormat As Integer, ByVal szErrInfo As String) As Boolean
其中:dim CommInfo(33) as byte
起初使用结构体传值,总是内存读出错:改成字节数组就不错了。
structure STRUCommInfo
dim BaudRate as integer
dim szSCA() as btye
end structure
有没有更好的办法,请高人指点,谢过!
------解决方案--------------------
http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120