次の方法で共有


OLE Background: Implementation Strategies

OverviewHow Do ISampleTutorial

Depending on your application, there are four possible implementation strategies for adding OLE support:

  • You are writing a new application.

    This situation usually requires the least work. You simply run AppWizard and select OLE options to create a skeleton application. For information on the OLE options in AppWizard and what they do, see the article The MFC AppWizard (EXE version): Step-by-Step.

  • You have a program written with the Microsoft Foundation Class Library version 2.0 or higher that does not support OLE.

    Create a new application with AppWizard as above, then copy and paste the code from the new application into your existing application. This will work for servers, containers, or automated applications. See the MFC Tutorial sample, , Step 7, and the Scribble for an example of this strategy.

  • You have a Microsoft Foundation Class Library program that implements OLE version 1.0 support.

    See for this conversion strategy.

  • You have an application that was not written using the Microsoft Foundation classes and that may or may not have implemented OLE support.

    This situation requires the most work. One approach is to create a new application, as in the first strategy, then copy and paste your existing code into it. If your existing code is written in C, you may need to modify it so it can compile as C++ code. If your C code calls the Windows API, you do not have to change it to use the Microsoft Foundation classes. This approach likely will require some restructuring of your program to support the document/view architecture used by versions 2.0 and higher of the Microsoft Foundation classes. For more information on this architecture, see , and see the MFC Migration Kit, which contains the MFC Migration Guide.

Once you have decided on a strategy, you should either read the Containers or Servers family of articles (depending on the type of application you are writing), or examine the sample programs, or both. The MFC OLE samples and show how to implement the various aspects of containers and servers, respectively. At various points throughout these articles, you will be referred to certain functions in these samples as examples of the techniques being discussed.

See Also   Containers: Implementing a Container, Servers: Implementing a Server, The MFC AppWizard (EXE version): Step-by-Step