Re: NotSupportedException TomTomSDK
- From: "Peter Foot [MVP]" <feedback@xxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 16 Oct 2005 16:32:54 +0100
The easiest way to marshal this data is as a byte array (268 bytes). Then
use the System.Text.Encoding.Unicode.GetString to extract the inline string.
BitConverter will allow you to get the int members out of the byte
structure. .NETCF v2.0 allows you to do more complex marshalling so you can
declare a structure and mark it up with attributes to define how the members
are marshalled e.g.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)]
public string StreetName;
Peter
--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://www.peterfoot.net
"Jeroen" <no@xxxxxxxx> wrote in message
news:11l4cspq79p1r8c@xxxxxxxxxxxxxxxxxxxxx
> Ok, that indeed does the trick.
>
> One more question:
>
> TTNCom_GetLocationInfoV01( long aLongitude, long aLatitude,
> CTomTomNavigatorCom::TLocationInfoV01 &aLocInfo );
> where the Locationinfo parameter is an structure:
>
> struct TLocationInfoV01
> {
> int iType;
> TCHAR iStreetName[128];
> int iHouseNr1, iHouseNr2;
> };
>
> Any ideas how to declare the TCHAR? (or should i use an other datatype?)
>
> Declaration
> [DllImport("TTNCom.dll", EntryPoint = "TTNCom_GetLocationInfoV01",
> SetLastError=true)]
> public extern static int GetLocationInfoV01( int aLongitude, int
> aLatitude,
> ref TLocationInfoV01 aLocInfo);
>
> "Peter Foot [MVP]" <feedback@xxxxxxxxxxxxxxxxxxxx> schreef in bericht
> news:eYMKTKa0FHA.1028@xxxxxxxxxxxxxxxxxxxxxxx
>> Each of those is a pointer , the first to an enumeration and the second
>> to
> a
>> custom structure - you'll be able to tell from the .h files the layout of
>> this structure. You have two options, if the structures are simple you
>> can
>> either declare them as a struct in managed code and pass by ref, or
> declare
>> as a class and pass directly (classes are byref by nature), the other
> option
>> is to use a byte array of the correct size for the native struct layout
>> (useful if the structure contains inline strings for example) and then
>> use
>> the BitConverter and Buffer classes to extract the data from the relevant
>> places in the byte array. My recollection of the LocationV01 struct is
> that
>> it's simple with all integer members so you can declare as a struct in
>> managed code, you'll also need to define the enum in your managed code to
>> match that in the .h file, then your P/Invoke will look like:-
>>
>> DllImport("TTNCom.dll", EntryPoint = "TTNCom_GetCurrentPositionV01",
>> SetLastError=true)]
>> private static extern int TTNCom_GetCurrentPositionV01( ref EGpsStatus
>> aStatus, ref TTTnLocationV01 aLocation );
>>
>> Peter
>>
>> --
>> Peter Foot
>> Windows Embedded MVP
>> http://www.inthehand.com | http://www.peterfoot.net
>>
>> "Jeroen" <no@xxxxxxxx> wrote in message
>> news:11l26d71e2tqjd7@xxxxxxxxxxxxxxxxxxxxx
>> > Do you also know how to declare and use the
>> >
>> > TTNCom_GetCurrentPositionV01( CTomTomNavigatorCom::EGpsStatus &aStatus,
>> > CTomTomNavigatorCom::TTTnLocationV01 &aLocation );
>> >
>> > because this one doesn't use "normal" parameters
>> >
>> > "Peter Foot [MVP]" <feedback@xxxxxxxxxxxxxxxxxxxx> schreef in bericht
>> > news:uHuYJkY0FHA.3720@xxxxxxxxxxxxxxxxxxxxxxx
>> >> In .NETCF you can't marshal a long (Int64) by value, only pass it by
>> >> reference. However a long in C++ is a 32bit value (Int32 / int in c#)
> so
>> > you
>> >> can change your code to:-
>> >>
>> >> DllImport("TTNCom.dll", EntryPoint = "TTNCom_ShowCoordinatesOnMap",
>> >> SetLastError=true)]
>> >> public extern static int ShowCoordinatesOnMap(int aLongitude, int
>> >> aLatitude );
>> >>
>> >> Peter
>> >>
>> >> --
>> >> Peter Foot
>> >> Windows Embedded MVP
>> >> http://www.inthehand.com | http://www.peterfoot.net
>> >>
>> >> "Jeroen" <no@xxxxxxxx> wrote in message
>> >> news:11l1uqlti40jg43@xxxxxxxxxxxxxxxxxxxxx
>> >> > Hello,
>> >> >
>> >> > I've got some trouble with the tomtom 3 sdk.
>> >> >
>> >> > I'm currently trying the possiblities, and i only get the functons
> that
>> >> > don't use parameters to work:
>> >> >
>> >> > [DllImport("TTNCom.dll", EntryPoint =
>> >> > "TTNCom_BringNavigatorToForeground")]
>> >> > public extern static void BringNavigatorToForeground();
>> >> >
>> >> > If i call this, it works great.
>> >> >
>> >> > But when i call this function:
>> >> > [DllImport("TTNCom.dll", EntryPoint = "TTNCom_ShowCoordinatesOnMap",
>> >> > SetLastError=true)]
>> >> > public extern static int ShowCoordinatesOnMap( long aLongitude, long
>> >> > aLatitude );
>> >> > i get an NotSupportedException
>> >> > i read the documentation and i call it this way:
>> >> >
>> >> > long lon = (long)5257996;
>> >> > long lat = (long)51788699;
>> >> > try
>> >> > {
>> >> > ShowCoordinatesOnMap(lon,lat);
>> >> > }
>> >> > catch (Exception ex)
>> >> > {
>> >> > MessageBox.Show(ex.Message);
>> >> > }
>> >> >
>> >> > this is what the documentation says for the C++ function:
>> >> > 6.2.14. INT ShowCoordinateOnMap( long aLongitude, long aLatitude)
>> >> > Command Parameters:
>> >> > . long aLongitude: longitude specified in WGS84 format (in
>> >> > millionths
>> >> > of
>> >> > degree)
>> >> > . long aLatitude: latitude specified in WGS84 format (in millionths
> of
>> >> > degree)
>> >> > Returns: 0 if successful, non-zero value otherwise.
>> >> > Supported Since: TTN 1.42
>> >> > Centers the map around the given coordinate (zoomed in), specified
>> >> > in
>> >> > WGS84
>> >> > format (longitude and
>> >> > latitude in millionths of degree).
>> >> > Example:
>> >> > INT error = CTomTomNavigatorCom::ShowCoordinateOnMap(4860000,
>> >> > 52380000);
>> >> > 6. Communicating with TomTom Navigator from C++
>> >> > 31
>> >> > if (error)
>> >> > {
>> >> > ::AfxMessageBox(TEXT("Failed to center around a point in
> Amsterdam"));
>> >> > }
>> >> >
>> >> >
>> >> > So'm pretty sure the parameters itself are correct.
>> >> > Any ideas as to what i'm doing wrong?
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>
.
- Follow-Ups:
- Re: NotSupportedException TomTomSDK
- From: Jeroen
- Re: NotSupportedException TomTomSDK
- References:
- NotSupportedException TomTomSDK
- From: Jeroen
- Re: NotSupportedException TomTomSDK
- From: Peter Foot [MVP]
- Re: NotSupportedException TomTomSDK
- From: Jeroen
- Re: NotSupportedException TomTomSDK
- From: Peter Foot [MVP]
- Re: NotSupportedException TomTomSDK
- From: Jeroen
- NotSupportedException TomTomSDK
- Prev by Date: Re: Porting Application to WM2005
- Next by Date: Need help - Mobile 2005 Remote Dispaly
- Previous by thread: Re: NotSupportedException TomTomSDK
- Next by thread: Re: NotSupportedException TomTomSDK
- Index(es):
Relevant Pages
|