Problem in Writting wrapper in Managed C++

D

DebGuria

We are writing a wrapper in Managed C++. Wrapper is based on a C dll.
That wrapper will be used from .Net based application and VB also.

Our initial understanding that a .NET Application developer will pass
a delegate to the Managed C++ wrapper and in this wrapper, we have to
cast the delegate into function pointer. The argument list of that
function pointer is not compatible in .NET.

A .NET developer will pass a delegate to get the desired output. Is
their any other way?

..Please guide, how we will write wrapper for the following C Code?

SetProgressProc(void * userdata, ProgressProc callback);

// message callback proc
typedef void __stdcall MessageProc(
const void * context, // IN: message proc context
MyString & text, // OUT: message text
int & number); // OUT: message number

// progress callback proc
typedef bool __stdcall ProgressProc( // RETURN: cancel operation?
double progress, // IN: fractional progress (0.0 .. 1.0)
const void * userdata, // IN: progress callback userdata
const void * context, // IN: message proc context
MessageProc * message, // IN: message proc; else 0
unsigned int step, // IN: global step number (1 .. count)
unsigned int count); // IN: global step count

struct MyString
{
enum Type // encoding type
{
Type_ASCII = 1, // local encoding (8-bit)
Type_UTF8 = 2, // Unicode (8-bit)
Type_Wide = 3, // Unicode (wchar_t)
};

Type type; // encoding type
size_t size; // size of string data buffer in characters
void * data; // pointer to string data buffer
};
 
G

Guest

Is this Managed C++ (Visual C++ 2003) or C++/CLI (Visual C++ 2005)?

If it's a managed application written in C++ why would you need to convert
the delegate to a function pointer, why not use it as is?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top