Travis Herbert Travis Herbert - 2 months ago 9
C++ Question

how to use unmanaged .dll, .lib, .exp in c++ project

I am way out of my league here so I am hoping someone can give me some advice on how to proceed.

The long story is, I started with a jar which i ran an application called ikvm on to produce a .net library of my java classes. This was tested and works fine. So then I had a .net dll, which i used mono aot to generate an unmanaged .dll, .exp, and .lib but no header file. I do know the class names and methods involved.

Now what I can't figure out is how I use these files to work with these classes in a c++ project without the header file. I am using visual studio. If there is any information I missed that would be helpful please comment.

Answer Source

If you have got an unmanged DLL then there are many way to use it c++.

One easy way could be to use LoadLibrary() & GetProcAddress() function. For example:

//Define the function prototype
typedef int (CALLBACK* FirstFunction)(LPCTSTR);

void main()
   HINSTANCE dllHandle = NULL;              
   FirstFunction pFirstFunction = NULL;

   //Load DLL
    dllHandle = LoadLibrary("Your.dll");

   if(dllHandle != NULL)
      //Get pointer to function FindBook
      pFirstFunction = (FirstFunction)GetProcAddress(dllHandle,

      // If function pointer is valid then you can use it 
      if (pFirstFunction != NULL)
         LPCTSTR strBook = "Duchamp";
         short nSuccessCode = pFirstFunction(strBook);