Jump to content

Calling polymorphic dll built with VB6


Recommended Posts

Help me please !!!!

I'm trying to use a dll build with VB6.

This dll consists on a polymorphic interface (see code in chargeur.zip, contains, the dll and samples of VB6 code)

My VB6 project contains one file that declare the

polymorphic interface (clsChargeur.cls) and two or more other classes that implement

this one (cls2415.cls, cls2430.cls, ....).

This dll works very well and is very convenient under VB6 project.

I can chose and create the instance of the polymorphic dll using, under VB6,

something like that:

Select Case Version

Case Constant.ch4850, Constant.ch4850_pcb130

Set myCharger = New cls4850

Exit Sub

Case Constant.ch2415

Set myCharger = New cls2415

Exit Sub

Case Constant.ch2430

Set myCharger = New cls2430

Exit Sub

End Select

Then I can access properties, methods, ... from the newly create object.

How I can create such as object under Labview ???

A switch case under Labview8.5 does not works.

Each case, use automation open and return via the tunel the reference. (attached file: clsgenerator.vi)

I have an error when I create the output tunel of the switch case:

wire classe confilct. Any idea ???

If I create a more simple VI, without switch case (basic.vi),

when I try to retrieve the reference using Open Automation,

Labview fails in unknow error.

(I have registred my dll, regsvr32 ...).

How I can create and use the interface I want, like in my VB6 sample ????

Thank u very much.

Link to comment

Hi!

Thanks for the repply!!!

First point:

peraps it's something similar to that described in http://forums.lavag.org/COM-component-that...l&pid=29816, but I don't know how to make a library cast ???

First I open, with Automation open, the polymorphic interface (clschargeur) and next I made a cast into cls2415 for example ????

cls2415 is not a type cast ????

Second point:

My dll was build in VB6, so no header file... How can I do ????

I'm a beginner in Labview, Any new ideas ?

Thanks

Link to comment

QUOTE (Anders Björk @ Jun 18 2008, 09:11 AM)

I wonder if do not need to something similar to that discribed in this http://forums.lavag.org/COM-component-that...l&pid=29816 ?

Otherwise import your dll and supply a header file, using Tools, Import and shared library.

VB DLLs are normally ActiveX DLLs. They do not export normal functions (excpet 4 for instantiating and controllling the ActiveX server) but ActiveX objects and consequently can not be imported by the shared library wizard.

Casting references might work in older LabVIEW versions, not sure about the most recent ones since LabVIEW got a lot stricter in allowing to cast object refnums into other refnums.

Basically you chose a class that is the least common denominiator of all the classes that are "polymorphic" and cast each resulting refnum into that refnum class before you leave the case structure. You need to make sure that you do not use a class that allows to select properties or methods that certain classes do not implement as that would certainly cause nasty side effects if you ever execute code to access such a class property or method on a refnum that was casted from a class not implementing these.

All in all not a very good idea in LabVIEW really and if casting doesn't work (anymore) you will have to change your VB object hierarchy. Personally I would think this kind of technique be a poor mans implementation of inheritence.

Rolf Kalbermatter

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.