// This overload method is used to get SysHeader Item text. internal static unsafe string GetItemText(IntPtr hwnd, int index, NativeMethods.HDITEM item) { ProcessorTypes localBitness; ProcessorTypes remoteBitness; GetProcessTypes(hwnd, out localBitness, out remoteBitness); if (localBitness == remoteBitness) { return GetTextWithinStructure(hwnd, NativeMethods.HDM_GETITEMW, new IntPtr(index), new IntPtr(&item), Marshal.SizeOf(item.GetType()), new IntPtr(&item.pszText), item.cchTextMax); } else if (remoteBitness == ProcessorTypes.Processor32Bit) { HDITEM_32 item32 = new HDITEM_32(item); return GetTextWithinStructureRemoteBitness( hwnd, NativeMethods.HDM_GETITEMW, new IntPtr(index), new IntPtr(&item32), Marshal.SizeOf(item32.GetType()), new IntPtr(&item32.pszText), item32.cchTextMax, remoteBitness, false); } else if (remoteBitness == ProcessorTypes.Processor64Bit) { HDITEM_64 item64 = new HDITEM_64(item); return GetTextWithinStructure(hwnd, NativeMethods.HDM_GETITEMW, new IntPtr(index), new IntPtr(&item64), Marshal.SizeOf(item64.GetType()), new IntPtr(&item64.pszText), item64.cchTextMax); } return ""; }
//------------------------------------------------------ // // SysHeader Control Methods that support cross process / cross bitness // //------------------------------------------------------ #region SysHeader Control Methods // This overload method is used to get SysHeader Item data. internal static unsafe bool GetItem(IntPtr hwnd, int index, ref NativeMethods.HDITEM item) { ProcessorTypes localBitness; ProcessorTypes remoteBitness; GetProcessTypes(hwnd, out localBitness, out remoteBitness); if (localBitness == remoteBitness) { fixed (NativeMethods.HDITEM* pItem = &item) { return XSend(hwnd, NativeMethods.HDM_GETITEMW, new IntPtr(index), new IntPtr(pItem), Marshal.SizeOf(item.GetType())); } } else if (remoteBitness == ProcessorTypes.Processor32Bit) { HDITEM_32 item32 = new HDITEM_32(item); bool result = XSend(hwnd, NativeMethods.HDM_GETITEMW, new IntPtr(index), new IntPtr(&item32), Marshal.SizeOf(item32.GetType())); if (result) { item = (NativeMethods.HDITEM)item32; } return result; } else if (remoteBitness == ProcessorTypes.Processor64Bit) { HDITEM_64 item64 = new HDITEM_64(item); bool result = XSend(hwnd, NativeMethods.HDM_GETITEMW, new IntPtr(index), new IntPtr(&item64), Marshal.SizeOf(item64.GetType())); if (result) { item = (NativeMethods.HDITEM)item64; } return result; } return false; }