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

Posted on 2005-05-16
Last Modified: 2013-12-03
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.  :)
Question by:steven808
    1 Comment
    LVL 9

    Accepted Solution

    You have three options:

    1. Call the exported functions directly from the C# application by using the PInvoke layer (see

    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

    3. Wrap the QueAPI.dll exports in managed C++ classes and use these from C# (see

    You can get more information about each of these strategies here:


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now