1

I am trying to work out how to pass a pointer from my C# interface application to the C++ back-end functionality DLL.

I tried searching Google but can't work out what I'm doing wrong.. I'm used to using * for pointers and just changing the value in the pointer through direct assignment but in C# to C++ interactions I'm using ^ and don't know how to change the variable declared in C# so I can pass values to the C# interface.

in C++ i have

int MediaMogul::readlist(String^ name)
{
    name = "changed value";
    return 0;
}

and in C# I have

private void AddExistingMedia_DoWork(object sender, DoWorkEventArgs e)
{
    MediaMogul item = new MediaMogul();
    String name = "string to be replaced";

    MessageBox.Show(name, "String");

    item.readlist(name)

    MessageBox.Show(name, "String");
}

I'd be grateful for any information regarding .NET C# -> C++ pointers

2
Contributors
1
Reply
17
Views
4 Years
Discussion Span
Last Post by deceptikon
2

You can pass a ref parameter in C++/CLI using the '%' operator, it corresponds to standard C++'s reference operator(&):

int MediaMogul::readlist(String^% name)
{
    name = "changed value";
    return 0;
}

Edited by deceptikon

Votes + Comments
Deep knowledge!
Thankyou, I also worked out from that how to pass to the C++ DLL using item.readlist(ref name); in C#
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.