Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / November 2005

Tip: Looking for answers? Try searching our database.

Unmanaged dll, macro definitions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anna - 16 Nov 2005 04:59 GMT
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
   
TT (Tom Tempelaere) - 16 Nov 2005 18:30 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.