INFO: VB Automation of Visual C++ Server Using OBJ1.OBJ2.prop Syntax
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Steps to Create the Visual C++ OLE Automation Server
1.
Create an AppWizard-generated project called AutoServ with OLE
Automation enabled.
2.
Once the project has been generated, start ClassWizard.
3.
Click the OLE Automation tab.
4.
Click the Add Class button, enter the following values, and then click
Create Class:
Class Name: nested
Class Type: CCmdTarget
Check: OLE Automation
5.
Click the ClassWizard's OLE Automation tab. Set the Class Name to
nested, click the Add Property button, enter the following values, and
then click OK:
External Name: Value
Type: long
6.
Change the Class Name in ClassWizard to CAutoServDoc. If you are
prompted to save changes, click Yes. Then click the Add Method button,
enter the following values, and click OK:
External Name: Nested
Return Type: LPDISPATCH
7.
Click OK to accept the additions created by ClassWizard.
8.
Open the project's AutoServDoc.h file, and add the following line to
the beginning of the file:
#include "nested.h"
9.
To the same file, add a public member variable m_nested of type nested.
A pointer mechanism could have been used to maintain the nested class;
however, for this example, the chosen method will automatically create
and destroy the nested object within the Documents constructor and
destructor respectively.
10.
Open the project's nested.h file, and modify the class so that the
constructor and destructor are public methods.
11.
Open the projects AutoServDoc.cpp file, and modify the Nested Method
as follows:
LPDISPATCH CAutoServDoc::Nested()
{
//TODO: Add your dispatch handler code here
return m_nested.GetIDispatch(TRUE);
}
12.
Build the project, and then run AutoServ.exe to register the server.
Need More Help? Contact a Support professional by E-mail, Online or Phone.
Customer Service For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
Newsgroups Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.