views:

304

answers:

3

I have a VB6 application that I don't have source code. This application uses third-party ActiveX controls. I want to automate these ActiveX controls. Is it possible to get the IUnknowns or Object references? For some of these, I can get the underlying HWNDs, but from what I can tell there isn't a generic way to convert these HWNDs to the ActiveX control.

Some testing software allows you to script VB6 applications with ActiveX controls. How do they do it?

A: 

You might be able to using DLL injection via Microsoft Research Detours library. Basically you'd want to hook the cocreate for those specific controls. You will need to be ultra careful especially if you do anything cross-thread/cross-process (COM threading rules are vitally important).

On whole Detours is easy to use... but I've never tried it with COM routines. You might want to look at a different solution.

Also note that Detours has some licensing restrictions on it that may affect your ability to distribute it.

Testing software may well just send the appropriate WM_XXX messages to the particular windows in question (eg. WM_MOUSEMOVE).

I'm currently using WM_XXX messages, but there's a limit to what you can do with them. I'll try the DLL injection route. Thanks.
Tommy Hui
A: 

Sorry to say but the VB6 EXE don't contain the manifests needed to pull out the COM objects it uses. You best bet is trying some of rbobby's suggestions especially about sending WM_XXX messages.

RS Conley
A: 

Are these ActiveX controls in a separate DLL? If so, you can use OLE View (an VS 6.0 tool) to open the dll and view all the interfaces, coclasse and etc.

Piotr Anders