1

I have a function in C++ that returns pointer values​​:

fPosFirst( int &aId, char *aNname, char *aDirectory );

But I have to pass this to C#. How can I do that?

2 Answers 2

3

You need to examine P/Invoke (Platform Invoke), a way to call native-code functions (C and C++) from .Net/Managed Code (C#).

Sign up to request clarification or add additional context in comments.

Comments

1

This is VB.NET syntax, but you should be able to convert this to C# easily enough.

Private Declare Ansi Sub fPosFirst lib "libraryname" (ByRef aId as Integer, byval aName as StringBuilder, byval aDirectory as StringBuilder)

Now if aNname and aDirectory should have been const char *, you can use String instead of StringBuilder and it gets a lot easier.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.