Microsoft KB Archive/194656

{|
 * width="100%"|

HOWTO: Do 16-Bit Automation in C++ Using VC 1.52

 * }

Q194656

-

The information in this article applies to:


 * Microsoft Visual C++ for Windows, 16-bit edition, version 1.52, on platform(s):
 * the operating system: Microsoft Windows NT
 * the operating system: Microsoft Windows 95
 * the operating system: Microsoft Windows 98

-

SUMMARY
This article shows you how to build a 16-bit Automation client written in VC++ 1.52 to automate Microsoft Excel 97 and Microsoft Word 97, without using MFC.

MORE INFORMATION
Although it is recommended that you port your code to 32-bit, some implementations require 16-bit code for compatibility and integration with other 16-bit applications. Please remember that if your code is going to run on Windows 95, you must install DCOM. Without DCOM installed, 16-bit automation clients on Windows 95 usually crash. This is also true for 32- bit code that is called via a thunk from 16-bit.

Follow the steps below to create the example:


 * 1) Start Visual C++ 1.52. On the Project menu, click New, and name the new project Auto16.
 * 2) Use the project type "Windows application (.EXE)." Don't select the MFC option, and click OK.
 * 3) Add Main.cpp to your project, and click Close.
 * 4) On the File menu, click New.
 * 5) Paste the following code into the new file:
 * 6) On the File menu, click Save, and name the file Main.cpp.
 * 7) On the Options menu, click Project, then click Linker.
 * 8) Add ", ole2, ole2disp" (without the quotation marks) to the Libraries edit box, then click OK.
 * 9) Now click Compiler, on the Project Options dialog box.
 * 10) Select the "Memory Model" category and change the Model to Large. This avoids any problems concerning "near" and "far" pointers, because in the large memory model, all pointers are far pointers. Click OK to close the Compiler Options dialog box, and click OK again to close the Project Options dialog box.
 * 11) On the Project menu, click Rebuild All, and click Yes when prompted to create a default .def file.
 * 12) Click Rebuild All again to build the project.
 * 13) On the Project Menu, click Execute Auto16.exe to run the project.

© Microsoft Corporation 1999, All Rights Reserved.

Contributions by Joe Crump, Microsoft Corporation

Additional query words:

Keywords : kb16bitonly kbAutomation kbDCOM kbVC152 kbOSWin95 kbOSWin98 kbGrpDSO

Issue type : kbhowto

Technology : kbVCsearch kbAudDeveloper kbVC16bitSearch