Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Sep 16, 2019 11:47 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: ActiveX, DLL's and Excedrin
PostPosted: Fri Jun 08, 2012 4:12 pm 
Offline

Joined: Mon Nov 01, 2010 6:28 pm
Posts: 24
I've spent the past couple of days trying to work with some IBM ActiveX/COM dlls that are specific to Windows. I've used
these DLLs many times in many VB programs very successfully and I am able to add the reference into RB as one would
expect.

This code runs perfectly in VB:

Public Function CallAS400Cmd(ByVal My400IP As String, ByVal My400User As String, ByVal My400Password As String, ByVal My400CMD As String) As Boolean
'Define our Objects
Dim I5 As New cwbx.AS400System
Dim MyCMD As New cwbx.Command
'Define our Connection
I5.Define(My400IP)
I5.UserID = My400User
I5.Password = My400Password

'Set the System
MyCMD.system = I5
'Run the Command
MyCMD.Run(My400CMD)
Return True
End Function


For the life of my I cannot get it to work in RB. It always hangs at the MyCMD.system = I5. It states I cannot
set the property for it. I am able verify the I5 Connection as the AS400System object can be used properly but RB
will not let me use it for the MyCMD.Run. I'm not sure if this is a limitation in RB's ActiveX, a bug or simply some small
thing I need to learn. Here's to hoping someone knows what to do with this. If I cannot get this to work I'll likely have
to write a VB webservice and run it like that but I'm trying to move away from .NET whenever possible.

I tried wrapping the CWBX DLL in a VB.NET DLL but found that wouldn't work due to the code being in a class object.

Any help / suggestions / pain relief would be greatly appreciated!

Thanks,
Dwane


Top
 Profile  
Reply with quote  
 Post subject: Re: ActiveX, DLL's and Excedrin
PostPosted: Sat Jun 09, 2012 9:34 am 
Offline
User avatar

Joined: Thu Dec 29, 2011 6:46 pm
Posts: 191
Location: Edmonton, AB, Canada
The ActiveX feature of RB has a BUG in some instances
Look Feedback case : 20691, Maybe it has something to do with you problem

What program did you use to create your DLL ?
I had a similar problem then I compiled the DLL with see: http://forums.realsoftware.com/viewtopic.php?f=1&t=44274

We need a third test to formulate some assuption
Get a third programming software different of VB and RB, demo or free... (FreeBasic, or GoLink, there many)
Create a single application to call the DLL, Test the function...

There were cases which the DLL I created in VB would not work in other application for obvious reasons:
http://www.hermetic.ch/vbm2dll.htm
http://windowsdevcenter.com/pub/a/windows/2005/04/26/create_dll.html
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=54190&lngWId=1

_________________
Regards,
TomazVDaSilva


Clean Code: Robert C. Martin
It is not the language that makes programs appear simple.
It is the programmer that make the language appear simple!


Top
 Profile  
Reply with quote  
 Post subject: Re: ActiveX, DLL's and Excedrin
PostPosted: Mon Jun 11, 2012 8:53 am 
Offline

Joined: Mon Nov 01, 2010 6:28 pm
Posts: 24
The DLLs in question are supplied by IBM as a part of their Client Access software. They work properly in VB and VBA (I use them in both). I have tried downloading 2009R5 and still get the same error.

"Error: Cannot assign a value to this property."

Like I said it would be different if I had not use this successfully many times before. It just seems that RB doesn't like to pass an object in a a parameter to another object. I'm going to see if I can figure out a work around but it looks like I may have to use a webservice to run the command instead. I'm just really trying to NOT use .NET.

Thanks,
Dwane


Top
 Profile  
Reply with quote  
 Post subject: Re: ActiveX, DLL's and Excedrin
PostPosted: Mon Jun 11, 2012 8:58 am 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:48 am
Posts: 3554
Location: Lenexa, KS
Real Studio does not fully implement COM. Period. So while you have used it successfully in VB and VBA it may not (probably will not) work in Real Studio. So until they fully implement COM support the chances of getting it work are low.

It's been on my wish list for 10 years now.

_________________
Bob K.

A blog about being a Real Studio/Xojo developer at http://www.bkeeneybriefs.com


Top
 Profile  
Reply with quote  
 Post subject: Re: ActiveX, DLL's and Excedrin
PostPosted: Mon Jun 11, 2012 10:50 am 
Offline
Real Software Engineer

Joined: Fri Sep 30, 2005 8:28 am
Posts: 242
Location: Unfortunately not Canada
If it works in VBA then it should work using RB's OLEObject. OLEObjects work off the premise that the classes you're interfacing with support a dual interface. When you add a COM component via Project->Add->ActiveX Component the COM classes can be dual or just VTable based. The imported classes provide autocomplete as well, but since it's strictly typed you are not allowed some of the passive rules of dealing with a dual interface. It could be that MyCMD.system accepts multiple interfaces, which COM allows.

Dim I5 As New OLEObject("cwbx.AS400System")
Dim MyCMD As New OLEObject("cwbx.Command")
'Define our Connection
I5.Define(My400IP)
I5.UserID = My400User
I5.Password = My400Password

'Set the System
MyCMD.system = I5
'Run the Command
MyCMD.Run(My400CMD)


Top
 Profile  
Reply with quote  
 Post subject: Re: ActiveX, DLL's and Excedrin
PostPosted: Mon Jun 11, 2012 11:48 am 
Offline

Joined: Mon Nov 01, 2010 6:28 pm
Posts: 24
I had just gotten a VB6 DLL compiled and working but this solution is much cleaner.

Thank you very much that was exactly what I needed!

It worked perfectly.

Dwane


Top
 Profile  
Reply with quote  
 Post subject: Re: ActiveX, DLL's and Excedrin
PostPosted: Mon Jun 11, 2012 6:58 pm 
Offline
User avatar

Joined: Thu Dec 29, 2011 6:46 pm
Posts: 191
Location: Edmonton, AB, Canada
William Yu,

Very good !
I hope we could have the same work around to import components from COMCTL32.OCX

_________________
Regards,
TomazVDaSilva


Clean Code: Robert C. Martin
It is not the language that makes programs appear simple.
It is the programmer that make the language appear simple!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group