PDA

View Full Version : Referencing dlls from Vbscript


mxbush
05-13-2004, 07:29 PM
How can I reference dlls from the vbscript environment provided by visual build. Other tools and IDEs such as Visual Basic support this process by providing the function of Project | Reference settings.

At this stage I'm getting around this by creating components under Visual Basic and running them from VisBuildPro. As most of these components are trivial complexity (eg. performing clear case baseline comparisons, creating and destroying virtual directories etc) I would much prefer to do this inside VisBuildPro directly.

Also, I would prefer to use early binding rather than late binding and have "option explicit" turned on.

kinook
05-14-2004, 08:06 AM
Script [1] hosting environments such as Visual Build Pro, Internet Explorer, WSH, etc., are inherently late-bound and typeless. Rather then setting a reference to a type library, you simply create the component you need from its ProgId and call its methods.

Many components are callable from such a script environment (any class that implements IDispatch and uses Automation-compatible method signatures), including the FileSystemObject [2], MSXML [3], the VBP objects, etc. Start at 'script' in the help index for all the ways you can incorporate scripting into your VBP projects and for links to additional documentation on using scripting in general. The Script.bld and Advanced.bld samples demonstrate this, as well as many of the FAQs [4].

When using VBScript [5], you can use Option Explicit to require variable declaration before use. Finally, since any VB6 ActiveX DLL project is script-compatible, you can continue to create your custom components in Visual Basic and call them from script in VBP.

[1] http://msdn.microsoft.com/library/default.asp?url=/nhp/Default.asp?contentid=28001169
[2] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/jsfsotutor.asp
[3] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk30/htm/xmmscxmloverview.asp
[4] http://www.kinook.com/Forum/forumdisplay.php?forumid=13
[5] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriVBScript.asp