Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / June 2007

Tip: Looking for answers? Try searching our database.

Problem in Writting wrapper in Managed C++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DebGuria - 29 Jun 2007 10:46 GMT
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
};
Peter Ritchie [C# MVP] - 29 Jun 2007 15:46 GMT
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?

Signature

Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual 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.
[quoted text clipped - 39 lines]
>     void * data; // pointer to string data buffer
> };

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.