Home All Groups Group Topic Archive Search About

how to work with 3rd party SDK

Author
26 Mar 2005 1:05 AM
Sam Carleton
The 3rd party SDK that I would like to use in C# (I am an C/C++
programmer) is designed to be used from C/C++.  This is how it
works:

The vendor is abstracting things a bit.  The real DLL has only one
actual exported method, one of the parameters on the DLL takes an
enum which determines which internal function is being called.
Then the vendor provides a header file with a very large number of
enums and structs.  There is also a file called function.c with
the sample which contains all the different "internal" functions
and wraps up the parameters to send through the on entry point. 

To top it all off, one of the functions in the function.c goes off
to the registry, learns where the DLL is located and then does a
LoadLibrary().

I know that I re-write the whole function.c file in C# and port
the 1000+ lines of header files, too.   But my objective in
working in C# is to speed things up, not slow them down;) 

Is there an easier way of calling this SDK?  I know that I can
compile the function.c as a DLL, but then the issue of the header
files remain, is there any way to include them into the managed
world without having to re-write all the structs and enums?

Sam

Author
26 Mar 2005 2:56 AM
Peter Bromberg [C# MVP]
It sounds like your best bet is to move into the Managed C++ world, and
write a managed C++ wrapper. You will need to translate all the unmanaged
structs etc into their managed counterparts.

The only other alternative I can think of is to P/Invoke your calls into the
unmanaged C++ DLL from C#. But that may not solve the issue of translation
of all the unmanaged structs etc. you will need to look carefully at the
Marshal class which provides a lot of methods to handle this.

Doesn't sound like fun, does it?
Peter

Show quote
"Sam Carleton" <scarleton-nospam@miltonstreet.com> wrote in message
news:tz21e.28100$cC6.20034@fe2.columbus.rr.com...
> The 3rd party SDK that I would like to use in C# (I am an C/C++
> programmer) is designed to be used from C/C++.  This is how it
> works:
>
> The vendor is abstracting things a bit.  The real DLL has only one
> actual exported method, one of the parameters on the DLL takes an
> enum which determines which internal function is being called.
> Then the vendor provides a header file with a very large number of
> enums and structs.  There is also a file called function.c with
> the sample which contains all the different "internal" functions
> and wraps up the parameters to send through the on entry point.
>
> To top it all off, one of the functions in the function.c goes off
> to the registry, learns where the DLL is located and then does a
> LoadLibrary().
>
> I know that I re-write the whole function.c file in C# and port
> the 1000+ lines of header files, too.   But my objective in
> working in C# is to speed things up, not slow them down;)
>
> Is there an easier way of calling this SDK?  I know that I can
> compile the function.c as a DLL, but then the issue of the header
> files remain, is there any way to include them into the managed
> world without having to re-write all the structs and enums?
>
> Sam

AddThis Social Bookmark Button