Registering Without a License
Dear Dr. GUI,
After registering mscomm32.ocx with regsvr32 on a machine that does not have Visual C++ installed, I still have problems using it. If Visual C++ has been installed, no problems arise. Of course I want my application working on a machine without Visual C++ installed.
In the following code, the Create function returns a value of 0, which means that no OLE control has been created.
The Create function is declared in mscomm.h, which calls (and returns the result of) the function CreateControl.
Do you know what I might have forgotten?
M. Haring
Dr. GUI replies:
Dr. GUI thinks he has a pretty good idea.
The mscomm32.ocx you mention is a licensed control. On a developer machine, creating it works because a design-time license was installed on the machine when you installed Microsoft Visual Studio®. On a non-developer machine, only a run-time license can be used. The Microsoft Knowledge Base article Q151771: "SAMPLE: LICREQST.EXE Requesting a License Key from an Object" (http://support.microsoft.com/support/kb/articles/q151/7/71.asp) tells what your program needs to do to create licensed controls on non-developer machines dynamically.
Basically, the process is to query the control for its license string, and then copy the license string to the Clipboard in a format you can paste into your C++ program. DO NOT use this technique to violate any software licenses—but you can use it for mscomm32.ocx. (There should be no need to do this for controls you've legitimately licensed for redistribution—the vendor should supply you with the license key.)
You can also place the licensed control on a dialog resource and get it to work. By doing so, the license key is placed into the dialog resource and the control will be created with the license information automatically. The MFC framework has the necessary code to create licensed controls in this case.
Just to double-check, you might also try running Depends.exe or Dumpbin.exe on the .ocx and the .dll files needed to support the application on a development machine and compare the versions of the resultant DLLs to those of your target machine (http://msdn.microsoft.com/library/techart/redistribvc6.htm#redistribvc6_topic3). Actually, read the whole article—it tells you all sorts of things you need to know to successfully distribute Microsoft ActiveX® controls.