Loading a DLL in an OCX Wrapper

Hey guys, I'm back :D I'm currently trying to load a .dll into an .ocx wrapper for use in Wonderware. For some reason the loading of the .dll is not working properly, thus causing my ocx to fail when trying to run it in a test container. I have tried a couple things for loading the .dll...

[code]BOOL CActiveXApp::InitInstance()
BOOL bInit = COleControlModule::InitInstance();
if (bInit)
//Loading the .dll
m_hButtonControl= ::LoadLibrary( _T( "DAPassThru.dll" ));

return bInit;
AfxEnableControlContainer(); //Added on 04/03/2008 hopefully fix OnDraw problem

if (m_hButtonControl == NULL)
return bInit;


And the other method I tried was:

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 ) // Get the DLL version
m_DADllVersion( &m_DAMajor, &m_DAMinor, &m_DARelease );

outputDebug("Loaded DAPassThruDll Version %d.%d.%d", m_DAMajor, m_DAMinor, m_DARelease);

if( m_DAOpen ) // Open the DLL
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 );
outputDebug("Failed to open DAPassThru Dll");[/code]

The ocx compiles fine when I use the first code block, but when it comes time to test it, I get an error in the test container Sad Any suggestions would be appreciated, I'm open to any ideas. Thanks guys.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!