VB取得一个ADO的记录集(Recordset类型),再调用VC的DLL将记录集传入DLL中进行处理,在DLL中可以正确读出记录集内容,但调用完成,退出DLL中的调用函数后,DLL(总是会报错提示"Unhandleed exception in Project1.exe(MSADO15.DLL): 0xC00000005:Access Violation)。
在DLL中的接口声明为
int GetDBS(_RecordPtr adoDBS)
{
//对VB中传过来的记录集进行处理
}VB中声明:
Private Declare Function ExportDBS Lib "DLLOut" (ByVal rstOut As Recordset) As Long
调用:
Dim tmpRst As Recordset
Dim hnd As Long
Set tmpRst = New ADODB.Recordset
gSql = "Select * From Formats"
tmpRst.Open gSql, gAdoCon, adOpenDynamic, adLockOptimistic
hnd = ExportDBS(tmpRst)我在网上查了下资料,估计是传递的变量类型不正确,但我的困惑是如果变量传递不正确,为何在DLL中可以正常读出记录集中数据呢?请知道的XD给我些建议,谢谢。
在DLL中的接口声明为
int GetDBS(_RecordPtr adoDBS)
{
//对VB中传过来的记录集进行处理
}VB中声明:
Private Declare Function ExportDBS Lib "DLLOut" (ByVal rstOut As Recordset) As Long
调用:
Dim tmpRst As Recordset
Dim hnd As Long
Set tmpRst = New ADODB.Recordset
gSql = "Select * From Formats"
tmpRst.Open gSql, gAdoCon, adOpenDynamic, adLockOptimistic
hnd = ExportDBS(tmpRst)我在网上查了下资料,估计是传递的变量类型不正确,但我的困惑是如果变量传递不正确,为何在DLL中可以正常读出记录集中数据呢?请知道的XD给我些建议,谢谢。
int WINAPI __stdcall ExportDBS(_RecordPtr adoDBS)
{}
应该是传入参数类型的问题,将此函数只增加一句 return 0,结果也是相同。
如果都是vc,可以自己写个包装类,把记录集_RecordsetPtr作为类的成员