Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 744
  • Last Modified:

Garmin M5: Calling unmanaged dll (c++) functions, enums, structs from managed code (c#) for Pocket PC.

I'm looking to build an application in c# that integrates GPS.  I'm building the application to be used on the Garmin M5.  However the SDK that came with the M5 is all in c++.  So I'd like to build a dll that I'll be able to call functions passing and returning structs and enums from c#.  What was included with the Garmin SDK was a bunch of .h files, a dll, and a lib file.

.h files included are:

the dll files included is:

and the lib file included is:

The SDk only mentions the .h files and makes no references to the dll file, so I'm not sure what's in that file.  But I'm guessing that it's got all the same functions in there as well.  Is there a way that I can see if it's got the functions in there?

Also, the SDK mentions that in order to use the GPS funcationality all I need to include is the GPSLib.h file.  I looked at the GPSLib.h file and that simply #includes the QueApi.h file.  I looked in there and that #includes the QuePrvApi.h and the QuePubApi.h files.  Then those #include the QueApiTypes.h file.  So I'm not quite sure how to go about this.

So here are my question:
1)  How can I found out if I can use the provided QueApi.dll?
2)  If I can use the QueApi.dll, can I use the .h files to figure out what functions to call?
3)  Basically, how can I use the provided .h or dll in c#?

There are so many different questions in this one question, please don't hesitate to ask me for clarification on anything.

Thanks in advance.  :)
1 Solution
You have three options:

1. Call the exported functions directly from the C# application by using the PInvoke layer (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp09192002.asp)

2. Wrap the QueAPI.dll in a COM server written in C++, then use the functionality in your C# application by going through the .NET COM Interop (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcwlkCOMInteropPart1CClientTutorial.asp)

3. Wrap the QueAPI.dll exports in managed C++ classes and use these from C# (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp09192002.asp)

You can get more information about each of these strategies here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp09192002.asp


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now