// Helper override to handle common scenario of having a string lParam
        // Handles bi-directional string marshaling
        internal static bool XSend (IntPtr hwnd, int uMsg, IntPtr wParam, ref string str, int maxLength)
        {
            using (SafeProcessHandle hProcess = new SafeProcessHandle(hwnd))
            {
                if (hProcess.IsInvalid)
                {
                    // assume that the hwnd was bad
                    throw new ElementNotAvailableException();
                }

                using (RemoteMemoryBlock rmem = new RemoteMemoryBlock(maxLength * sizeof(char), hProcess))
                {
                    if (rmem.IsInvalid)
                    {
                        return false;
                    }

                    // Send the message...
                    if (Misc.ProxySendMessage(hwnd, uMsg, wParam, rmem.Address) == IntPtr.Zero)
                    {
                        return false;
                    }

                    // Read the string from the remote buffer
                    return rmem.ReadString(out str, maxLength);
                }
            }
        }
        // A generic GetItemText that sends a message to a control then reads memory out of the controls process.
        internal static string GetItemText(IntPtr hwnd, int msg, int index, int textLen)
        {
            if (textLen <= 0)
            {
                return "";
            }

            using (SafeProcessHandle hProcess = new SafeProcessHandle(hwnd))
            {
                if (hProcess.IsInvalid)
                {
                    // assume that the hwnd was bad
                    throw new ElementNotAvailableException();
                }

                using (RemoteMemoryBlock rmem = new RemoteMemoryBlock((textLen + 1) * sizeof(char), hProcess))
                {
                    // Allocate memory for UNICODE string.
                    if (rmem.IsInvalid)
                    {
                        return "";
                    }

                    if (Misc.ProxySendMessage(hwnd, msg, new IntPtr(index), rmem.Address) != IntPtr.Zero)
                    {
                        string itemText;

                        // Read the string from the remote buffer
                        if (rmem.ReadString(out itemText, (textLen + 1)))
                        {
                            return itemText;
                        }
                    }
                }
            }

            return "";

            //ProcessorTypes localBitness;
            //ProcessorTypes remoteBitness;
            //GetProcessTypes(hwnd, out localBitness, out remoteBitness);

            //if (localBitness == remoteBitness)
            //{
            //    return "";
            //}
            //else if (remoteBitness == ProcessorTypes.Processor32Bit)
            //{
            //ToDo: Convert from 64-bit to 32-bit
            //    return "";
            //}
            //else if (remoteBitness == ProcessorTypes.Processor64Bit)
            //{
            //ToDo: Convert from 32-bit to 64-bit
            //    return "";
            //}
            //return "";
        }