コード例 #1
0
        // This overload method is used to set ListView Item data.
        internal static unsafe bool SetItem(IntPtr hwnd, int index, NativeMethods.LVITEM item)
        {
            ProcessorTypes localBitness;
            ProcessorTypes remoteBitness;
            GetProcessTypes(hwnd, out localBitness, out remoteBitness);

            if (localBitness == remoteBitness)
            {
                return XSend(hwnd, NativeMethods.LVM_SETITEMSTATE, new IntPtr(index), new IntPtr(&item), Marshal.SizeOf(item.GetType()));
            }
            else if (remoteBitness == ProcessorTypes.Processor32Bit)
            {
                LVITEM_32 item32 = new LVITEM_32(item);

                return XSend(hwnd, NativeMethods.LVM_SETITEMSTATE, new IntPtr(index), new IntPtr(&item32), Marshal.SizeOf(item32.GetType()));
            }
            else if (remoteBitness == ProcessorTypes.Processor64Bit)
            {
                LVITEM_64 item64 = new LVITEM_64(item);

                return XSend(hwnd, NativeMethods.LVM_SETITEMSTATE, new IntPtr(index), new IntPtr(&item64), Marshal.SizeOf(item64.GetType()));
            }
            return false;
        }
コード例 #2
0
        //------------------------------------------------------
        //
        //  ListView Control Methods that support cross process / cross bitness
        //
        //------------------------------------------------------

        #region ListView Control Methods

        // This overload method is used to get ListView Item text.
        internal static unsafe string GetItemText(IntPtr hwnd, NativeMethods.LVITEM item)
        {
            ProcessorTypes localBitness;
            ProcessorTypes remoteBitness;
            GetProcessTypes(hwnd, out localBitness, out remoteBitness);

            if (localBitness == remoteBitness)
            {
                return GetTextWithinStructure(hwnd, NativeMethods.LVM_GETITEMW, IntPtr.Zero, new IntPtr(&item), Marshal.SizeOf(item.GetType()), new IntPtr(&item.pszText), item.cchTextMax);
            }
            else if (remoteBitness == ProcessorTypes.Processor32Bit)
            {
                LVITEM_32 item32 = new LVITEM_32(item);

                return GetTextWithinStructureRemoteBitness(hwnd, NativeMethods.LVM_GETITEMW, IntPtr.Zero,
                    new IntPtr(&item32), Marshal.SizeOf(item32.GetType()), new IntPtr(&item32.pszText),
                    item32.cchTextMax, remoteBitness, false);

            }
            else if (remoteBitness == ProcessorTypes.Processor64Bit)
            {
                LVITEM_64 item64 = new LVITEM_64(item);

                return GetTextWithinStructure(hwnd, NativeMethods.LVM_GETITEMW, IntPtr.Zero, new IntPtr(&item64), Marshal.SizeOf(item64.GetType()), new IntPtr(&item64.pszText), item64.cchTextMax);
            }
            return "";
        }