wrapper or direct PInvoke for TomTom 5 SDK

P

Peter Hartlén

Hi!

I'm playing with the thought of creating my own .NET wrapper for a C++ SDK
(TomTom 5 SDK in this case).

What are my alternatives? Considering there are function calls with
non-blittable structures, a custom C-wrapper which exposes each function
call with only non-struct arguments sounds most logical. But perhaps it is
possible to use .NET right away?

For example, a simple function (using dumpbin) for retrieveing the
sdk-version has the following export:
?GetSDKVersion@CTomTomAPI@@QAAHPAUTError@1@PAUTVersion@1@@Z

The function has the following definition:
INT GetSDKVersion(TError* aError, TVersion* aVersion)

TError has the following definition:
int iError

TVersion has the following definitions:
char iVersion[16];
int iBuildNumber;

What would your recommendation be?

1. Create a C++-wrapper that exposes the function calls like this:
GetSDKVersion(int iError, char cVersion[16], int iBuildNumber) so it's easy
to call the functions from a managed environment. I don't have much
C-experience so this is not a trivial thing for me in the initial phase.

2. Create the structures/classes in C#-manner and use some tricks (I believe
Alex Feinman wrote an article about how to pinvoke complex structures but I
have lost the link :( ).

Thanks in advance,

Peter
 
P

Peter Hartlén

Yes I know, but I don't like the idea of having too many 3rd party products
involved in my projects. I also like the idea of only exposing the functions
and methods I need, keeping the size of the dll's at a minimum...

The question was actually intended as a general question, so apart from
TomTom, how do you integrate with unmanaged dlls that has complex structs in
their function calls? Plain .NET wrapper or a unmanaged wrapper that exposes
the function calls in an easier manner???

Thanks for any reply!

/ Peter



Stephen Souness said:
You may be re-inventing the wheel.

Google for: ttncf

Hi!

I'm playing with the thought of creating my own .NET wrapper for a C++
SDK (TomTom 5 SDK in this case).

What are my alternatives? Considering there are function calls with
non-blittable structures, a custom C-wrapper which exposes each function
call with only non-struct arguments sounds most logical. But perhaps it
is possible to use .NET right away?

For example, a simple function (using dumpbin) for retrieveing the
sdk-version has the following export:
?GetSDKVersion@CTomTomAPI@@QAAHPAUTError@1@PAUTVersion@1@@Z

The function has the following definition:
INT GetSDKVersion(TError* aError, TVersion* aVersion)

TError has the following definition:
int iError

TVersion has the following definitions:
char iVersion[16];
int iBuildNumber;

What would your recommendation be?

1. Create a C++-wrapper that exposes the function calls like this:
GetSDKVersion(int iError, char cVersion[16], int iBuildNumber) so it's
easy to call the functions from a managed environment. I don't have much
C-experience so this is not a trivial thing for me in the initial phase.

2. Create the structures/classes in C#-manner and use some tricks (I
believe Alex Feinman wrote an article about how to pinvoke complex
structures but I have lost the link :( ).

Thanks in advance,

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

pinvoking with pointers 5

Top