elpaquito3 Posted June 19, 2008 Report Share Posted June 19, 2008 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. Quote Link to comment
Anders Björk Posted June 19, 2008 Report Share Posted June 19, 2008 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. Quote Link to comment
elpaquito3 Posted June 19, 2008 Author Report Share Posted June 19, 2008 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 Quote Link to comment
Rolf Kalbermatter Posted June 20, 2008 Report Share Posted June 20, 2008 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 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.