Share via


How to: Build and Run the ShapeAppBasicMFC Sample

The ShapeAppBasicMFC sample demonstrates how to integrate Visual Studio Tools for Applications with a host application that is written in unmanaged code.

For more information about the ShapeAppBasicMFC sample, see ShapeApp Samples (Visual Studio Tools for Applications).

Building and Running ShapeAppBasicMFC

To build and run ShapeAppBasicMFC, perform the following steps:

  1. Install Visual Studio Tools for Applications.

  2. Extract ShapeAppBasicMFC.

  3. Open ShapeAppBasicMFC in Visual Studio and build it.

  4. Register ShapeAppBasicMFC. This enables you to build and debug the sample add-in, and to use the project templates that are included with ShapeAppBasicMFC to create your own add-ins.

  5. Build the sample add-in.

  6. Load the sample add-in into ShapeAppBasicMFC.

  7. Optionally, unregister ShapeAppBasicMFC. This removes the registry entries that enable you to build and debug the sample add-in, and to use the project templates that are included with ShapeAppBasicMFC to create your own add-ins.

To extract ShapeAppBasicMFC

  1. Create a folder named ShapeAppSamples at the root of the Windows system drive (%SystemDrive%), and then create a subfolder named ShapeAppBasicMFC. For example, if your system drive is C, the directory would be C:\ShapeAppSamples\ShapeAppBasicMFC.

    Note

    Although you can extract ShapeAppBasicMFC to any folder, the following procedures and the walkthroughs in the Visual Studio Tools for Applications documentation assume that you extract ShapeAppBasicMFC to the drive:\ShapeAppSamples\ShapeAppBasicMFC folder.

  2. Open the Visual Studio Tools for Applications samples folder.

    By default, the samples folder is located at %ProgramFiles%\Visual Studio Tools for Applications 2.0 SDK\build number\Visual Studio Tools For Applications\Samples on 32-bit versions of Windows, or at %ProgramFiles(x86)%\Visual Studio 2008 Tools for Applications SDK\build number\Visual Studio Tools For Applications\Samples on 64-bit versions of Windows.

  3. Right-click the ShapeAppBasicMFC.zip file, and then click Extract All.

    Note

    This step assumes that your system is set to open .zip files using Compressed (zipped) Folders. If your system is set to open .zip files with another program, follow the instructions of that program to extract the contents of ShapeAppBasicMFC.zip.

  4. Follow the instructions in the Extract Compressed (Zipped) Folders wizard to extract the contents of ShapeAppBasicMFC.zip to the drive:\ShapeAppSamples\ShapeAppBasicMFC folder.

To build ShapeAppBasicMFC

  1. Start Visual Studio 2008. If you are using Windows Vista as your operating system, start Visual Studio 2008 by using the Run as Administrator option.

  2. On the File menu, point to Open, and then click Project/Solution.

  3. In the Open Project dialog box, navigate to the drive:\ShapeAppSamples\ShapeAppBasicMFC folder.

  4. Select the ShapeAppBasicMFC.sln file, and then click Open.

  5. On the Build menu, click Build Solution. Verify that the solution builds without errors.

  6. On the File menu, click Close Solution.

To register ShapeAppBasicMFC

  1. Open a Command Prompt window. If you are using Windows Vista as your operating system, open a Command Prompt window by using the Run as Administrator option.

  2. Run the following command:

    cd "%SystemDrive%\ShapeAppSamples\ShapeAppBasicMFC"
    

    Note

    If your development computer has a 64-bit operating system, make sure that you open a 32-bit Command Prompt window. The script file that registers ShapeAppBasicMFC can be run only in a 32-bit Command Prompt window.

  3. Type the following command to run the SetupShapeAppBasicMFC.js script file. This script file registers ShapeAppBasicMFC with Visual Studio Tools for Applications and configures the project templates so that they can be used from Visual Studio 2008.

    cscript SetupShapeAppBasicMFC.js
    

    For more information about registering host applications, see Registering the Host Application.

    Note

    This command might require several minutes to complete.

To build the sample add-in

  1. On the File menu, point to Open, and then click Project/Solution.

  2. In the Open Project dialog box, navigate to the drive:\ShapeAppSamples\ShapeAppBasicMFC\Sample AddIns\CSharp folder.

    Note

    The following instructions assume that you are building the Visual C# version of the add-in. For a Visual Basic version of the add-in, see the drive:\ShapeAppSamples\ShapeAppBasicMFC\Sample AddIns\VisualBasic folder.

  3. Select the ShapeAppMFCAddIns.sln file, and then click Open.

  4. On the Build menu, click Build Solution. Verify that the solution builds without errors.

    When you build the solution, the add-in assemblies are automatically copied as follows:

    For Windows XP and Windows Server 2003:

    • ShapeAppCSharpAppAddIn.dll is copied to %UserProfile%\My Documents\ShapeAppMFC\AppAddIns\ShapeAppMFCAppAddIn.

    For Windows Vista:

    • ShapeAppCSharpAppAddIn.dll is copied to %UserProfile%\Documents\ShapeAppMFC\AppAddIns\ShapeAppMFCAppAddIn.

    ShapeAppBasicMFC searches for add-ins in this directory.

  5. On the File menu, click Close Solution.

To load the add-in into ShapeAppBasicMFC

  1. On the File menu of Visual Studio, point to Open, and then click Project/Solution.

  2. In the Open Project dialog box, navigate to the drive:\ShapeAppSamples\ShapeAppBasicMFC folder.

  3. Select the ShapeAppBasicMFC.sln file, and then click Open.

  4. Press F5. Verify that ShapeAppBasicMFC displays the message "Drawing Created".

  5. Close ShapeAppBasicMFC.

To unregister ShapeAppBasicMFC

  1. Open a Command Prompt window. If you are using Windows Vista as your operating system, open a Command Prompt window by using the Run as Administrator option.

  2. Run the following command.

    cd "%SystemDrive%\ShapeAppSamples\ShapeAppBasicMFC"
    

    Note

    If your development computer has a 64-bit operating system, make sure that you open a 32-bit Command Prompt window. The script file that unregisters ShapeAppBasicMFC can be run only in a 32-bit Command Prompt window.

  3. Type the following command to run the RemoveShapeAppMFC.js script file. This script file removes registry entries that enable you to build and debug the sample add-in, and to use the project templates that are included with ShapeAppBasicMFC to create your own add-ins.

    cscript RemoveShapeAppMFC.js
    

    Note

    This command might require several minutes to complete.

See Also

Tasks

How to: Build and Run the ShapeAppCSharp Sample

How to: Build and Run the ShapeAppBasicCSharp Sample

How to: Build and Run the ShapeAppMacroRecordingCSharp Sample

How to: Build and Run the ShapeAppDynamicProgrammingModelCSharp Sample

How to: Build and Run the ShapeAppClickOnceCSharp Sample

Walkthrough: Integrating Visual Studio Tools for Applications with ShapeApp

Concepts

ShapeApp Samples (Visual Studio Tools for Applications)