Tutorial: Crear un SDK usando C++

Este tutorial muestra cómo crear una librería matemática de C++ nativa SDK, paquete SDK como una extensión de Visual Studio (VSIX), y se utiliza para crear una aplicación.El tutorial está dividido en estos pasos:

Requisitos previos

Debe tener Visual Studio 2012 y Visual Studio 2012 SDK instalado en el equipo.Puede descargar Descargas de Visual Studio el SDK del sitio Web.

Para crear código nativo y las bibliotecas en tiempo de ejecución de Windows

  1. En la barra de menú, elija Archivo, Nuevo, Proyecto.

  2. En la lista de plantillas, expanda Visual C++, Tienda Windows, y seleccione la plantilla DLL (aplicaciones de almacén de Windows).En el cuadro Nombre, especifique NativeMath, y elija el botón Aceptar.

  3. Actualice NativeMath.h para que coincida con el código siguiente.

  4. Actualice NativeMath.cpp para coincidir con este código:

  5. En Explorador de soluciones, abra el menú contextual para Solución “NativeMath” y, a continuación Add, nuevo proyecto.

  6. En la lista de plantillas, expanda Visual C++, y seleccione la plantilla Componente en tiempo de ejecución de Windows.En el cuadro Nombre, especifique NativeMathWRT, y elija el botón Aceptar.

  7. Actualice Class1.h para coincidir con este código:

  8. Actualice Class1.cpp para coincidir con este código:

  9. En la barra de menú, elija Compilar, Compilar solución.

Para crear el proyecto de extensión de NativeMathVSIX

  1. En Explorador de soluciones, abra el menú contextual para Solución “NativeMath” y, a continuación Add, nuevo proyecto.

  2. En la lista de plantillas, expanda Visual c#, Extensibilidad, y Paquete VSIX seleccione.En el cuadro Nombre, especifique NativeMathVSIX, y elija el botón Aceptar.

  3. Cuando aparezca el diseñador manifiesto VSIX, ciérrela.

  4. En Explorador de soluciones, abra el menú contextual para source.extension.vsixmanifest y, a continuación ver código.

  5. Utilice el siguiente XML para reemplazar XML existente.

  6. En Explorador de soluciones, abra el menú contextual para el proyecto NativeMathVSIX y, a continuación Add, Nuevo elemento.

  7. En la lista Elementos de Visual C, expanda datos y, a continuación Archivo XML.En el cuadro Nombre, especifique SDKManifest.xml, y elija el botón Aceptar.

  8. Utilice este XML para reemplazar el contenido del archivo:

  9. En Explorador de soluciones, en el proyecto NativeMathVSIX, cree esta estructura de carpetas:

          \DesignTime
                \CommonConfiguration
                      \Neutral
                            \Include
                \Debug
                      \x86
          \Redist
                \Debug
                      \x86
          \References
                \CommonConfiguration
                      \Neutral
    
  10. En Explorador de soluciones, abra el menú contextual para Solución “NativeMath” y, a continuación Abrir carpeta en el Explorador de archivos.

  11. En Explorador de archivos, la copia \NativeMath\NativeMath .h y, en Explorador de soluciones, en el proyecto NativeMathVSIX, pegarlo en \DesignTime\CommonConfiguration\Neutral\Include \.

    Copia \debug\nativemath\nativemath.lib, \Debug\NativeMath\NativeMath.lib, and then paste it in the \DesignTime\Debug \Debug\NativeMath\NativeMath.lib, and then paste it in the \DesignTime\Debug \Debug\NativeMath\NativeMath.lib, and then paste it in the \DesignTime\Debug \Debug\NativeMath\NativeMath.lib, and then paste it in the \DesignTime\Debug \Debug\NativeMath\NativeMath.lib, and then paste it in the \DesignTime\Debug \Debug\NativeMath\NativeMath.lib, and then paste it in the \DesignTime\Debug \designtime\debug \ x86 \.

    Copia \debug\nativemath\nativemath.dll \Debug\NativeMath\NativeMath.dll and paste it in the \Redist\Debug \Debug\NativeMath\NativeMath.dll and paste it in the \Redist\Debug \Debug\NativeMath\NativeMath.dll and paste it in the \Redist\Debug \Debug\NativeMath\NativeMath.dll and paste it in the \Redist\Debug \Debug\NativeMath\NativeMath.dll and paste it in the \Redist\Debug \redist\debug \ x86 \.

    Copia \debug\nativemathwrt\nativemathwrt.dll \Debug\NativeMathWRT\NativeMathWRT.dll and paste it in the \Redist\Debug \Debug\NativeMathWRT\NativeMathWRT.dll and paste it in the \Redist\Debug \Debug\NativeMathWRT\NativeMathWRT.dll and paste it in the \Redist\Debug \Debug\NativeMathWRT\NativeMathWRT.dll and paste it in the \Redist\Debug \Debug\NativeMathWRT\NativeMathWRT.dll and paste it in the \Redist\Debug \redist\debug \ x86 \.

    Copia \debug\nativemathwrt\nativemathwrt.winmd \Debug\NativeMathWRT\NativeMathWRT.winmd and paste it in the \References\CommonConfiguration\Neutral \Debug\NativeMathWRT\NativeMathWRT.winmd and paste it in the \References\CommonConfiguration\Neutral \Debug\NativeMathWRT\NativeMathWRT.winmd and paste it in the \References\CommonConfiguration\Neutral \Debug\NativeMathWRT\NativeMathWRT.winmd and paste it in the \References\CommonConfiguration\Neutral \Debug\NativeMathWRT\NativeMathWRT.winmd and paste it in the \References\CommonConfiguration\Neutral \references\commonconfiguration\neutral \.

    Copia \debug\nativemathwrt\nativemathwrt.pri \Debug\NativeMathWRT\NativeMathWRT.pri and paste it in the \References\CommonConfiguration\Neutral \Debug\NativeMathWRT\NativeMathWRT.pri and paste it in the \References\CommonConfiguration\Neutral \Debug\NativeMathWRT\NativeMathWRT.pri and paste it in the \References\CommonConfiguration\Neutral \Debug\NativeMathWRT\NativeMathWRT.pri and paste it in the \References\CommonConfiguration\Neutral \Debug\NativeMathWRT\NativeMathWRT.pri and paste it in the \References\CommonConfiguration\Neutral \references\commonconfiguration\neutral \.

  12. En \designtime\debug\x86\ folder, \DesignTime\Debug\x86\ folder, create a text file that’s named NativeMathSDK \DesignTime\Debug\x86\ folder, create a text file that’s named NativeMathSDK \DesignTime\Debug\x86\ folder, create a text file that’s named NativeMathSDK \DesignTime\Debug\x86\ folder, create a text file that’s named NativeMathSDK that's \DesignTime\Debug\x86\ folder, create a text file that’s named NativeMathSDK \DesignTime\Debug\x86\ folder, create a text file that’s named NativeMathSDK .props y, a continuación pegue el contenido siguiente en él:

  13. En la barra de menú, elija Vista, Otras ventanas, Ventana Propiedades (teclado: Elija la F4).

  14. En Explorador de soluciones, seleccione el archivo NativeMathWRT.winmd.En la ventana propiedades, cambie la propiedad Acción de compilación a Contenido, y después cambie la propiedad Incluir en VSIX a True.

    Repita este proceso para el archivo SimpleMath.pri.

    Repita este proceso para el archivo NativeMath.Lib.

    Repita este proceso para el archivo NativeMathSDK.props.

  15. En Explorador de soluciones, seleccione el archivo NativeMath.h.En la ventana propiedades, cambie la propiedad Incluir en VSIX a True.

    Repita este proceso para el archivo NativeMath.dll.

    Repita este proceso para el archivo NativeMathWRT.dll.

    Repita este proceso para el archivo SDKManifest.xml.

  16. En la barra de menú, elija Compilar, Compilar solución.

  17. En Explorador de soluciones, abra el menú contextual para el proyecto NativeMathVSIX y, a continuación Abrir carpeta en el Explorador de archivos.

  18. En Explorador de archivos, navegue a \bin\debug\ folder, \bin\Debug\ folder, and then run NativeMathVSIX \bin\Debug\ folder, and then run NativeMathVSIX \bin\Debug\ folder, and then run NativeMathVSIX \bin\Debug\ folder, and then run NativeMathVSIX .vsix para iniciar la instalación.

  19. Elija el botón Instalar, esperará la instalación para terminar, y reinicie Visual Studio.

Para crear una aplicación de ejemplo que utiliza la biblioteca de clases

  1. En la barra de menú, elija Archivo, Nuevo, Proyecto.

  2. En la lista de plantillas, expanda Visual C++, Tienda Windows, y Aplicación en blanco y seleccione.En el cuadro Nombre, especifique NativeMathSDKSample, y elija el botón Aceptar.

  3. En Explorador de soluciones, abra el menú contextual para el proyecto NativeMathSDKSample y, a continuación References.

  4. En Propiedades comunes, la página de propiedades Marco de trabajo y referencias, en la lista de tipos de referencia, expanda Windows y, a continuación Extensiones.En el panel de detalles, seleccione la extensión Matemática nativa SDK, y después elija el botón Agregar nueva referencia.

  5. En el cuadro de diálogo Agregar referencia, active la casilla Matemática nativa SDK, y después elija el botón Aceptar.

  6. Mostrar las propiedades del proyecto para NativeMathSDKSample.

    Las propiedades definidas en NativeMathSDK.props se aplicaron cuando agregó la referencia.Puede comprobarlo examinando la propiedad Directorios de VCPropiedades de configuración del proyecto.

  7. En Explorador de soluciones, abra MainPage.xaml, y después utilizan el siguiente XAML para reemplazar el contenido:

  8. Actualización Mainpage.xaml.h para que este código:

  9. Actualización MainPage.xaml.cpp para que este código:

  10. Elija la tecla F5 para ejecutar la aplicación.

  11. En la aplicación, escriba los dos números, seleccione una operación, y después elija el botón =.

    El resultado correcto aparece.

Este tutorial muestra cómo crear y usar una extensión SDK para llamar a Windows en tiempo de ejecución una biblioteca y una biblioteca no de Windows en tiempo de ejecución.

Vea también

Tareas

Tutorial: Crear un SDK usando C#

Conceptos

Cómo: Crear un kit de desarrollo de software