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?
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.
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).
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.
Related
I was wondering either it is possible to run an external application inside a QT widget under windows operating system. For example, if I were to write a Qt gui application, where in one of the dialogs user could write some text, I could use a textbox there or something similar. But instead, would it be possible to run Notepad++ or windows notepad application in that dialog?
I would appreciate all help.
It is not really practical to do what you describe at the application level, embedding an entire process into a window of another. (It would be technically difficult and the user experience would likely be pretty bad if you could pull it off.)
Fortunately, this very problem of application components has already been solved!
So it is possible to get the end result you describe via a slightly different mechanism. Many applications expose COM interfaces for automation and embedding, and it is possible to embed COM objects within a Qt application.
(Older technologies such as DDE, OLE and ActiveX provided various aspects of this but are all basically deprecated in favour of COM AFAIK.)
Hopefully you can find a COM object from a third party, or find an app that exposes its components via COM and assemble your app that way.
Have a look at the Qt documentation:
Active Qt - ActiveX and COM support for Qt
I have a legacy Win32 application (WndProcs, etc) that needs to consume a COM object. With the use of a little ATL headers and some smart pointers that was a snap, however what I'm currently struggling with is how best to sink the events coming off that COM object?
My current working plan has been to build a second COM object (as a dll) that handles all the sinking and uses windows messages to communicate with the legacy application. This is "ok" but there's a lot of cruft moving messages back and forth to make the legacy application do what I want.
Is there a readily accessible way to get the Win32 legacy application to sink COM events directly vs running through the second "sinker" com object?
Before I go to far down this process I wanted to see if anyone else ran across this before and had a working solution.
Thanks!
Stumbled across this excellent write up by the always brilliant Raymond Chen.
http://blogs.msdn.com/b/oldnewthing/archive/2013/06/12/10425215.aspx
As WhozCraig indicated above, all I needed was the Interface pointer and to setup the Advise, handle the Invoke.
Nice and clean.
Thanks!
What I am trying to do is create an exe (not .hta) that can be programmed to open a local html file and have it work just like it was in IE (handle styles, scripts and etc), only without actually loading IE. The exe must also be run without installation requirements, and no dependencies (other than recent IE obviously), needed on the host machine.
The purpose is to create an interactive e-book type document, that can be edited without recompile, and also be run from cd/usb on the fly.
I can't just open IE, because it will look unprofessional with the big E, the toolbar and tabs all at the top. know what I mean?
I have experience with HTA, and this was my first suggestion, however I would like to take advantage of the auto run from cd, and also to make the form border a little different, less plain.
I also have experience in VB. Which I could accomplish the look and functionality, however those vbruntimes are not installed on some machines :(
Is it possible to use the IE webBrowser control from c++ or even assembly?
Thanks in advance!
It appears, Lucian Wischik's Webform can be a good starting point to meet your minimalistic project requirements. Alternatively, you could host WebBrowser ActiveX control directly using ATL AxHost. ATL can be linked statically and adds a very low size overhead to the final EXE. Here is a sample project of WebBrowser host app which only depends on ATL.
Yes, you can use the browser component from C++.
C++ however will again need runtime libraries, similar to VB. The good news is, you can statically link those runtime libraries with the executable.
You will not be able to statically link the browser component with your executable, but that wont be an issue unless you try to support ancient Windows versions (pre NT 4.0). For all more recent Windows versions, you can pretty much assume that this component is available.
For more details on that component, you may refer to the CHtmlView class reference - that is the MFC wrapped version of that WebBrowser activeX component.
Using that component from assembler certainly is possible as well, but unless you are deeeeeeep into system programming on the windows platform, you will fail.
I'm trying to understand event hooks in C++. I know what an event is, I've used them a lot in Java, C# and Javascript.
What I'm having trouble with is finding the documentation, and tutorials on stuff like global hooks, dll injection, global hooks without a DLL.
Lets say that I wanted to iterate through the browser tabis in FireFox .. would I need to hope that FireFox has an API for C++? Or lets say I wanted to do something when a user opens a new tab would I need to use a hook that FireFox would provide in their API?
The above is just an example so people know what I'm trying to learn/understand. Am I thinking on the right ines?
I seen a post on a forum and for the past 2 hours I've took an interest. I always say that a tricky challange, or a new challange, makes a stronger programmer.
Any resources, or any help, would be very much appreciated.
C++ itself does not have events or hooks, but a lot of C++ libraries and frameworks implement them. For an example of generic events library, see Boost.Signals.
Some of the implementations allow their events to be seen by other applications, but the API is application-specific (e.g. for Firefox, see XPCOM).
Windows has a mechanizm of hooks that allows to monitor various events in its windowing system. However, it is an OS feature, not related to C++. As it's a system mechanizm, all Windows applications are affected even if they don't do anything for it. The documentation for Windows hooks can be found here. Also, since you mentioned "global hooks without a DLL", see SetWinEventHook, which is a higher-level API than Windows hooks linked above and can be used with hook functions both implemented in DLLs or EXEs.
Look up MSDN for SetWindowsHookEx. It should be your entrance in Windows hooks. If you ar etargetting a parituclar window for mthe system then a less intrusive option is SetWindowLongPtr. For the first API you are going to need some Dll injection - which gets automatically for you by the system. Just follow these steps:
Create a Dll that exports a HOOKPROC function (actual type dependent upon the hook tpe - read in the docs)
Load that Dll in your application and retrieve a pointer to the HOOKPROC function. LoadLibrary / GetProcAddress APIs may be used for this.
From your application, make a call to SetWindowsHookEx feeding in the appropriate parameters - this will inject the dll in the target process. So, the dll is now loaded into both your app's process and in the target process. So you will need a mechanism to IPC between the two processes probably. Lots of ways here - sockets, pipes, shared segment in DLL, filesystem, windows messages, COM servers + events, etc etc.
The former API, while less powerful, does not require DLL injection.
Choose wisely & good luck!
I dont think firefox would be having a C++ aPI to find the open tabs....
If you want to find out open tabs or whenever a new tab is open , you can basically hook the firefox window and get all events happening on that window to your hook procedure.
If you open spy++ in VC++ and track firefox window , you can see a new MozillaContentWindowClass gets created every time whenever a new tab is opened. So you can basically iterate through window handles and get information about open tabs.
You can use SetWindowLongPtr to set the subclass procedure for that window.
How do you develop UI in MFC?
do you use any free libray, or usually develop from scratch?
There are always so many DLL files in a C++ developed software, what are them used for ?
What's the difference between MFC ActiveX Control and MFC DLL ?
Visual Studio 2008 enhances MFC by adding the 'Feature Pack'. This allows you to create MS Office 2007 style GUIs (amongst others), complete with a Ribbon Bar.
http://msdn.microsoft.com/en-us/library/bb982354.aspx
I cut my C++ teeth using MFC, but I'd recommend you look at Qt instead - it's a much more modern framework plus you get cross-platform support (Linux, Mac, etc.) for free. MFC is pretty much a dead framework IMHO (the Feature Pack was bought in and is actually a cut-down version of the BCG library.)
http://www.bcgsoft.com/
If you want to stick with MFC there is another popular GUI framework, by CodeJock:
http://www.codejock.com/products/overview.asp?platform=mfc
MFC (Microsoft Foundation/Frustration Class) is an old approach of Microsoft to provide an Framework to C++ developers. In those days it was the only framework offered by Microsoft so the approch is very old (Win95 I think).
The MFC is a toolbox consisting of String, Gui, Controls etc...
CString, CWindow, CTreeControl, ...
In addition it contained an component framework (ActiveX) and Gui based component framework
ActivX Controls that may include all of the parts of the toolbox.
All the functionallity is hosted in the mfc??.dll and other dll taht have become part of the Microsft OS itself and contains a lot of compatibility stuff of Windows. (Most of the applications including Word Excel, ... are implemented using MFC).
Today I wouldn't suggest to start using MFC anymore. If you have to care about MFC you are doomed but I would suggest to use one of the newer hype things of MS or use Qt or whatever Gui based toolbox.
Most of them are more modern than MFC.
Get yourself a good book to begin with. There are still some third parties controls if you do not mind spending a bit of money. Finally, codeproject has hundreds of MFC examples.
The standard book for learning MFC is this one.
Since you don't list the DLLs that are troubling you, I can't comment on them. However in native code it's common practice for frequently-used functions to be separated out into DLLs.
An ActiveX control is a COM (Component Object Model) "chunk" of functionality, designed to be accessible from multiple languages. COM has no specific connection with MFC, other than the fact that MFC can use COM components like any other MS product.
MFC DLLs come in two types, extension and regular. Regular DLLs are just like any other DLL. An extension DLL is more tightly integrated with MFC, can only be used with MFC applications, and can export MFC classes and functions.
How do you develop UI in MFC?
More often than not the MFC GUI will be defined as a Windows resource file that is compiled using the Windows resource compiler and edited using the MFC specific resource file editor that is built into Visual Studio.
But since the resource file is just plain text it can also be created and edited by hand inside any text editor.
What's the difference between MFC
ActiveX Control and MFC DLL ?
MFC is nothing more than a set of C++ library classes designed to wrap around existing Windows technology.
So for example the MFC ActiveX control is nothing more than a Windows ActiveX Control written in MFC and likewise the MFC DLL is a Windows DLL written in MFC.
I would also recommend taking some time to also learn a little about the underlying Win32 layer. In reality MFC is only a very thin layer over the top of standard Win32 so any knowledge of Win32 always comes in handy.