IProfferTypeLib::ProfferTypeLib

Adds a reference to a type library to the project.

HRESULT ProfferTypeLib(
REFGUID guidTypeLib,
UINT uVerMaj,
UINT uVerMin,
DWORD dwFlags
);

Parameters

guidTypeLib

[in] Globally unique identifier of the type library to add.

uVerMaj

[in] Major version number of the type library.

uVerMin

[in] Minor version number of the type library.

dwFlags

[in] Flags indicating the kind of type library. With Visual Basic 5.0, this value must be 0.

Return Values

The return value obtained from HRESULT is one of the following:

Return Value

Meaning

S_OK

Success.

E_INVALIDARG

One or more of the arguments is invalid.

E_OUTOFMEMORY

Out of memory.


Comments

The ProfferTypeLib method adds a programmatic reference to a type library. It is the equivalent of choosing References on the Project menu in Visual Basic 5.0.

The order in which type libraries are added is important. Type libraries added in an earlier call are listed before type libraries added in a later call. After type libraries have been added, a user can change the order in which they are referenced by rearranging their names in the References dialog box. The order of reference may affect the user's code, particularly if two type libraries expose the same name.

References are persistent. A project remembers which type libraries a component contributed during an earlier session. A component remembers which type libraries it contributed. A component cannot alter the order in which its libraries are referenced after user editing has occurred. A user may remove a reference and then add it again, but the component cannot control where the reference appears in the project-level list.

Example

The following example queries for the SProfferTypeLib service, then calls the ProfferTypeLib method to add a type library to the project:

hr = m_pServiceProvider->QueryService(SID_SProfferTypeLib, 
                        IID_IProfferTypeLib, (void **)&pProfferTypeLib);
if (FAILED(hr)) return;

// Add the type library.
pProfferTypeLib->ProfferTypeLib(m_guidTypeLib, uMaj, uMin, dwFlags);

// Done.
pProfferTypeLib->Release();