Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBS and DLL

Status
Not open for further replies.

jtheis

Technical User
Sep 9, 2004
41
US
I have a question that I'm afraid I know the answer to.

I have inherited a project (using ICONICS Genesis 32) that originally had all of the scripting written in VBA. Now, the project is being ported over to the ICONICS WebHMI and all of the scripting has to be rewritten for VBS. The problem is, there are many calls to some .dll files that were created using Delphi. Is there a way to call a .dll file from VBS? I've done some searching online and I don't think I can.

Sorry if this is an obvious question, but this is some of the first programming I've ever had to do.

Thanks for any relpies.
 
These DLL files... are they not ActiveX DLLs?
 
if you have a dll which is registered and call helloworld, which has a module call baseit then this should work to expose the methods etc in that dll

Set oProfile = CreateObject("Helloworld.baseit")

i think
 
Well that will work if they are ActiveX DLLs (ie: COM Objects) but if they are regular C-Style DLLs like Win32 API then that is different.
 
Sorry for the long delay in getting back to everyone. I had to educate myself a little further before I could respond to your questions.

The answer is no, these DLLs are not ActiveX registered DLLs. They were written before there was any idea of putting them on a web server.

I've been going through the Delphi manual and Mastering Delphi 7 to see what I need to do to register them. I am currently just trying to get one of the pieces of the DLL to register as an ActiveX component. However, after I install a component and compile it, I do not get a message back that the component has been installed. I'm guessing it is something in the way that the original file was written, but I don't know for sure. If anyone wants to see the original source, I'll be glad to post it.


Joe
 
"...see what I need to do to register them."

Did you try using regsvr32.exe ???

Another thing you might try is to simply create a wrapper ActiveX DLL. Like if you start a brand new project as an ActiveX DLL and then put a reference to it in that project and then create pass thru methods for the COM interface.
 
Sheco,

It's funny you ask about regsvr32. I was just using it before your message posted. Of the six DLLs that I need to use, only one of them worked registered this way. So I guess that's a step in the right direction!

Here's probably a very stupid question - where do I go to create a new ActiveX DLL? I know that under File -> New -> Other there is the ActiveX tab, but there is no option for ActiveX DLL. Under File -> New -> Other on the New tab there is a DLL Wizard and Resource DLL Wizard. Once I can create the new ActiveX DLL I'm sure I'll have more questions about the rest of your suggestion.

Thanks for the quick replies!


Joe
 
I was confused until I went back up to the top and noticed that you are using Delphi. They call it an ActiveX DLL in VB but I don't know what they call it in Delphi.

Basically it is a DLL that holds a COM object.

I'm sure Delphi has something like this, but I don't know the name for it.
 
Well you were quite clear about it being Delphi but somehow my brain was on automatic.
 
Sheco,

No problem with your brain being on automatic. I'm thinking that I may need to move this thread over to the Delphi forum anyhow, since we've moved away from the VBS and are now in to Delphi and how to make a DLL that will work with VBS.

One more question - now that the one DLL is registered, what is the proper call to get to its functions? Here's what I have written in VBS.

Code:
Dim objTest
Set objTest = CreateObject("testdll.main")
objTest.CheckOPCStatus()

In VB, I can go to View -> Object Browser and find the testdll. Under it is Class Main, and under Main is the Sub CheckOPCStatus. At this point I'm not 100% sure what the sub is going to do, but it doesn't matter (I don't think) because when I run it I can get an error - "Out of memory : 'Create Object'." That's the only thing running! Any ideas? I'm guessing that it's probably something going on in the sub that I can't see.


Joe
 
It looks like the sub CheckOPCStatus has no input and no output so your guess that it is something inside the sub seems reasonable.

Are there any other public methods or properties that you can call on this object that might return something? You know, just to make sure that the problem isn't the COM interface.

Since you have VB you might could just make the ActiveX wrapper DLLs with it instead of Delphi. The trick will be to figure out how to call the DLL from within the VB Project. The the main two ways of doing it would be to either build a type lib for the dll and make a reference to the TLB or, depending on the data types that you need to pass in and out you may also be able to use VB's Declare statement for each function. If you do the latter you'll want to put the Declares in a standard module but still create your ActiveX object on a class module.
 
Unfortunately they're all similar - nothing to return.

I think for right now I'm going to keep my confusion level as limited to one programming language as possible, so I'll have to move this to a Delphi forum.

Thanks for all the help. Once I figure out how to make the DLL the right way I'll probably be back here with questions on using it!


Joe



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top