Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This method maps a name to a member of a type, or binds global variables and functions contained in a type library.

Syntax

HRESULT Bind(
  OLECHAR FAR* 
szName, 
  unsigned long 
lHashVal, 
  unsigned short 
wFlags, 
  ITypeInfo FAR* FAR* 
ppTInfo, 
  DESCKIND FAR* 
pDescKind, 
  BINDPTR FAR* 
pBindPtr 
);

Parameters

szName

[in] Null-terminated string that contains the name to be bound.

lHashVal

[in] Hash value for the name computed by LHashValOfNameSys.

wFlags

[in] Flags word that contains one or more of the IDispatch::Invokeflags defined in the INVOKEKINDenumeration. Specifies whether the name was referenced as a method or a property.

When binding to a variable, specify the flag INVOKE_PROPERTYGET. Specify zero to bind to any type of member.

ppTInfo

[out] If a FUNCDESCor VARDESCwas returned, then ppTInfois a pointer to a pointer to the type description that contains the item to which it is bound.

pDescKind

[out] Pointer to a DESCKINDenumerator that indicates whether the name bound to is a VARDESC, FUNCDESC, or TYPECOMP. If there was no match, points to DESCKIND_NONE.

pBindPtr

[out] On return, contains a pointer to the bound-to VARDESC, FUNCDESC, or ITypeCompinterface.

Return Value

The following table shows the return values for this function.

Value Description

S_OK

Success.

E_OUTOFMEMORY

Out of memory.

E_INVALIDARG

One or more of the parameters is invalid.

TYPE_E_IOERROR

The function could not read from the file.

TYPE_E_INVDATAREAD

Invalid data.

TYPE_E_UNSUPFORMAT

The type library has an older format.

TYPE_E_INVALIDSTATE

The type library could not be opened.

TYPE_E_AMBIGUOUSNAME

More than one instance of this name occurs in the type library.

Remarks

Use Bindfor binding to the variables and methods of a type, or for binding to the global variables and methods in a type library.

The returned DESCKINDpointer pDescKindindicates whether the name was bound to a VARDESC, a FUNCDESC, or to an ITypeCompinstance.

The returned pBindPtrpoints to the VARDESC, FUNCDESC, or ITypeComp.

If a data member or method is bound to, then ppTInfopoints to the type description that contains the method or data member.

If Bindbinds the name to a nested binding context, it returns a pointer to an ITypeCompinstance in pBindPtrand a NULL type description pointer in ppTInfo.

For example, if the name of a type description is passed for a module (TKIND_MODULE), enumeration (TKIND_ENUM), or coclass (TKIND_COCLASS), Bindreturns the ITypeCompinstance of the type description for the module, enumeration, or coclass.

This feature supports languages such as Visual Basic that allow references to members of a type description to be qualified by the name of the type description. For example, a function in a module can be referenced by modulename . functionname.

The members of TKIND_ENUM, TKIND_MODULE, and TKIND_COCLASS types marked as Application objects can be bound to directly from ITypeComp, without specifying the name of the module. The ITypeCompof a coclass defers to the ITypeCompof its default interface.

As with other methods of ITypeComp, ITypeInfo, and ITypeLib, the calling code is responsible for releasing the returned object instances or structures. If a VARDESCor FUNCDESCis returned, the caller is responsible for deleting it with the returned type description and releasing the type description instance itself. Otherwise, if an ITypeCompinstance is returned, the caller must release it.

Special rules apply if you call a type library's Bindmethod, passing it the name of a member of an Application object class (a class that has the TYPEFLAG_FAPPOBJECT flag set).

In this case, Bindreturns DESCKIND_IMPLICITAPPOBJ in pDescKind,a VARDESC that describes the Application object in pBindPtr, and the ITypeInfoof the Application object class in ppTInfo.

To bind to the object, ITypeInfo::GetTypeCompmust make a call to get the ITypeCompof the Application object class, and then reinvoke its Bindmethod with the name initially passed to the type library's ITypeComp.

The caller should use the returned ITypeInfopointer ( ppTInfo) to get the address of the member.

The wflagsparameter is the same as the wflagsparameter in Invoke.

Requirements

Header oaidl.h, oaidl.idl
Library oleaut32.lib, uuid.lib
Windows Embedded CE Windows CE 2.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also