Determine and Changing the Class ID in Visual Basic 6

Visual Basic is very old programming language but still sometimes we need it like a good old friend.

I will demonstrate how to Determine and Changing the Class ID in Visual Basic 6

Determining the VB6 OCX ClassID

To determine the OCX `ClassID` you have to search in the in `Registry` by control name.

 

For e.g. if you have control name ABC.ocx if you search it by name you will get the `ClassID`.

Note: You can find the Windows Registry by typing the command ‘regedit’ in  Run.

Changing a VB6 OCX ClassID

If you have made some changes in the `ActiveX` and want new `ClassID` you have to set the `Version`
`Compatibility: No Compatibility`,

in *Properties -> Component ->Version Compatibility

 

How to add a method to an ActiveX (ocx)

In the programming world, there are many ways to perform a task.

Prerequisites: Language: C++ and I have used VisualStudio2008.

First, create a Project (MFC ActiveX control). Then to add a method to your ActiveX control you have to follow the following steps:

  1.  Declare the function in the header file.

e.g.

public:
int Connect(int timeout);

2. Add the definition in the CPP file.

int CSLWebLinkCtrl::Connect(int timeout)

// Your logic here.

return 0;
3. Expose your methods in the .idl file

[id(4), helpstring(“method Connect”)] int Connect(int timeout);
Hope it will help you. 🙂