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

Re: wrapper or direct PInvoke for TomTom 5 SDK by Ginny

Ginny
Tue Oct 11 10:53:50 CDT 2005

Peter,

You might want to check with Peter Foot since he's done a lot of work with
TomTom. You can reach him at www.inthehand.com.

--
Ginny Caughey
.NET Compact Framework MVP


"Peter Hartlén" <peter@data.se> wrote in message
news:OiRNkVmzFHA.3256@TK2MSFTNGP09.phx.gbl...
> 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
>
>



Re: wrapper or direct PInvoke for TomTom 5 SDK by Stephen

Stephen
Tue Oct 11 14:45:20 CDT 2005

You may be re-inventing the wheel.

Google for: ttncf


Peter Hartlén wrote:
> 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
>
>

Re: wrapper or direct PInvoke for TomTom 5 SDK by Peter

Peter
Wed Oct 12 02:40:49 CDT 2005

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" <sounie@hotmail.com> skrev i meddelandet
news:%23HBOBvpzFHA.4032@TK2MSFTNGP15.phx.gbl...
> You may be re-inventing the wheel.
>
> Google for: ttncf
>
>
> Peter Hartlén wrote:
>> 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
>>