static AutomationElement() {
            // Register the ItemsView custom properties, as documented here:
            // http://msdn.microsoft.com/en-us/library/ff486373%28VS.85%29.aspx

            Guid rclsid = CLSID_CUIAutomationRegistrar;
            Guid riid = IID_IUIAutomationRegistrar;
            object obj;
            PInvoke.CoCreateInstance(ref rclsid, IntPtr.Zero, 1, ref riid, out obj);
            IUIAutomationRegistrar pRegistrar = obj as IUIAutomationRegistrar;
            try {
                UIAutomationPropertyInfo propinfo;
                propinfo = new UIAutomationPropertyInfo {
                    guid = ItemCount_Property_GUID,
                    pProgrammaticName = "ItemCount",
                    type = UIAutomationType_Int
                };
                pRegistrar.RegisterProperty(ref propinfo, out UIA_ItemCountPropertyId);
                propinfo = new UIAutomationPropertyInfo {
                    guid = SelectedItemCount_Property_GUID,
                    pProgrammaticName = "SelectedItemCount",
                    type = UIAutomationType_Int
                };
                pRegistrar.RegisterProperty(ref propinfo, out UIA_SelectedCountPropertyId);
                propinfo = new UIAutomationPropertyInfo {
                    guid = ItemIndex_Property_GUID,
                    pProgrammaticName = "ItemIndex",
                    type = UIAutomationType_Int
                };
                pRegistrar.RegisterProperty(ref propinfo, out UIA_ItemIndexPropertyId);
            }
            finally {
                if(pRegistrar != null) Marshal.ReleaseComObject(pRegistrar);
            }
        }
 static AutomationElement() {
     Guid rclsid = CLSID_CUIAutomation;
     Guid riid = IID_IUIAutomation;
     object obj = null;
     PInvoke.CoCreateInstance(ref rclsid, IntPtr.Zero, 1, ref riid, out obj);
     if(obj == null) return;
     pAutomation = obj as IUIAutomation;
     
     rclsid = CLSID_CUIAutomationRegistrar;
     riid = IID_IUIAutomationRegistrar;
     PInvoke.CoCreateInstance(ref rclsid, IntPtr.Zero, 1, ref riid, out obj);
     IUIAutomationRegistrar pRegistrar = obj as IUIAutomationRegistrar;
     try {
         UIAutomationPropertyInfo propinfo;
         propinfo = new UIAutomationPropertyInfo {
             guid = ItemCount_Property_GUID,
             pProgrammaticName = "ItemCount",
             type = UIAutomationType_Int
         };
         pRegistrar.RegisterProperty(propinfo, out UIA_ItemCountPropertyId);
         propinfo = new UIAutomationPropertyInfo {
             guid = SelectedItemCount_Property_GUID,
             pProgrammaticName = "SelectedItemCount",
             type = UIAutomationType_Int
         };
         pRegistrar.RegisterProperty(propinfo, out UIA_SelectedCountPropertyId);
         propinfo = new UIAutomationPropertyInfo {
             guid = ItemIndex_Property_GUID,
             pProgrammaticName = "ItemIndex",
             type = UIAutomationType_Int
         };
         pRegistrar.RegisterProperty(propinfo, out UIA_ItemIndexPropertyId);   
     }
     finally {
         if(pRegistrar != null) Marshal.ReleaseComObject(pRegistrar);
     }
 }