AssocQueryKeyA function (shlwapi.h)

Searches for and retrieves a key related to a file or protocol association from the registry.

Syntax

LWSTDAPI AssocQueryKeyA(
  [in]  ASSOCF   flags,
  [in]  ASSOCKEY key,
  [in]  LPCSTR   pszAssoc,
  [in]  LPCSTR   pszExtra,
  [out] HKEY     *phkeyOut
);

Parameters

[in] flags

Type: ASSOCF

The flags that can be used to control the search. It can be any combination of ASSOCF values, except that only one ASSOCF_INIT value can be included.

[in] key

Type: ASSOCKEY

The ASSOCKEY value that specifies the type of key that is to be returned.

[in] pszAssoc

Type: LPCTSTR

A pointer to a null-terminated string that is used to determine the root key. Four types of strings can be used.

File name extension

A file name extension, such as .txt.

CLSID

A CLSID GUID in the standard "{GUID}" format.

ProgID

An application's ProgID, such as Word.Document.8.

Executable name

The name of an application's .exe file. The ASSOCF_OPEN_BYEXENAME flag must be set in flags.

[in] pszExtra

Type: LPCTSTR

A pointer to an optional null-terminated string with additional information about the location of the string. It is normally set to a Shell verb such as open. Set this parameter to NULL if it is not used.

[out] phkeyOut

Type: HKEY*

A pointer to the key's HKEY value.

Return value

Type: HRESULT

Returns S_OK if successful, or a COM error value otherwise.

Remarks

This function is a wrapper for the IQueryAssociations interface. It is intended to simplify the process of using the interface. For further discussion of how the file and protocol association functions work, see IQueryAssociations.

Note

The shlwapi.h header defines AssocQueryKey as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional, Windows XP [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header shlwapi.h
Library Shlwapi.lib
DLL Shlwapi.dll (version 5.0 or later)