When using some function in FMod’s C# wrapper we get pointers like the one below:
EventParameter.getInfo(ref int index, ref System.IntPtr name)

I tried two ways to read that name, like going on each char* and reading it till I hit a ‘/0’ and the other one below, but none worked. They all just gave me empty strings.

This is the last code I tried:

[code:1z37mn0d]char** cpp = (char)namePointer.ToPointer();
pname = new string(*cpp);
LogDebug("Read name: " + pname);
} while (
cpp != 0);[/code:1z37mn0d]

What’s the proper way to read those char** names in C#?

Thanks in advance.

  • You must to post comments

A friend found the solution:

Marshal.PtrToStringAnsi(IntPtr pointer)

int numParams = 0;
Errcheck(eventToUse.getNumParameters(ref numParams));
Log("Got " + numParams + " parameters.");
string[] paramNames = new string[numParams];
EventParameter eventParameter = new EventParameter();
for (int i = 0; i < numParams; i++)
Log("Reading param: " + i);

            Errcheck(eventToUse.getParameterByIndex(i, ref eventParameter));

            IntPtr namePointer = new IntPtr();
            int index = 0;
            Errcheck(eventParameter.getInfo(ref index, ref namePointer));

            paramNames[i] = Marshal.PtrToStringAnsi(namePointer);


  • You must to post comments

Glad you found a solution. Thanks for posting it for others to see.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.