CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Location
    Jerusalem, Israel
    Posts
    304

    MC++ function that receives void * parameter

    Hello,
    I'm writing a wrapper class in MC++ that call a c++ function that its prototype looks like this:
    void func1(int length, void *);

    How the MC++ wrapper for this will look like?
    And how the call from C# will look like?

    How can I pass any kind of parameter from C# to my MC++ wrapper class?
    InfraRed.
    Please rate my post, if it helped you.

  2. #2
    Join Date
    Dec 2003
    Location
    Montreal
    Posts
    58

    Re: MC++ function that receives void * parameter

    Assuming C++/CLI (i.e. VS 2005 or later, otherwise upgrade) the wuestion is what managed thing do you wish to pass in "void *" ?
    C++/CLI: void Mfunc1 (System::Int32 length, System::Object^ thing)
    C#: looks same as C++/CLI (just replace :: with .)
    C++: convert reference to thing into a pointer and use that.
    e.g.
    Code:
    GCHandle myGcPointer = GCHandle::Alloc((ManagedReference);
    myNativePointer = myGcPointer.Target;
    But this is a pointer to a Managed object. This is propably not what you want, so if void * is say a structure, create the native structure and copy from the managed to the native to use in you native call.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured