473,473 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem in Writting wrapper in Managed C++

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
};

Jun 29 '07 #1
1 1998
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?
--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"DebGuria" wrote:
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
};

Jun 29 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Wayne Gibson | last post by:
Hi all, Please ignore the other post.. The cat jumped on the machine and sent it before I could stop it!! Was wondering if anybody has expericence this problem.. I am writting an application...
1
by: mynab | last post by:
Hello, I am facing an issue I cannot easily solve. I am writing a non-managed C++ application that I want to be extensible using plugins. The goal is to let people write plugins in any language...
0
by: Ola Sprauten | last post by:
I got a .NET class library project where I have written a managed wrapper for some unmanaged code. The managed wrapper is then used by a c# .net application. The problem I am having is that the...
1
by: Adam Clauss | last post by:
I have an unmanaged C++ library that I need to use through C#. I created a Managed C++ class library and through it wrote a wrapper class to call what I need. However, one of the methods (an...
8
by: Nadav | last post by:
Hi, I am writing a performence critical application, this require me to stick to unmanaged C++ as performance is much better using unmanaged C++ ( about 33% better ), Still, I am trying to avoid...
0
by: DotNetJunkies User | last post by:
Background: I am creating a VC++ .NET wrapper for a C++ DLL; the aim is to use this wrapper in C# as shown below: Range r = new Range( 2, 2 ); r = new Cell( “Hello Mum” ); Range is a...
9
by: WithPit | last post by:
I am trying to create an Managed C++ Wrapper around an unmanaged library which contains C++ code. Some of the unmanaged methods returns an returntype which is of the abstract base type (for...
1
by: ukasz Zbik | last post by:
I have project that uses managed c++ where I use c - library, this library contains some variables named generic, during compilation I get error: Error 1 error C2146: syntax error : missing ';'...
2
by: chandramohanp | last post by:
I am having problem to delete a Managed C++ DLL that was used in a pure C# DLL even in the following scenario. 1. Launch the application. This applicatio has its own default applicaiton...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.