C++/CLI in Action

Book description

C++/CLI in Action is a practical guide that will help you breathe new life into your legacy C++ programs. The book begins with a concise C++/CLI tutorial. It then quickly moves to the key themes of native/managed code interop and mixed-mode programming. You'll learn to take advantage of GUI frameworks like Windows Forms and WPF while keeping your native C++ business logic. The book also covers methods for accessing C# or VB.NET components and libraries.

Table of contents

  1. preface
  2. acknowledgments
  3. about this book
    1. Roadmap
    2. Source code
    3. Author Online
    4. About the author
    5. About the title
    6. About the cover illustration
  4. Part 1 - The C++/CLI Language
    1. Introduction to C++/CLI
      1. 1.1 The role of C++/CLI (1/2)
      2. 1.1 The role of C++/CLI (2/2)
        1. 1.1.1 What C++/CLI can do for you
        2. 1.1.2 The rationale behind the new syntax
      3. 1.2 Hello World in C++/CLI
        1. 1.2.1 The /clr compiler option
        2. 1.2.2 Using VC++ 2005 to create a /clr application
      4. 1.3 Declaring CLR types (1/2)
      5. 1.3 Declaring CLR types (2/2)
        1. 1.3.1 Class modifiers
        2. 1.3.2 CLI types and inheritance
      6. 1.4 Handles: the CLI equivalent to pointers
        1. 1.4.1 Syntax for using handles
        2. 1.4.2 Tracking references
      7. 1.5 Instantiating CLI classes (1/2)
      8. 1.5 Instantiating CLI classes (2/2)
        1. 1.5.1 The gcnew operator
        2. 1.5.2 Constructors
        3. 1.5.3 Copy constructors
        4. 1.5.4 Assignment operators
      9. 1.6 Boxing and unboxing (1/2)
      10. 1.6 Boxing and unboxing (2/2)
        1. 1.6.1 Implicit boxing in the new syntax
        2. 1.6.2 Boxing and type-safety
        3. 1.6.3 Implementation at the MSIL level
        4. 1.6.4 Assigning null to a boxed value type
      11. 1.7 Summary
    2. Getting into the CLI: properties, delegates and arrays
      1. 2.1 Properties (1/3)
      2. 2.1 Properties (2/3)
      3. 2.1 Properties (3/3)
        1. 2.1.1 Scalar Properties
        2. 2.1.2 Indexed properties
      4. 2.2 Delegates and events (1/2)
      5. 2.2 Delegates and events (2/2)
        1. 2.2.1 Delegates
        2. 2.2.2 Events
      6. 2.3 CLI Arrays (1/4)
      7. 2.3 CLI Arrays (2/4)
      8. 2.3 CLI Arrays (3/4)
      9. 2.3 CLI Arrays (4/4)
        1. 2.3.1 Basic CLI array concepts
        2. 2.3.2 Single-dimensional arrays
        3. 2.3.3 Multidimensional arrays
        4. 2.3.4 Jagged arrays
        5. 2.3.5 Arrays as function arguments
        6. 2.3.6 Returning arrays from functions
        7. 2.3.7 Parameter arrays
        8. 2.3.8 Using System::Array methods
        9. 2.3.9 Array covariance
        10. 2.3.10 Arrays of non-CLI objects
        11. 2.3.11 Directly accessing CLI arrays using native pointers
      10. 2.4 Summary
    3. More C++/CLI: stack semantics, function overriding, and generic programming
      1. 3.1 Stack semantics and deterministic destruction (1/3)
      2. 3.1 Stack semantics and deterministic destruction (2/3)
      3. 3.1 Stack semantics and deterministic destruction (3/3)
        1. 3.1.1 The new destructor and finalizer syntaxes
        2. 3.1.2 Stack semantics
        3. 3.1.3 Guidelines for using destructors and stack semantics
      4. 3.2 Function overriding (1/2)
      5. 3.2 Function overriding (2/2)
        1. 3.2.1 Explicit overriding
        2. 3.2.2 Renamed overriding
        3. 3.2.3 Multiple overriding
        4. 3.2.4 Sealed and abstract functions
      6. 3.3 Generics and managed templates (1/5)
      7. 3.3 Generics and managed templates (2/5)
      8. 3.3 Generics and managed templates (3/5)
      9. 3.3 Generics and managed templates (4/5)
      10. 3.3 Generics and managed templates (5/5)
        1. 3.3.1 Why have parameterized types?
        2. 3.3.2 Generics syntax for classes and functions
        3. 3.3.3 Constraint mechanism
        4. 3.3.4 Issues with the constraint mechanism and simple types
        5. 3.3.5 Comparison with templates
        6. 3.3.6 Managed templates
      11. 3.4 Summary
  5. Part 2 - Mixing managed and native code
    1. Introduction to mixed-mode programming
      1. 4.1 Using interior and pinning pointers (1/3)
      2. 4.1 Using interior and pinning pointers (2/3)
      3. 4.1 Using interior and pinning pointers (3/3)
        1. 4.1.1 Interior pointers
        2. 4.1.2 Pinning pointers
      4. 4.2 Working with interop mechanisms (1/3)
      5. 4.2 Working with interop mechanisms (2/3)
      6. 4.2 Working with interop mechanisms (3/3)
        1. 4.2.1 Accessing a managed library from native code
        2. 4.2.2 Accessing a native library from managed code
      7. 4.3 Using mixed types (1/3)
      8. 4.3 Using mixed types (2/3)
      9. 4.3 Using mixed types (3/3)
        1. 4.3.1 Native types with managed members
        2. 4.3.2 Managed types with native members
      10. 4.4 Function pointers and delegates: bridging the gap
        1. 4.4.1 Using GetFunctionPointerForDelegate
        2. 4.4.2 Using GetDelegateForFunctionPointer
      11. 4.5 Summary
    2. Interoping with native libraries from managed applications
      1. 5.1 Converting between managed and native types
        1. 5.1.1 Marshalling native strings
        2. 5.1.2 Marshalling arrays
        3. 5.1.3 Simulating a native static array with managed code
      2. 5.2 Double thunking in mixed-mode function calls
      3. 5.3 Wrapping a native API and exposing a CLI interface (1/4)
      4. 5.3 Wrapping a native API and exposing a CLI interface (2/4)
      5. 5.3 Wrapping a native API and exposing a CLI interface (3/4)
      6. 5.3 Wrapping a native API and exposing a CLI interface (4/4)
        1. 5.3.1 Overview of the native API
        2. 5.3.2 Writing the CLI wrapper
      7. 5.4 Exposing an MFC extension DLL to .NET (1/2)
      8. 5.4 Exposing an MFC extension DLL to .NET (2/2)
        1. 5.4.1 Overview of the MFC extension DLL
        2. 5.4.2 Writing the managed regular MFC DLL wrapper
      9. 5.5 Accessing a COM object via a custom RCW (1/2)
      10. 5.5 Accessing a COM object via a custom RCW (2/2)
        1. 5.5.1 The COM object to interop with
        2. 5.5.2 Writing the custom RCW
        3. 5.5.3 Using the custom RCW
      11. 5.6 Writing a single mixed-mode DLL for both managed and native clients (1/2)
      12. 5.6 Writing a single mixed-mode DLL for both managed and native clients (2/2)
        1. 5.6.1 Wrapping the System::Object class
        2. 5.6.2 Writing derived class wrappers
      13. 5.7 Summary
  6. Part 3 - Using managed frameworks from native applications
    1. Interoping Windows Forms with MFC
      1. 6.1 A simple Windows Forms application
      2. 6.2 Hosting a Windows Forms control in an MFC dialog
      3. 6.3 Hosting a Windows Forms control as an MFC view (1/2)
      4. 6.3 Hosting a Windows Forms control as an MFC view (2/2)
      5. 6.4 Giving your MFC apps an Office 2003 style UI (1/3)
      6. 6.4 Giving your MFC apps an Office 2003 style UI (2/3)
      7. 6.4 Giving your MFC apps an Office 2003 style UI (3/3)
      8. 6.5 Using a Windows Forms control as an MFC dialog (1/2)
      9. 6.5 Using a Windows Forms control as an MFC dialog (2/2)
      10. 6.6 Using an MFC control in a Windows Forms form (1/2)
      11. 6.6 Using an MFC control in a Windows Forms form (2/2)
        1. 6.6.1 The custom MFC control
        2. 6.6.2 Hosting the MFC control from WinForms
        3. 6.6.3 Using the wrapped control from a WinForms app
      12. 6.7 Summary
    2. Using C++/CLI to target Windows Presentation Foundation applications
      1. 7.1 What is WPF? (1/2)
      2. 7.1 What is WPF? (2/2)
        1. 7.1.1 Overview of XAML
        2. 7.1.2 Anatomy of a simple WPF application
      3. 7.2 Using C++/CLI to write a WPF application (1/3)
      4. 7.2 Using C++/CLI to write a WPF application (2/3)
      5. 7.2 Using C++/CLI to write a WPF application (3/3)
        1. 7.2.1 Creating a new C++/CLI Avalon project
        2. 7.2.2 Using procedural code
        3. 7.2.3 Dynamically loading XAML
        4. 7.2.4 Deriving from a class in a C# DLL
      6. 7.3 A brief look at some WPF Graphics features (1/2)
      7. 7.3 A brief look at some WPF Graphics features (2/2)
        1. 7.3.1 Using brushes and shapes
        2. 7.3.2 Transformations
      8. 7.4 Hosting a WPF control in a native C++ application (1/4)
      9. 7.4 Hosting a WPF control in a native C++ application (2/4)
      10. 7.4 Hosting a WPF control in a native C++ application (3/4)
      11. 7.4 Hosting a WPF control in a native C++ application (4/4)
        1. 7.4.1 Using a mixed-mode extension DLL
        2. 7.4.2 Using a mixed-mode application
      12. 7.5 Hosting a native control in a WPF application
      13. 7.6 Summary
    3. Accessing the Windows Communication Foundation with C++/CLI
      1. 8.1 Hello World with the Windows Communication Foundation
      2. 8.2 Duplex communication in WCF (1/2)
      3. 8.2 Duplex communication in WCF (2/2)
        1. 8.2.1 Creating the service
        2. 8.2.2 Creating the client
      4. 8.3 Migrating a native DCOM application to WCF (1/4)
      5. 8.3 Migrating a native DCOM application to WCF (2/4)
      6. 8.3 Migrating a native DCOM application to WCF (3/4)
      7. 8.3 Migrating a native DCOM application to WCF (4/4)
        1. 8.3.1 The example DCOM server
        2. 8.3.2 The native MFC client
        3. 8.3.3 Writing a WCF proxy service
        4. 8.3.4 Modifying the MFC client to use WCF
        5. 8.3.5 Writing a pure WCF service
        6. 8.3.6 Comparison of the two migration methods
      8. 8.4 Hosting a WCF service in an IIS server
      9. 8.5 Summary
    4. Appendix: A concise introduction to the .NET Framework
      1. What is the .NET Framework?
      2. The Common Language Runtime
      3. Executing a .NET program
      4. Visual C++ and .NET
      5. The Base Class Library
      6. CLI types
      7. Memory management
      8. Application domains
      9. Reflection
  7. index
    1. Symbols
    2. A
    3. B
    4. C
    5. D
    6. E
    7. F
    8. G
    9. H
    10. I
    11. J
    12. K
    13. L
    14. M
    15. N
    16. O
    17. P
    18. Q
    19. R
    20. S
    21. T
    22. U
    23. V
    24. W
    25. X

Product information

  • Title: C++/CLI in Action
  • Author(s): Nishant Sivakumar
  • Release date: April 2007
  • Publisher(s): Manning Publications
  • ISBN: 9781932394818