示例#1
0
        ////////////////
        /// Get/Set owner
        private void TestOwner()
        {
            int    hr;
            IntPtr owner1, owner2;

            // Read the current value
            hr = m_ivw.get_Owner(out owner1);
            Marshal.ThrowExceptionForHR(hr);

            // Change it
            hr = m_ivw.put_Owner((IntPtr)(owner1.ToInt32() + 1));
            Marshal.ThrowExceptionForHR(hr);

            // Re-read
            hr = m_ivw.get_Owner(out owner2);
            Marshal.ThrowExceptionForHR(hr);

            // Put it back to null
            hr = m_ivw.put_Owner(IntPtr.Zero);
            Marshal.ThrowExceptionForHR(hr);

            // Make sure the value we set is what we just read
            Debug.Assert(owner1.ToInt32() + 1 == owner2.ToInt32(), "get/set Owner");
        }