The information in this article applies to:
SUMMARY
This article explains how to use CreateObject with COM/ActiveX components
created in Visual C++. The CreateObject programming syntax used to create
an instance of a component created in Visual Basic may not work with a VC++
component, even though the object can be created using the New method. For
example, assume you have an component named "neuLib" referenced in a Visual
Basic project. The component has one createable object (Interface) named
"myclass." The following code will work if the ActiveX component was
created using either Visual Basic or Visual C++:
However, the code below will work only for a component created using Visual Basic:
If this is a VC++-created component, you will receive the error message:
The reason CreateObject works with a Visual Basic component and not with a Visual C++ component can be explained and resolved by examining the different way in which Visual Basic and Visual C++ create program IDs (ProgID.) When you use CreateObject, the argument you provide is a ProgID. Visual Basic and Visual C++ assign a name to the ProgID differently. Visual Basic uses the original name, Visual C++ does not. In a Visual Basic component, the ProgID for this example is "neuLib.myclass." In a Visual C++ component, the ProgID would be "myclass.myclass.1," which requires the (correct) syntax:
MORE INFORMATION
There are two ways to determine the ProgID that you need to specify when
using CreateObject for the VC object.
Additional query words: kbDSupport kbDSD kbVBp kbVBp500 kbVBp600 kbCtrl kbActiveX kbCOMt
Keywords : kbGrpVB |
Last Reviewed: January 5, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |