Hi Thomas,

 

Every COM object can only have a single IDispatch interface, regardless how many other interfaces it may support.  It is up to the implementer of the object to make sure all the functionality of the different VTBL interfaces is accessible to scripting languages through the IDispatch interface.

 

Visual Basic is not using IDispatch, so it can access all COM interfaces of an object.  If you can find a way to access the functionality you need from _vbscript_ (which is also restricted to IDispatch), then I’m sure there’ll be a way to access it from Perl as well.  But if there isn’t, then you may have to implement a wrapper object in e.g. VB to expose the additional functionality through IDispatch.

 

Cheers,

-Jan

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: October 27, 2006 9:22 AM
To: perl-win32-users@listserv.activestate.com
Subject: OLE-object type cast

 


Hi,

in a project we want to use the DCOM-API of a Win98-based measurement instrument.
We need to access different so called Inputs which have some common settings but also some individual settings.
This is mapped to the API by creating a Class "IInput" (which is IDispatch type according to OLEViewer.exe) for all the settings common to all the channels, and to derive other Classes like "IBridgeInput" (which is IInput type according to OLEViewer.exe) for the specific settings.
To my understanding so far IBridgeInput inherits the structure from IInput and adds the additional special features.

Well, so far so good:
The problem arises from the way of access to the objects.
+++The only way+++ to access the API is by referencing a structure in a way like:

my $MyInput = $InputBoard->Inputs->Item(3)  

here the method Item($i) return ++always++ an IInput-type, however the physical situation is:
Item(1) and Item(2) are in fact IInput (only common settings)
Item (3) is an IBridgeInput (certain special settings)
Item (4) is a IIPCInput (other certain special settings)
Item(5) is a ICounterInput (again other special settings)

The API defines this types and exports them, i.e. when I do the same in Visual Basic I just do

Dim MyInput as BridgeInput;   REM make it a bridge input, no matter what is returned
Set MyInput = InputBoard.Inputs.Item(3)

and violas, I can access common ++and++ special settings.

So my question is: Is there a way to cast  an OLE-Object type onto an existing/returned Object of parent-type.
Like:
my $MyInput = $InputBoard->Inputs->Item(3);
castObjectType($MyInput, BridgeInput); # function non-existent

which is a replacement for the explicit "DIM .... as ...." in Visual Basic.

Sorry for the long description, but it's a difficult issue I think,
TIA,
Thomas
 

--------------------------------------------------------------------------------------
Dr. Thomas Bruns                        <[EMAIL PROTECTED]>

        Physikalisch-Technische Bundesanstalt
                               Braunschweig
Arbeitsgruppen: 1.31 & 1.34
Bundesallee 100                         Tel: 0531/592 -  1220
D-38116 Braunschweig              Fax: 0531/592-69-1220
--------------------------------------------------------------------------------------

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to