I have a third party dll (C++) which I need to call from my c# class. I
defined
[DllImport("The.dll")]
public static extern ...
for each function that I want to use. The brief API document for the
functions states that the return values from these functions can be H_FAIL
and H_SUCCESS. There also some structs that are used as parameters which in
turn can have values in the same form, e.g. H_NOT_INSTALLED.
There is no documentation so I can't figure out the actual values behind the
H_FAIL etc. I don't have any .h files, just the dll. Is there any way to
obtain these underlying values (I'm pretty sure they are all integers) using
the Interop? Or make my c# understand the H_SOMETHING?
Thanks in advance.
Anna
Hi Anna,
>I have a third party dll (C++) which I need to call from my c# class. I
> defined
[quoted text clipped - 17 lines]
> Thanks in advance.
> Anna
Unless an entry appears in the exports of the dll, you cannot use it.
You're lucky if your third party supplier not only supplies the library, but
also the header files + lib to bind to. In that case, you can make a program
that reads these headers and converts any non-exported thing (like a define)
to a .NET thing (whatever thing may be). I would explicitely ask the third
party supplier for at least the header files. If you can't then your stuck
at that point. You will have to experiment and determine the values
yourself, or check the documentation if the values are defined there.
FYI I was forced to make such a program to interop with a C library that was
developed by a third party supplier. My "conversion" program translated all
structs and defines from the header files that were included. This need not
be a difficult "translates everything" program, you can write one that
simply parses the #define's and outputs a static class that has public
entries for each of the defines. I could have just read the headers and make
the conversion myself, but as we foresaw that the third party library could
evolve and add new defines etc, we decided to write a program that does the
conversion and add the conversion to our pre-build process.
Kind regards,
--
Tom Tempelaere.