[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

pinvoke c dll callback function?

Asked by steven808 in C# Programming Language

Hi,

I've got a third party c dll that I'm trying to make function calls to from c#.  I'm using pinvoke to do this, but I'm new to c#, so I'm not sure if I'm doing this right.  One of the function calls from c# passes a callback function to and i'm not sure how to implement this.  Here's the code

[c]
//QueAPI.dll

typedef uint16 QueErrT16; enum
    {
    queErrNone    = 0,              /* Success                                       */
    queErrNotOpen = 1,           /* Close() without having called open() first    */
    queErrBadArg,                   /* Invalid parameter passed to function          */
    queErrMemory,                   /* Out of memory                                 */
    queErrNoData,                   /* No data available                             */
    queErrAlreadyOpen,              /* The Que API is already open                   */
    queErrInvalidVersion,           /* The Que API is an incompatable version        */
    queErrComm,                     /* There was an error communicating with the API */
    queErrCmndUnavail,              /* The command is unavaialbe                     */
    queErrStillOpen,                /* Library is still open                         */
    queErrFail,                     /* General failure                               */
    queErrCancel                    /* Action cancelled by user                      */
    };

typedef uint8 QueNotificationT8; enum
    {
    queLocationChange       = 0,    /* The GPS position has changed                 */
    queStatusChange         = 1,    /* The GPS status has changed                   */
    queLostFix              = 2,    /* The quality of the GPS position computation
                                        has become less than two dimensional        */
    queSatDataChange        = 3,    /* The GPS satellite data has changed           */
    queModeChange           = 4,    /* The GPS mode has changed                     */
    queEvent                = 5,    /* An event has occurred (i.e. sunrise/set,
                                       route has started/ended, etc. )              */
    queCPOPositionChange    = 6,    /* The GPS CPO position data has been updated   */
    queSatelliteInstChange  = 7,    /* THe GPS CPO satellite data has been updated  */

    queUserNotificationCount,       /* Count of change type enumerations(user only) */

    // Internal notifications (do not publish, not visible to end user)
    quePickPointComplete,       /* The user has picked a position.              */
    queNotificationCount,       /* Count of change type enumerations (all)      */

    queInvalid              = 0xFF, /* Invalid message. Ignore                      */
    };

typedef void (__stdcall* QueNotificationCallback)( QueNotificationT8 );

__declspec(dllexport) QueErrT16 QueAPIOpen( QueNotificationCallback callback );


[c#]
//QueAPI.cs

public enum QueErrT16
{
      queErrNone    = 0,              /* Success                                       */
      queErrNotOpen = 1,            /* Close() without having called open() first    */
      queErrBadArg,                   /* Invalid parameter passed to function          */
      queErrMemory,                   /* Out of memory                                 */
      queErrNoData,                   /* No data available                             */
      queErrAlreadyOpen,              /* The Que API is already open                   */
      queErrInvalidVersion,           /* The Que API is an incompatable version        */
      queErrComm,                     /* There was an error communicating with the API */
      queErrCmndUnavail,              /* The command is unavaialbe                     */
      queErrStillOpen,                /* Library is still open                         */
      queErrFail,                     /* General failure                               */
      queErrCancel                    /* Action cancelled by user                      */
}

public enum QueNotificationT8 : byte
{
      queLocationChange       = 0,    /* The GPS position has changed                 */
      queStatusChange         = 1,    /* The GPS status has changed                   */
      queLostFix              = 2,    /* The quality of the GPS position computation
                        has become less than two dimensional        */
      queSatDataChange        = 3,    /* The GPS satellite data has changed           */
      queModeChange           = 4,    /* The GPS mode has changed                     */
      queEvent                = 5,    /* An event has occurred (i.e. sunrise/set,
                  route has started/ended, etc. )              */
      queCPOPositionChange    = 6,    /* The GPS CPO position data has been updated   */
      queSatelliteInstChange  = 7,    /* THe GPS CPO satellite data has been updated  */

      queUserNotificationCount,       /* Count of change type enumerations(user only) */

      // Internal notifications (do not publish, not visible to end user)
      quePickPointComplete,       /* The user has picked a position.              */
      queNotificationCount,       /* Count of change type enumerations (all)      */

      queInvalid              = 0xFF, /* Invalid message. Ignore                      */
}

//I don't know how to implement the call back function that QueNotificationCallback would call here.

[DllImport("QueAPI.dll")]
public static extern QueErrT16 QueAPIOpen(QueNotificationCallback callback);



So that's the code I'm working with.  The QueAPIOpen function is what I'm trying to call from c# to the c dll.

Thanks
[+][-]06/01/05 10:26 PM, ID: 14128077Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: C# Programming Language
Sign Up Now!
Solution Provided By: AlexFM
Participating Experts: 2
Solution Grade: A
 
[+][-]06/03/05 02:25 AM, ID: 14137892Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/25/05 08:45 AM, ID: 14300195Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07/05/05 04:05 AM, ID: 14367710Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07/09/05 01:18 AM, ID: 14403059Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93