Cant import dll in C++ application

Go To StackoverFlow.com

0

I have a dll called hecom32.dll. I want to use this in my application. I acll the following:

#import "hecom32.dll"

And I get the following error:

enter Error 1   error C1083: Cannot open type library file: 'c:\users\dvargo\documents\visual studio 2010\projects\johnny\johnny\hecom32.dll': Error loading type library/DLL.  c:\users\dvargo\documents\visual studio 2010\projects\johnny\johnny\johnny.cpp  6   1   Johnny

Obviously it cant add it. I am not sure however to determine what is wrong with it. Is there some way that I can analyze the file to see why it cant be imported. Is there a different way to use the functions in the dll?

I am using Visual Studio 2010

2012-04-05 15:53
by user489041
Sounds like the DLL doesn't have a type library - David Heffernan 2012-04-05 15:57
http://msdn.microsoft.com/en-us/library/et4zwx34%28v=vs.80%29.asp - selalerer 2012-04-05 15:58


4

This will only work properly if hecom32.dll implements a COM server and has the type library embedded as a resource. You can check that with File + Open + File, select the dll. You'll see the resources listed, there should be one labeled "TYPELIB" with a resource ID of 1 if you open the node.

Surely that's missing, the error message says as much. Embedding a type library is a convention, it isn't required. Just keeping it separate as a .tlb file is possible as well. And of course, it might not be a COM server at all. You can see that by running Dumpbin.exe /exports on the dll. A COM server has at least an export named "DllGetClassObject".

If none of this pans out then you'd better contact the owner of the DLL and ask for help on how to use it properly. Which typically requires having a .h file with the declarations of the exported functions and a .lib file so you can link it.

2012-04-05 16:02
by Hans Passant
Thanks for the help. If it is kept in a seperate .tlb file, would it have the same name - user489041 2012-04-05 16:06
Not necessarily, it can be anything. This would be documented by the owner. Do you at least have a manual - Hans Passant 2012-04-05 16:08
I do, but its in German :( . As of now, I have tried your first suggestion. It does not appear to have a TYPELI - user489041 2012-04-05 16:09
You can almost always find somebody that speaks English on the other end of the phone line. Give them a call - Hans Passant 2012-04-05 16:12
Ok so it does not have a DllGetClassObject function. This would mean it is not a COM Server. SO if this is the case. What could it be then - user489041 2012-04-05 16:53
Just a regular DLL then. Now you need the .h and the .lib file - Hans Passant 2012-04-05 17:00
Im not 100 percent sure that this dll was created originally in c++. My best guess is Delphi. If this is the case, any suggestions on what I can do - user489041 2012-04-05 17:09
Language does not matter, as long as there is a header file with function prototypes with the correct calling convention (stdcall, pascal, cdecl... - SirDarius 2012-04-06 11:38
Ads