// This overload method is used to get ListView Group Item text. internal static unsafe string GetItemText(IntPtr hwnd, NativeMethods.LVGROUP_V6 item, int mask) { ProcessorTypes localBitness; ProcessorTypes remoteBitness; GetProcessTypes(hwnd, out localBitness, out remoteBitness); item.mask = mask; IntPtr textAddress = IntPtr.Zero; int size = 0; // these are the only two fields we ask for right now if (((mask & NativeMethods.LVGF_HEADER) == 0) && ((mask & NativeMethods.LVGF_SUBSET) == 0)) return ""; if (localBitness == remoteBitness) { switch (mask) { case NativeMethods.LVGF_HEADER: textAddress = new IntPtr(&item.pszHeader); size = item.cchHeader; break; case NativeMethods.LVGF_SUBSET: textAddress = new IntPtr(&item.pszSubsetTitle); size = item.cchSubsetTitle; break; } return GetTextWithinStructure(hwnd, NativeMethods.LVM_GETGROUPINFO, new IntPtr(item.iGroupID), new IntPtr(&item), Marshal.SizeOf(item.GetType()), textAddress, size, true); } else if (remoteBitness == ProcessorTypes.Processor32Bit) { LVGROUP_V6_32 item32 = new LVGROUP_V6_32(item); switch (mask) { case NativeMethods.LVGF_HEADER: textAddress = new IntPtr(&item32.pszHeader); size = item32.cchHeader; break; case NativeMethods.LVGF_SUBSET: textAddress = new IntPtr(&item32.pszSubsetTitle); size = item32.cchSubsetTitle; break; } return GetTextWithinStructure(hwnd, NativeMethods.LVM_GETGROUPINFO, new IntPtr(item32.iGroupID), new IntPtr(&item32), Marshal.SizeOf(item32.GetType()), textAddress, size, true); } else if (remoteBitness == ProcessorTypes.Processor64Bit) { LVGROUP_V6_64 item64 = new LVGROUP_V6_64(item); switch (mask) { case NativeMethods.LVGF_HEADER: textAddress = new IntPtr(&item64.pszHeader); size = item64.cchHeader; break; case NativeMethods.LVGF_SUBSET: textAddress = new IntPtr(&item64.pszSubsetTitle); size = item64.cchSubsetTitle; break; } return GetTextWithinStructure(hwnd, NativeMethods.LVM_GETGROUPINFO, new IntPtr(item64.iGroupID), new IntPtr(&item64), Marshal.SizeOf(item64.GetType()), textAddress, size, true); } return ""; }
// This overload method is used to get ListView group data. internal static unsafe bool GetGroupInfo(IntPtr hwnd, ref NativeMethods.LVGROUP_V6 group) { ProcessorTypes localBitness; ProcessorTypes remoteBitness; GetProcessTypes(hwnd, out localBitness, out remoteBitness); if (localBitness == remoteBitness) { int result = 0; fixed (NativeMethods.LVGROUP_V6* pGroup = &group) { result = XSendGetIndex(hwnd, NativeMethods.LVM_GETGROUPINFO, new IntPtr(group.iGroupID), new IntPtr(pGroup), Marshal.SizeOf(group.GetType())); } if (result == group.iGroupID) { return true; } } else if (remoteBitness == ProcessorTypes.Processor32Bit) { LVGROUP_V6_32 group32 = new LVGROUP_V6_32(group); int result = XSendGetIndex(hwnd, NativeMethods.LVM_GETGROUPINFO, new IntPtr(group.iGroupID), new IntPtr(&group32), Marshal.SizeOf(group32.GetType())); if (result == group32.iGroupID) { group = (NativeMethods.LVGROUP_V6)group32; return true; } } else if (remoteBitness == ProcessorTypes.Processor64Bit) { LVGROUP_V6_64 group64 = new LVGROUP_V6_64(group); int result = XSendGetIndex(hwnd, NativeMethods.LVM_GETGROUPINFO, new IntPtr(group.iGroupID), new IntPtr(&group64), Marshal.SizeOf(group64.GetType())); if (result == group64.iGroupID) { group = (NativeMethods.LVGROUP_V6)group64; return true; } } return false; }