// This overload method is used to get ListView Group Item text. internal static unsafe string GetItemText(IntPtr hwnd, NativeMethods.LVGROUP item) { ProcessorTypes localBitness; ProcessorTypes remoteBitness; GetProcessTypes(hwnd, out localBitness, out remoteBitness); if (localBitness == remoteBitness) { // obtain group string (header only) if (Environment.OSVersion.Version.Major == 5) { return ListView_V6_GetGroupTextOnWinXp(hwnd, item); } return GetTextWithinStructure(hwnd, NativeMethods.LVM_GETGROUPINFO, new IntPtr(item.iGroupID), new IntPtr(&item), Marshal.SizeOf(item.GetType()), new IntPtr(&item.pszHeader), item.cchHeader); } else if (remoteBitness == ProcessorTypes.Processor32Bit) { LVGROUP_32 item32 = new LVGROUP_32(item); // obtain group string (header only) if (Environment.OSVersion.Version.Major == 5) { return ListView_V6_GetGroupTextOnWinXp(hwnd, item32); } return GetTextWithinStructure(hwnd, NativeMethods.LVM_GETGROUPINFO, new IntPtr(item32.iGroupID), new IntPtr(&item32), Marshal.SizeOf(item32.GetType()), new IntPtr(&item32.pszHeader), item32.cchHeader); } else if (remoteBitness == ProcessorTypes.Processor64Bit) { LVGROUP_64 item64 = new LVGROUP_64(item); // obtain group string (header only) if (Environment.OSVersion.Version.Major == 5) { return ListView_V6_GetGroupTextOnWinXp(hwnd, item64); } return GetTextWithinStructure(hwnd, NativeMethods.LVM_GETGROUPINFO, new IntPtr(item64.iGroupID), new IntPtr(&item64), Marshal.SizeOf(item64.GetType()), new IntPtr(&item64.pszHeader), item64.cchHeader); } return ""; }
// This overload method is used to get ListView group data. internal static unsafe bool GetGroupInfo(IntPtr hwnd, ref NativeMethods.LVGROUP group) { ProcessorTypes localBitness; ProcessorTypes remoteBitness; GetProcessTypes(hwnd, out localBitness, out remoteBitness); if (localBitness == remoteBitness) { int result = 0; fixed (NativeMethods.LVGROUP* 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_32 group32 = new LVGROUP_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)group32; return true; } } else if (remoteBitness == ProcessorTypes.Processor64Bit) { LVGROUP_64 group64 = new LVGROUP_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)group64; return true; } } return false; }