public bool tryVectorString(
string name,
ushort fid,
ref string[] result)
{
// Returns
bool ret = false;
// The following arraylist wil contain all of the strings
ArrayList retStrings = new ArrayList();
// Enusre that the native message has been created
EnsurePeerCreated();
// Get the strings from the native message
IntPtr globalMemoryPointer = IntPtr.Zero;
uint numberElements = 0;
int code = NativeMethods.mamaMsg_getVectorString(nativeHandle, name, fid, ref globalMemoryPointer, ref numberElements);
if ((MamaStatus.mamaStatus)code == MamaStatus.mamaStatus.MAMA_STATUS_OK)
{
// Only continue if there are actually any strings in the array
if (numberElements > 0)
{
// Create a new array of pointers to hold the native string pointers
IntPtr[] nativeStringArray = new IntPtr[numberElements];
// Copy the entire array over
Marshal.Copy(globalMemoryPointer, nativeStringArray, 0, (int)numberElements);
// Extract each string, one at a time
foreach (IntPtr nextNativeString in nativeStringArray)
{
retStrings.Add(Marshal.PtrToStringAnsi(nextNativeString));
}
}
// The function has succeeded even if there were 0 strings
ret = true;
}
// Return the array of strings
result = (string[])retStrings.ToArray(typeof(string));
return ret;
}