Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IApplicationAssociationRegistration::SetAppAsDefault method

Sets an application as the default for a given type. For more information, see Default Programs. Not intended for use in Windows 8.

Syntax


HRESULT SetAppAsDefault(
  [in] LPCWSTR         pszAppRegistryName,
  [in] LPCWSTR         pszSet,
  [in] ASSOCIATIONTYPE atSetType
);

Parameters

pszAppRegistryName [in]

Type: LPCWSTR

A pointer to a null-terminated Unicode string that specifies the registered name of the application.

pszSet [in]

Type: LPCWSTR

A pointer to a null-terminated Unicode string that contains the file name extension or protocol of the application, such as .mp3 or http.

atSetType [in]

Type: ASSOCIATIONTYPE

One of the ASSOCIATIONTYPE enumeration values that specifies the type of the application named in pszSet, such as file name extension or MIME type.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Examples

This example demonstrates the use of IApplicationAssociationRegistration::SetAppAsDefault in an implementation of a fictitious Contoso browser, setting itself as the default for the .htm file name extension.


HRESULT SetContosoAsDefaultForDotHTM()
{
    IApplicationAssociationRegistration* pAAR;

    HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
                                  NULL,
                                  CLSCTX_INPROC,
                                  __uuidof(IApplicationAssociationRegistration),
                                  (void**)&pAAR);
    if (SUCCEEDED(hr))
    {
        hr = pAAR->SetAppAsDefault(L"Contoso.WebBrowser.1.06",
                                   L".htm",
                                   AT_FILEEXTENSION);

        pAAR->Release();
    }

    return hr;
}

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Shobjidl.h

IDL

Shobjidl.idl

See also

IApplicationAssociationRegistration
Default Programs

 

 

Show:
© 2017 Microsoft