ComHelper

COM and ACTIVEX Programming made easier in HotBasic

Part I – Getting started

General Summary

Part I – Getting started

Part II – Using ComHelper

Part III – Using a helper file with the Use Invoke option

Part IV – Using a helper file without the Use Invoke option

Part V – Using an ActiveX helper file

Part VI – Using COM events

Read this and start leveraging the power of COM programming in HotBasic in 15 minutes.

 

What are COM and ACTIVEX, in two words?

COM programming is an advanced programming technique that consists of using libraries of pre-programmed "objects" that carry out specific tasks. It can be loading a .JPG image, creating a desktop shortcut, or thousands of other things.

The core concept of COM programming is that of Interface. An interface is a set of subroutines that apply to an object. You never actually see an object, but you access it through an interface. Object and interfaces code is located in "library files", often DLLs.

ActiveX objects are components that you can put on a form, pretty much like HotBasic's buttons, edit fields, etc. The difference is that they're not native components of HotBasic. They are handled by Windows. What ComHelper does is wrap them up so that you can access them simply, in a way that looks very much like how you use the ordinary form objects of HotBasic. ActiveX objects are a kind of COM objects.

ComHelper, COM programming made easier in HotBasic

Windows maintains internal documentation about many objects and interfaces. ComHelper uses this documentation to let you do 2 things easily:

1) browse and search through the registered objects and interfaces,

2) generate HotBasic include files to access the objects and interfaces you choose.

Getting started

Prerequisite: you need to have the file TLBINF32.DLL installed.

How to know if you have it: try running ComHelper. If you don't, il will tell you at startup.

What to do then:
. locate TLBINF32.DLL on the internet. Be sure that version is v1.1.81.69 or later. Some previous versions don't work with ComHelper.
. download it to your windows\system32 directory
. register it by typing: "REGSVR32 TLBINF32" from the command prompt.

You’re ready to run ComHelper and to jump to the Using ComHelper section.

How does ComHelper works?

ComHelper doesn't actually contain any information. It just looks it up in Windows files. It does so by using a COM object (yes!) called TLIApplication, that is supported by the TLBINF32.DLL file.

Was ComHelper used to write ComHelper?

Well, no, because it didn't exist when I wrote it :)

But if I had to write it again, I would generate a ComHelper helper file from TLBINF32.DLL and it would considerably simplify the programming.

Original idea

The original idea for ComHelper derives from TypeLibViewer, an excellent utility by José Roca. ComHelper is tailor-made for HotBasic and is extended to support ActiveX objects.