private List<Guid> ReadClasses(IOPCEnumGUID enumerator)
{
List<Guid> guids = new List<Guid>();
int fetched = 0;
Guid[] buffer = new Guid[10];
do
{
try
{
IntPtr pGuids = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Guid))*buffer.Length);
try
{
enumerator.Next(buffer.Length, pGuids, out fetched);
if (fetched > 0)
{
IntPtr pos = pGuids;
for (int ii = 0; ii < fetched; ii++)
{
buffer[ii] = (Guid)Marshal.PtrToStructure(pos, typeof(Guid));
pos = (IntPtr)(pos.ToInt64() + Marshal.SizeOf(typeof(Guid)));
guids.Add(buffer[ii]);
}
}
}
finally
{
Marshal.FreeCoTaskMem(pGuids);
}
}
catch
{
break;
}
}
while (fetched > 0);
return guids;
}