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.

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 and later, 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 Not enough memory is available to complete the operation.

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 or later.

The order in which type libraries are added is important. Type libraries added in an earlier call are listed before those 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. The project remembers which type libraries the designer contributed during an earlier session, and the designer remembers which type libraries it contributed. A designer cannot alter the order in which its libraries are referenced after user editing has occurred. A user can remove a reference and then add it again, but the designer 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();