Loading a non-ATL .DLL from within ATL 
Author Message
 Loading a non-ATL .DLL from within ATL

I have the following code in my com object:

     // externaldll.h
     // header file for externaldll.dll
     #define DLLIMPORT _declspec(dllimport)
     DLLIMPORT int Function1(LPSTR user);

     // comobject.cpp
     char init[5] = {"TEST"};
     int success = Function1((char far *)(init));

The .dll and .lib file have been added to the project and
the externaldll.h file has been #included at the top of
comobject.h. The dll is a library that was written in C++
but i do not have the source or any idea what the object
structure inside of it is like. it is a black box.

Here is the crux of the matter: This code works just fine
when I choose VC Menu->Tools->ActiveXControl Test
Container or If I run it by pressing F5 (even a release
version). If I try to load the control in IE or in
ActiveXControl Test container when launched from the
windows menu, it doesn't even load. the testContainer
gives the error: "Failed to create control. Unspecified
error." If I comment out the call to the dll (thus
avoiding the link?) it also loads fine. For some reason,
under these conditions the dll is not being loaded right.

This seems like it might be a threading issue due to the
fact that it only loads the dll correctly under some
instances. Can anyone please shed some light on this issue
or tell me where to look for more info? Why would it fail
to load only some of the time?

Thanks,
Paul



Tue, 03 Feb 2004 01:38:05 GMT  
 Loading a non-ATL .DLL from within ATL
Perhaps the loader cannot locate that DLL. Put it in a commonly
acessible location like \winnt\system32 or somewhere on the
path.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> I have the following code in my com object:

>      // externaldll.h
>      // header file for externaldll.dll
>      #define DLLIMPORT _declspec(dllimport)
>      DLLIMPORT int Function1(LPSTR user);

>      // comobject.cpp
>      char init[5] = {"TEST"};
>      int success = Function1((char far *)(init));

> The .dll and .lib file have been added to the project and
> the externaldll.h file has been #included at the top of
> comobject.h. The dll is a library that was written in C++
> but i do not have the source or any idea what the object
> structure inside of it is like. it is a black box.

> Here is the crux of the matter: This code works just fine
> when I choose VC Menu->Tools->ActiveXControl Test
> Container or If I run it by pressing F5 (even a release
> version). If I try to load the control in IE or in
> ActiveXControl Test container when launched from the
> windows menu, it doesn't even load. the testContainer
> gives the error: "Failed to create control. Unspecified
> error." If I comment out the call to the dll (thus
> avoiding the link?) it also loads fine. For some reason,
> under these conditions the dll is not being loaded right.

> This seems like it might be a threading issue due to the
> fact that it only loads the dll correctly under some
> instances. Can anyone please shed some light on this issue
> or tell me where to look for more info? Why would it fail
> to load only some of the time?

> Thanks,
> Paul



Tue, 03 Feb 2004 02:02:22 GMT  
 Loading a non-ATL .DLL from within ATL
yep. That was it, thanks.

I love it when the solution is easy.

-paul



Tue, 03 Feb 2004 02:33:28 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. using ATL types in non-ATL project

2. mixing ATL & Non ATL code

3. ATL class in non-ATL class

4. List of instantiated objects (from within ATL DLL)

5. Help with Visual Basic ActiveX DLL showing form within Visual C++ ATL app

6. Using the CommonDialog ActiveX Control from within an ATL COM dll

7. ATL: instantiating a COM object within its own implementation DLL

8. Question about loading C DLL from ATL COM

9. loading an MFC DLL that was originally an extension dll from a non MFC dLL

10. Using AFX EXT DLL ATL objects in ATL EXE server

11. Atl control dependency on atl.dll

12. ATL.MSM does not register ATL.DLL properly

 

 
Powered by phpBB® Forum Software