Loading a .dll in ActiveX
I'm currently attempting to successfully wrap a dll with an activex ocx. So
far it has gone well and I have compiled my program, which is quite large.
When I attempt to run the ocx is the Test Container, I get a "Failed to
create control:Unspecified error" message. I'm assuming it has to do with how
I implement the dll. I have tried two ways, which are listed below.
============================================================
BOOL CActiveXPropPage::OnInitDialog()
{
CDialog::OnInitDialog();
// Load the DLL library
m_hLib = LoadLibraryW
((LPCWSTR)"..\\..\\DAPassThru\\Debug\\DAPassThru.dll");
if( m_hLib || (m_hLib = (LoadLibraryW((LPCWSTR)"DAPassThru.dll")) ) )
{
if( !LoadProcs() ) // Load the DLL
entry points
WriteDebugString("Could NOT get all proc addresses");
if( m_DADllVersion )
m_DADllVersion( &m_DAMajor, &m_DAMinor, &m_DARelease );
// outputDebug("Loaded DAPassThruDll Version %d.%d.%d", m_DAMajor,
m_DAMinor, m_DARelease);
if( m_DAOpen )
m_DAOpen( &m_hDA, &m_uFlags, &CallBack, NULL );
// outputDebug("Opened DAPassThruDll with %d flags", m_uFlags);
// updateMenus( m_uFlags );
if( m_DASetDebug )
m_DASetDebug( TRUE );
}
else return 0;
==========================================================
and
==========================================================
BOOL CActiveXApp::InitInstance()
{
BOOL bInit = COleControlModule::InitInstance();
// m_hButtonControl = NULL;
if (bInit)
//Loading the .dll 'cause its a ***!
m_hButtonControl= ::LoadLibrary( _T( "dapassthru.dll" ));
return bInit;
if (m_hButtonControl == NULL)
{
return bInit;
}
}
=========================================================
Is there a better way to load a dll? Both methods compile, but I still get
the same error message. The dll is also located in the same directory as the
ocx when I run it. Could it be possible that it is due to something else? Any
help would be greatly appreciated. Thanks guys.