none
Generating DLLImport statements from a C++ header RRS feed

  • Question

  • I have an unmanged C++ DLL with many functions in the API that I need to call.  I have the associated Header file (.h file) with the DLL.  I was wondering if there was a tool that would generate the appropriate DLLImport statements for each function in the header file ? 
    Thursday, November 6, 2008 9:42 PM

Answers

All replies

  • Yes, there is one.  Rats, what is it called again... My memory fails me, it was an Open Source project.  Nothing intuitive for a name, the last I heard of it was two years ago.  I never paid much attention because writing wrappers is one of those easy "auto-pilot", do twenty in a day routines.  Good for a Friday.  Knowing it is out there might perhaps encourage you to keep googling.


    Hans Passant.
    Thursday, November 6, 2008 10:16 PM
    Moderator
  • Its the pinvoke interop assistant on codeplex
    Thursday, November 6, 2008 10:18 PM
  • Nah, that wasn't it.  It was a tool that generated C++/CLI code, not [DllImport].  Required when you try to use C++ methods from managed code, P/Invoke can't work for C++ class methods.  You can't call the constructor.  I'll sleep on it.  Well, slumber.
    Hans Passant.
    Thursday, November 6, 2008 10:27 PM
    Moderator
  • Did the name of the utility ever come to you ?  I have searched more and have not come across a utility.  I don't think the pinvoke interop assistant on codeplex is what I am looking for.

    I am writing an appliction in VB.Net (Visual Studio 2008) and the C++ DLL is a third party DLL (it is not a COM DLL).  They provided the header file (.h) but not the code.  I was hoping there was some utility that read a header file and produced all of the DLLImport lines that I would need in the .Net code so that it can call to the DLL.
    Friday, November 7, 2008 6:08 PM
  • What does the header file look like?  If it uses classes, you can't use [DllImport].
    Hans Passant.
    Friday, November 7, 2008 6:36 PM
    Moderator
  • Okay, found it.  It was SWIG.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Thursday, November 13, 2008 9:38 AM
    Friday, November 7, 2008 6:43 PM
    Moderator