LoadLibraryEx from ActiveX OCX Control
  Home FAQ Contact Sign in
comp.os.mswindows.programmer.win32 only
 
Advanced search
POPULAR GROUPS

more...

comp.os ... win32 Profile…
 Up
LoadLibraryEx from ActiveX OCX Control         


Author: Beagle
Date: May 28, 2008 10:50

Folks,

I am trying to perform a LoadLibraryEx for a DLL from my OCX's
COleControl subclass, and finding GetLastError "126 The specified
module could not be found." The DLL is in the same subdir as the OCX
file, but am finding the search is not including this, but the ActiveX
Control Test Container pid instead (Image Name tstcon32.exe). How can
I get LoadLibrary to succeed without hard coding a path? This needs to
resolve during runtime. I have the ActiveX control's HINSTANCE, so I
ought to be able to resolve the right path from that, or the control's
registry entry, but seems there should be an easier way.

Thanks,
BEA
1 Comment
Re: LoadLibraryEx from ActiveX OCX Control         


Author: Beagle
Date: May 28, 2008 15:53

char ocx[MAX_PATH];
GetModuleFileName(AfxGetModuleState()->m_hCurrentInstanceHandle,
(LPWCH) &ocx[0], MAX_PATH);

Use this for the path in SetDllDirectory before the LoadLibraryEx
call.
Show full article (0.90Kb)
no comments