0
0

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();
do
{
pname = new string(*cpp);
LogDebug("Read name: " + pname);
cpp++;
} 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
0
0

A friend found the solution:

Marshal.PtrToStringAnsi(IntPtr pointer)

[code:1su28jhe]
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);
        }

[/code:1su28jhe]

  • You must to post comments
0
0

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.