none
Implementing Defines and Callback in C++/CLI RRS feed

  • Question

  • 1.I have a static C library where I have non static call back function. The Client program that register this callback gets Video data from camera .

    Now I am writing Wrapper(DLL) for this in C++/CLI.This Wrapper Dll will be used in C# application.

    How to Implement the callback in C++/CLI so that C# code can register it and gets the video data from it.

     

    2. I have several macro defined in C library how to implement that in C++/CLI as defines are not supported in C#.

    Friday, October 21, 2011 7:13 AM

Answers

All replies

  • #1. You can create a events in your managed class inside the C++/CLI wrapper. C# application can subscribe to these events to get data.

    #2. I am not sure if I understand that. What type of macros do you have in C lib? C# does not support macros but C++/CLI does. Why do you want to define macros in C#?


    Click the 'Vote as Helpful' arrow if this post was helpful.
    Friday, October 21, 2011 10:00 AM
  • I Dont want define macro in C#. I have lot #define in C library for error. How that can mapped in Managed C++/CLI and C#
    Friday, October 21, 2011 11:28 AM
  • Can you post an example?
    Click the 'Vote as Helpful' arrow if this post was helpful.
    Friday, October 21, 2011 5:00 PM
  • These are some of the defines in the C static Library
    #define BCI_SUCCESS 0 ///< Success
    #define BCI_NOT_IMPLEMENTED 1 ///< The function is not implemented
    #define BCI_INIT_ERROR 2 ///< Error during initialization or library not initialized
    #define BCI_INVALID_ARG 3 ///< Invalid argument
    #define BCI_INVALID_HANDLE 4 ///< Invalid handle
    #define BCI_INVALID_DEVICE 5 ///< Invalid device or device cannot be opened
    Monday, October 24, 2011 5:40 AM
  • You can use Enum class to define it:

    public enum BC_Result{BCI_SUCCESS= 0,BCI_NOT_IMPLEMENTED=1,...}


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Paul Zhou Monday, October 31, 2011 6:02 AM
    Tuesday, October 25, 2011 7:20 AM