internal static int[] GetItemResults(ref IntPtr pInput, int count, bool deallocate)
{
int[] output = null;
if (pInput != IntPtr.Zero && count > 0)
{
output = new int[count];
IntPtr pos = pInput;
for (int ii = 0; ii < count; ii++)
{
OpcRcw.Da.OPCITEMRESULT result = (OpcRcw.Da.OPCITEMRESULT)Marshal.PtrToStructure(pos, typeof(OpcRcw.Da.OPCITEMRESULT));
output[ii] = result.hServer;
if (deallocate)
{
if (result.pBlob != IntPtr.Zero)
{
Marshal.FreeCoTaskMem(result.pBlob);
result.pBlob = IntPtr.Zero;
result.dwBlobSize = 0;
}
Marshal.DestroyStructure(pos, typeof(OpcRcw.Da.OPCITEMRESULT));
}
pos = (IntPtr)(pos.ToInt32() + Marshal.SizeOf(typeof(OpcRcw.Da.OPCITEMRESULT)));
}
if (deallocate)
{
Marshal.FreeCoTaskMem(pInput);
pInput = IntPtr.Zero;
}
}
return output;
}