Share via


IUIAutomationProxyFactoryMapping::InsertEntry Method

Insert an entry into the table of proxy factories.

Syntax

HRESULT InsertEntry(      
    UINT before,
    IUIAutomationProxyFactoryEntry *factory
);

Parameters

  • before
    [in] The zero-based index at which to insert the entry.
  • factory
    [in] The address of the IUIAutomationProxyFactoryEntry interface of the entry to insert.

Return Value

Returns S_OK if successful, or an error value otherwise.

Example

The following example function creates and inserts an entry in the table.

HRESULT AddProxyEntry(IUIAutomationProxyFactory* pFactory)
{
        IUIAutomationProxyFactoryMapping* pMap;
        IUIAutomationProxyFactoryEntry* pEntry;

        // g_pAutomation is a global pointer to IUIAutomation.
        HRESULT hr = g_pAutomation->get_ProxyFactoryMapping(&pMap);   
        if (SUCCEEDED(hr))
        {
            hr = g_pAutomation->CreateProxyFactoryEntry(pFactory, &pEntry);
            if (SUCCEEDED(hr))
            {
                BSTR bstr = SysAllocString(L"MyButton");
                if (bstr != NULL)
                {
                    pEntry->put_ClassName(bstr);
                    SysFreeString(bstr);
                }

                bstr = SysAllocString(L"MyDLL.dll");
                if (bstr != NULL)
                {
                    pEntry->put_ImageName(bstr);
                    SysFreeString(bstr);
                }

                // 
                // Set other properties as needed.
                //

                hr = pMap->InsertEntry(0, pEntry);
                pEntry->Release();
            }
            hr = pMap->Release();
        }
        return hr;
}