代码如下:数据库方面已经测试,没问题,用的unicode编码.dll和主程序都支持mfc
dll的:
extern "C" __declspec(dllexport) void insert(CStringW val[], int size)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
DBOper o;
o.Insert(val, size);

}
BOOL DBOper::Insert(CStringW val[], int size)
{
CDaoRecordset rTemp(&m_database);
rTemp.Open(AFX_DAO_USE_DEFAULT_TYPE,
L"SELECT * FROM file", 0);
rTemp.AddNew();
for(int i =0;i<size;i++)
{
rTemp.SetFieldValue(i,(LPCTSTR)val[i]);
}
rTemp.Update();
rTemp.Close();
return true;
}
主程序的:
                  CStringW a[6]={"1","2","3","4","5","6"};
typedef void (WINAPI * Insert)(CStringW[],int);
HINSTANCE hmod;
hmod = ::LoadLibrary (L"DBHelper.dll");
if(hmod==NULL)
{
AfxMessageBox(L"fail");
}
Insert lpproc;
lpproc = (Insert)GetProcAddress (hmod,"insert");
if(lpproc!=(Insert)NULL)
(*lpproc)(a,6);//这里返回后报错
                    FreeLibrary(hmod);
这是错误信息
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.  This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
我还是新手,大家帮我一把,谢谢.