大家进来看看阿!急着给分的!
我写了一个DLL,编译都通过了,但在别的程序中却装载错误!我的DLL框架是这样的.(采用regular share mfc dll的方式.)
请各位想想办法阿!急!
DLL的.H文件(主要的)
class CWyldbApp : public CWinApp
{
public:
CWyldbApp();
// Operations
public:
CString m_ADOErrStr;
_RecordsetPtr m_pRecordset;
_ConnectionPtr m_pConnection;
int DataBaseConnect(LPCTSTR DBSrc,LPCTSTR DBpwd);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWyldbApp)
//}}AFX_VIRTUAL
//{{AFX_MSG(CWyldbApp)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_WYLDB_H__9142A2D4_5A6C_463A_910A_1DFEF72A8DA3__INCLUDED_)
DLL的.CPP文件(主要的)
int CWyldbApp::DataBaseConnect(LPCTSTR DBSrc,LPCTSTR DBpwd)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
m_ADOErrStr.Empty(); //在这句出错
if (DBSrc=="" || DBSrc==NULL)
{
m_ADOErrStr.Format("%s","123");
return(FALSE);
}
AfxOleInit();
m_pConnection.CreateInstance(__uuidof(Connection));
try
{
CString constr;
constr.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;Jet OLEDB:Database Password=%s;",DBSrc,DBpwd);
m_pConnection->Open((_bstr_t)(constr),"","",adModeUnknown);
}
catch(_com_error e)
{
m_ADOErrStr.Format("%s",(LPCTSTR)(_bstr_t)(e.Description()));
return FALSE;
}
return TRUE;
}