Tutorial 6: How to Register Your ActiveX Components on the Computer Science Machines

by Mike Rounding

Something that is a little annoying about how ActiveX develoment works is that you have to register your component with the system you're working on in order for it to recognize it (and so you can then use the control in other projects). Normally you can do this if you just go (in VB) to the File menu and choose Make xxxxxxx.ocx from there. It will write the binary ocx file and register it on the system for you.

Unfortunately, it will try to register to a place called Local_Machine in the Windows registry, which your accounts don't have access to. It would be all nice if it defaulted to try Local_User right after the Local_Machine attempt fails, but this is not the case. 

To circumvent this problem, Mike Boyle has made a neat little program that will sit on the desktop of the 2000 machines in the CPSC labs which will let you register your controls! As you read in a mail from Saul, this is how you're going to have to go about debugging your controls, too (see step 7 below). C'est la vie, but it's not too too bad.

  1. If you save your project and go to the directory where you saved it, you should get a list like this before trying to compile it (I'm compiling my ticker example):

  1. To compile it, go to the File menu and choose Make <your control name>.ocx:

  1. Unless there are coding problems, VB will compile the .ocx. However, because registration fails, it then gives you the big helpful "Permission Denied" dialog:

  1. However, if you go to your project directory, you will discover that it still made the .ocx file for your project(!!):

  1. Now all you have to do to register it is drag it on top of the happy wrench icon on the desktop (this is the program that Mike Boyle wrote). If you want to unregister something, just take the same file and drag it on top of the wrench icon labeled unregister with a Do Not Enter sign on it:

  1. Anyways, you'll get a dialog saying that the register was successful: if you didn't then something is wrong. When that's done, if you start up another standard exe project in another VB session and go to Project -> Components, you should find your component registered somewhere in the list, and you should be able to draw it onto the form just like the standard windows controls you're already used to:

  1. Unfortunately, certain things will  not work well on the university machines. In particular, you will not be able to use the 'Add project' feature of VB to debug controls. That is, a standard way of debugging controls is to raise the VB ActiveX control project in in the development environment, and then to add a new .exe project that tests the controls. Because of the way registration works (or does not work), you cannot do this successfully. This means that to debug your controls from an .exe, you have to resort to the usual debug statements e.g., msgbox "some statement".  

Okay, if there are any questions about this, get a hold of me and we'll see what we can do.