【CSDN】【VC调用VB组件接口方法时的参数转换问题】
在VB组件中有如下这一接口方法
Public Function validate(strAccountNumber As String, mCash As Currency) As Boolean
If strServerName = "" Then
getSQLServerName
End If
Call connectionSQLServer
If rsCheckAccount.State = 1 Then rsCheckAccount.Close
rsCheckAccount.CursorLocation = adUseClient
strSql = "select * from Customer where cAccountNumber ='" & strAccountNumber & "'"
rsCheckAccount.Open strSql, conCheckAccount, adOpenDynamic, adLockOptimistic
If rsCheckAccount.RecordCount > 0 Then
rsCheckAccount.MoveFirst
validate = Credit(rsCheckAccount("cAccountTypeID"), mCash, rsCheckAccount("mAccountBalance"))
Else
strError = "帐号非法"
validate = False
End If
End Function
VC中进行如下调用
void CZjyDlg::OnButton1()
{
// TODO: Add your control notification handler code here
HRESULT hr=CoInitialize(NULL);
CLSID clsid;
hr=CLSIDFromProgID(OLESTR("CheckAccountDll.CheckAccount"),&clsid);
_checkAccount * ckptr;
hr=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_checkAccount),(LPVOID *)&ckptr);
if(FAILED(hr))
{
AfxMessageBox("Failed");
return;
}
char cAccountType[4];
int iCash;
GetDlgItemText(IDC_EDIT1,cAccountType,4);
iCash=GetDlgItemInt(IDC_EDIT2);
long lStatus;
lStatus=ckptr->validate(_bstr_t(cAccountType),iCash);
if(lStatus==1)
AfxMessageBox("ok");
else
AfxMessageBox("bad");
CoUninitialize();
}
出现如下错误
E:\zjy\zjyDlg.cpp(193) : error C2664: 'validate' : cannot convert parameter 1 from 'class _bstr_t' to 'unsigned short ** '
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
请问VC中的
ckptr->validate(_bstr_t(cAccountType),iCash);
这句如何写法,参数是怎么转换的