|
GetObjectInterface Function
|
|
|
Prototype
|
Public Declare Function GetObjectInterface Lib "TclBridge.dll" (poDestination As Object, poSource As Object, puGUID As Any) As Long
|
|
Input
|
The "poSource" parameter, which is the object to query for another interface.
The "puGUID" parameter, which is a GUID structure that contains the IID (interface identifier) of the requested interface.
|
|
Output
|
The "poDestination" parameter, which will contain a reference to the object from the "poSource" parameter with the specified interface as the "default" interface.
|
|
Returns
|
A standard COM automation HRESULT (long integer).
|
|
COM Results
|
Not applicable.
|
|
Side Effects
|
A reference is added to the source object.
|
|
Description
|
This function is primarily used with objects written in Microsoft Visual Basic that implement multiple interfaces.
Traditionally, you would declare an early bound object variable (Dim poObj As ISomeInterface) and then assign the object variable from another object that implements the interface (or create a new object that implements the interface).
With this function, you can accomplish the same thing with a late bound object variable.
|
|
Notes
|
All the interfaces involved with this function must derive from IDispatch (this is not really an issue for objects written with Visual Basic).
The declaration for this function is in the "TclBridgeSupport" (TCLBSUPT.BAS) module.
|
|
Example
|
Private Sub Command1_Click()
Dim plResult As Long Dim poSource As Object Dim poDestination As Object Dim puGUID As GUID ' Set poSource = CreateObject(<some object that implements multiple interfaces>) ' THIS IS NOT AN ACTUAL IID, it is used for illustration only... ' this structure could also be filled via the Windows API function CLSIDFromString if you have access to a string representation of the interface identifier (i.e. a string constant)... puGUID.Data1 = &H47578347 puGUID.Data2 = &HF440& puGUID.Data3 = &HE101& puGUID.Data4(0&) = &H45& puGUID.Data4(1&) = &H0& puGUID.Data4(2&) = &H0& puGUID.Data4(3&) = &H10& puGUID.Data4(4&) = &H2& puGUID.Data4(5&) = &HAE& puGUID.Data4(6&) = &HF1& puGUID.Data4(7&) = &H1B& plResult = GetObjectInterface(poDestination, poSource, puGUID) ' the result will be >= 0 to indicate success... MsgBox "The result is: (" & plResult & ", " & pvResult & ")", vbInformation, App.Title End Sub |