Create an SDK for Virtual CEPC (Compact 7)

3/12/2014

OEMs typically use Platform Builder to create a software development kit (SDK) for a particular Windows Embedded Compact 7 target device or product platform. When you provide an SDK, application developers can develop applications on a stand-alone virtual CEPC that includes the SDK.

For information about creating a stand-alone virtual CEPC, see Create a Stand-Alone Virtual CEPC.

Generating the SDK Package

Platform Builder can automatically generate an SDK installer package based on the OS design that you create for virtual CEPC.

To generate an SDK package for your OS design

  1. In Platform Builder, open your virtual CEPC OS design.

  2. In the Solution Explorer pane, right-click SDKs, and then click Add New SDK.

  3. In the SDK1 Property Pages dialog box, enter the name of your SDK in the SDK Name box. For example, if the name of your product is "MyDevice," you could use "MyDevice Software Development Kit."

  4. In the Product Name box, enter the name of the target device or product platform that you intend for this SDK.

  5. In the Product Version box, enter the version number of your product that you intend for this SDK.

  6. In the Company Name box, enter the name of your company.

  7. In the Company Website box, enter the URL for your company’s website.

  8. Click OK.

  9. In Solution Explorer, when you see the name of your SDK appear under SDKs, right-click your SDK, and then click Build.

The build process can take several minutes or more. When the build completes, a message similar to the following appears in the output pane:

C:\WINCE700\build.log(1096) : Message:
Exported SDK to: C:\WINCE700\OSDesigns\VCEPC\VCEPC\SDKs\SDK1\MSI\SDK1.msi
C:\WINCE700\OSDesigns\VCEPC\VCEPC\SDKs\SDK1\SDK1.sdkcfg - 0 error(s), 0 warning(s)
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

The path of the SDK package appears in the output pane. In this example, "VCEPC" is the name of the OS design and the SDK package is located at C:\WINCE700\OSDesigns\VCEPC\VCEPC\SDKs\SDK1\MSI\SDK1.msi.

In the next section, you use this SDK to create a simple "Hello World" application for virtual CEPC.

Verifying Your SDK

After you create your SDK package, you can install it and create a simple virtual CEPC application to verify that it works.

To install your SDK package

  1. Exit Visual Studio.

  2. Navigate to the location of the SDK .msi file created earlier, and then double-click it to install the SDK.

  3. Follow the instructions displayed by the installation wizard and verify that the information you used to create the SDK displays properly.

To create a project that uses your SDK package

  1. Start Visual Studio.

  2. On the File menu, click New, and then click Project.

  3. When Visual Studio displays the New Project dialog box, under Project types, expand Visual C++ if it is collapsed, and then select Smart Device.

  4. Under Templates, select Win32 Smart Device Project.

  5. In the Name box, type a name for your project; for example, "MyApplication."

  6. In the Location box, either accept the default location C:\Users\<your login name>\Documents\Visual Studio 2008\Projects or browse to a different location.

  7. In the Solution Name box, either type the solution name that you want to use for your application or accept the default name that you typed in step 5, and then click OK.

  8. When you see Welcome to the Win32 Smart Device Project Wizard, click Next.

  9. When the Win32 Smart Device Project Wizard displays the Platforms page, click the << button to clear the Selected SDKs column.

  10. Under Installed SDKs, select the name of your SDK, click the > button to move it to the Selected SDKs column, and then click Next.

  11. On the Project Settings page, under Application type, select Windows application, and then click Finish.

When the Win32 Smart Device Project Wizard finishes, Visual Studio opens your project and displays the source file that contains the WinMain function. For example, if the name of your project is "MyApplication," you will find WinMain in MyApplication.cpp. In the next set of steps, you replace this functionality with a simple "Hello World" example application and use it to verify your SDK.

To create the sample application

  1. In Visual Studio, open the project that you created in the previous set of steps, and then edit the file that contains WinMain; for example, MyApplication.cpp.

  2. Replace the contents of this file with the following code:

    #include "stdafx.h"
    
    // The main window class name.
    
    TCHAR szWindowClass[] = TEXT("HelloWorldApp");
    
    // The string that appears in the application's title bar.
    
    TCHAR szTitle[] = TEXT("Hello World");
    
    // Forward declaration of callback function.
    
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    
    int WINAPI WinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
    {
       WNDCLASS wc;
       wc.style = CS_HREDRAW | CS_VREDRAW;
       wc.lpfnWndProc = (WNDPROC) WndProc;
       wc.cbClsExtra = 0;
       wc.cbWndExtra = 0;
       wc.hInstance = hInstance;
       wc.hIcon = 0;
       wc.hCursor = 0;
       wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
       wc.lpszMenuName = 0;
       wc.lpszClassName = szWindowClass;
    
       // Register the application
    
       RegisterClass(&wc);
    
       // Create the window for the application: specify the name 
       // of the application, the title bar text, flags to make
       // the window visible and turn on decorations. The window
       // is 300x200 in size and there is no parent window or menu.
    
        HWND hWnd = CreateWindow (
            szWindowClass, szTitle, WS_VISIBLE | WS_CAPTION, 
            150, 100, 300, 200, NULL, NULL, hInstance, NULL);
    
        // Display the window.
    
        ShowWindow (hWnd, nCmdShow);
    
        // Send a WM_PAINT message to the window.
    
        UpdateWindow (hWnd);
    
        // Message loop that listens for OS messages. When
        // the application receives a message, this loop dispatches
        // the message to the WndProc function.
    
        MSG msg;
        while (GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
       return msg.wParam;
    }
    
    // Function that processes messages for the main (and only) window:
    
    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, 
                             WPARAM wParam, LPARAM lParam)
    {
       PAINTSTRUCT ps;
       HDC hdc;
       TCHAR szMessage[] = L"Hello World!";
    
       switch (message) 
       {
            case WM_PAINT:
    
                // Display the message:
    
                hdc = BeginPaint(hWnd, &ps);
                RECT rt;
                GetClientRect(hWnd, &rt);
                DrawText(hdc, szMessage,
                        _tcslen(szMessage), &rt, DT_CENTER);
                EndPaint(hWnd, &ps);
                break;
    
            case WM_DESTROY:
                PostQuitMessage(0);
                break;
    
            default:
                return DefWindowProc(hWnd, message, wParam, lParam);
       }
       return 0;
    }
    
  3. On the File menu, click Save All to save your changes.

  4. On the Build menu, click Build Solution. When the build completes successfully, a message similar to the following appears in the output pane:

    1>MyApplication - 0 error(s), 0 warning(s)``====== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ======

In the next set of steps, you start this application from Visual Studio and run it on your stand-alone virtual CEPC. First, you configure Visual Studio with the IP address of your virtual CEPC, and then you connect your virtual CEPC to Visual Studio and start your application from within Visual Studio.

To configure Visual Studio with the IP address of your virtual CEPC

  1. Start your virtual CEPC if it is not already running.

  2. On your virtual CEPC desktop, click Start, click Programs, and then click Command Prompt.

  3. In the Command Prompt window, type the following command to display the IP address of your virtual CEPC:

    ipconfig

  4. When this command finishes, a message similar to the following appears in the Command Prompt window:

    Windows IP configuration``Ethernet adapter [PCI\DC21X41]:`` IPv4 Address . . . . : 10.125.149.75 Subnet Mask . . . . . : 255.255.254.0`` IPv6 Address . . . . : fe80:6468:9205:4eeb:a79b%4`` Default Gateway . . . : 10.125.149.1

  5. Find the IP address for your virtual CEPC. The IP address is to the right of IPv4 Address. In the previous example, the IP address is 10.125.149.75. You will enter this IP address into Visual Studio in step 11 in this procedure.

  6. In Visual Studio, on the Tools menu, click Options.

  7. In the Options dialog box, expand Device Tools, and then click Devices.

  8. Under Devices, select the device name that is associated with your SDK; for example, "MyDevice Software Development Kit x86 Device".

  9. Click Properties to open the Device Properties dialog box.

  10. In the Device Properties dialog box, click the Configure button to the right of TCP Connect Transport.

  11. In the Configure TCP/IP Transport dialog box, in the Use specific IP address box, enter the IP address for your virtual CEPC, and then click OK.

  12. In the Device Properties dialog box, click OK.

  13. In the Options dialog box, click OK.

At this point, Visual Studio has the IP address of your virtual CEPC so that Visual Studio can connect to your virtual CEPC to start and debug applications. If you reboot your virtual CEPC, you do not have to repeat these steps.

To run the sample application on your virtual CEPC

  1. In the Command Prompt window of your virtual CEPC, enter the following commands:

    cd hard disk
    ConmanClient2.exe
    
  2. On the virtual CEPC desktop, click Start, click Programs, and then click Command Prompt to open a second Command Prompt window.

  3. In the second Command Prompt window of your virtual CEPC, enter the following commands:

    cd hard disk
    CMAccept.exe
    
  4. In Visual Studio, click the Connect to Device icon as shown in the following figure:

    Connect to Device Icon

  5. When Visual Studio displays the Connection succeeded message, click Close.

  6. In Visual Studio, on the Debug menu, click Start Debugging. The sample application appears on the desktop of your virtual CEPC as shown in the following figure.

    Running the Sample Application

    To stop the sample application, right-click Hello World on the virtual CEPC taskbar, and then click Close.

  7. If you want to restart your virtual CEPC, you only need to run ConmanClient2.exe and CMAccept.exe again as described above before starting and debugging your application.

After you verify that the sample application runs successfully on your virtual CEPC, you can verify that you have debug capability by setting breakpoints in this sample application before running it again.

To verify debug capability

  1. In Visual Studio, open the file in the sample application that contains WinMain; for example, MyApplication.cpp.

  2. Find the line of code that calls the function DrawText.

  3. Click in the gray area on the left side of the call to DrawText to set a breakpoint at this location. The breakpoint is represented as a reddish circle as shown in the following figure.

    Setting a Break Point

  4. Start the application in the debugger by pressing F5, or you can click Debug, and then click Start Debugging. The sample application should break before it prints the message to the application window, as shown in the following figure.

    Application Break Point

  5. Press F5 to continue, or click Debug, and then click Continue. The sample application should continue past the breakpoint and call the DrawText function, which displays the "Hello World!" message in the application window as shown in the previous figure.

These verification steps demonstrate how you can use virtual CEPC to develop your Compact 7 applications in Visual Studio-like any other Visual Studio application-without using Platform Builder and without having to install Compact 7 on the computer that you use for application development.

See Also

Concepts

Develop with Virtual CEPC