共用方式為


Registry and TypeLib Global Functions

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Registry and TypeLib Global Functions.

These functions provide support for loading and registering a type library.

Important

The functions listed in the following tables cannot be used in applications that execute in the Windows Runtime.

AtlRegisterTypeLib This function is called to register a type library.
AtlUnRegisterTypeLib This function is called to unregister a type library
AtlLoadTypeLib This function is called to load a type library.
AtlUpdateRegistryFromResourceD This function is called to update the registry from the supplied resource.
RegistryDataExchange This function is called to read from, or write to, the system registry. Called by the Registry Data Exchange Macros.

These functions control which node in the registry the program uses to store information.

AtlGetPerUserRegistration Retrieves whether the application redirects registry access to the HKEY_CURRENT_USER ( HKCU) node.
AtlSetPerUserRegistration Sets whether the application redirects registry access to the HKEY_CURRENT_USER ( HKCU) node.

AtlRegisterTypeLib

This function is called to register a type library.

Important

This function cannot be used in applications that execute in the Windows Runtime.

ATLAPI AtlRegisterTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex);

Parameters

hInstTypeLib
The handle to the module instance.

lpszIndex
String in the format "\\N", where N is the integer index of the type library resource. Can be NULL if no index is required.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Remarks

This helper function is utilized by AtlComModuleUnregisterServer and CAtlComModule::RegisterTypeLib.

AtlUnRegisterTypeLib

This function is called to unregister a type library.

Important

This function cannot be used in applications that execute in the Windows Runtime.

ATLAPI AtlUnRegisterTypeLib(
    HINSTANCE hInstTypeLib, 
    LPCOLESTR lpszIndex);

Parameters

hInstTypeLib
The handle to the module instance.

lpszIndex
String in the format "\\N", where N is the integer index of the type library resource. Can be NULL if no index is required.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Remarks

This helper function is utilized by CAtlComModule::UnRegisterTypeLib and AtlComModuleUnregisterServer.

AtlLoadTypeLib

This function is called to load a type library.

Important

This function cannot be used in applications that execute in the Windows Runtime.

ATLINLINE ATLAPI AtlLoadTypeLib(
    HINSTANCE hInstTypeLib,
    LPCOLESTR lpszIndex,
    BSTR* pbstrPath,
    ITypeLib** ppTypeLib);

Parameters

hInstTypeLib
Handle to the module associated with the type library.

lpszIndex
String in the format "\\N", where N is the integer index of the type library resource. Can be NULL if no index is required.

pbstrPath
On successful return, contains the full path of the module associated with the type library.

ppTypeLib
On successful return, contains a pointer to a pointer to the loaded type library.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Remarks

This helper function is utilized by AtlRegisterTypeLib and AtlUnRegisterTypeLib.

AtlUpdateRegistryFromResourceD

This function was deprecated in Visual Studio 2013 and is removed in Visual Studio 2015.

<removed>

Parameters

Return Value

Remarks

RegistryDataExchange

This function is called to read from, or write to, the system registry.

Important

This function cannot be used in applications that execute in the Windows Runtime.

HRESULT RegistryDataExchange(
    T* pT,
    enum RDXOperations rdxOp,
    void* pItem = NULL);

Parameters

pT
A pointer to the current object.

rdxOp
An enum value that indicates which operation the function should perform. See the table in the Remarks section for the allowed values.

pItem
Pointer to the data that is to be read from, or written to, the registry. The data can also represent a key to be deleted from the registry. The default value is NULL.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Remarks

The macros BEGIN_RDX_MAP and END_RDX_MAP expand to a function that calls RegistryDataExchange.

The possible enum values that indicate the operation the function should perform are shown in the following table:

Enum value Operation
eReadFromReg Read data from the registry.
eWriteToReg Write data to the registry.
eDeleteFromReg Delete the key from the registry.

Registry Data Exchange Macros

These macros perform Registry Data Exchange operations.

BEGIN_RDX_MAP Marks the beginning of the Registry Data Exchange map.
END_RDX_MAP Marks the end of the Registry Data Exchange map.
RDX_BINARY Associates the specified registry entry with a specified member variable of type BYTE.
RDX_CSTRING_TEXT Associates the specified registry entry with a specified member variable of type CString.
RDX_DWORD Associates the specified registry entry with a specified member variable of type DWORD.
RDX_TEXT Associates the specified registry entry with a specified member variable of type TCHAR.

See Also

Functions