Share via


Step by Step: Migrating an eMbedded Visual C++ Application to Visual Studio 2005

 

Microsoft Corporation

June 2006

Applies to:
   Microsoft ActiveSync
   Microsoft eMbedded Visual C++
   Windows Mobile–based devices
   Microsoft Win32
   Microsoft Windows XP Professional
   Microsoft Visual Studio 2005

Summary: Say goodbye to eMbedded Visual C++ and build a native Windows Mobile-based application by using Visual Studio 2005. This hands-on lab (HOL) will take one hour and 30 minutes to complete. (23 printed pages)

Download MEDC06_HOL303.msi from the Microsoft Download Center.

Contents

Introduction
Lab 1: Migrating an eMbedded Visual C++ Win32 Project to Visual Studio 2005
Summary
Lab 2: Migrating an eMbedded Visual C++ MFC Project to Visual Studio 2005
Summary
Appendix A: Terminating an Application That Is Running on a Device or Emulator
Appendix B: Setting Up Your Computer

The following applications are required to run this HOL:

Introduction

You will migrate an eMbedded Visual C++ project to Visual Studio 2005, make it orientation-aware, debug the application by using the device emulator, and build a .cab file for deployment. Upon completion of this HOL, you will be ready to start using Visual Studio 2005 as your new integrated development environment (IDE) for native Windows Mobile–based application development.

Lab 1: Migrating an eMbedded Visual C++ Win32 Project to Visual Studio 2005

The objective of this lab is to migrate a Windows Mobile 2003–based Pocket PC project that was created in eMbedded Visual C++ to Visual Studio 2005, and then to create a Smart Device CAB project for it.

In this HOL, you will perform the following exercises:

  • Migrating an eMbedded Visual C++ Win32 project to Visual Studio 2005
  • Creating a Smart Device CAB Project

Exercise 1: Migrating an eMbedded Visual C++ Win32 Project to Visual Studio 2005

In this exercise, you will convert a Win32 project that was originally created in eMbedded Visual C++ to a Smart Device C++ project in Visual Studio 2005. You will also make that project orientation aware, and you will open it in two device emulators.

To open an eMbedded Visual C++ project in Visual Studio 2005

  1. In Visual Studio 2005, click File | Open | Project/Solution.
  2. Browse to C:\Program Files\Windows Mobile Developer Samples\HOLs\MEDC06_HOL303\Exercises\Dirtree.
  3. Select dirtree.vcp, and then click Open.
  4. On the Visual Studio Conversion Wizard welcome page, click Finish, and then click Close.
  5. In Solution Explorer, right-click the DirTree project, and then click Properties.
  6. Expand Configuration Properties | Linker | Input.
  7. In the Configuration drop-down list box, select All Configurations.
  8. In the Platform drop-down list box, select All Platforms.
  9. In the Ignore Specific Library property, replace the default text by typing oldnames.lib.
  10. In the Additional Dependencies property, type commctrl.lib coredll.lib aygshell.lib.
  11. Click OK.

To make a project orientation aware

  1. In Solution Explorer, expand dirtree | Source Files.

  2. Double-click the treedir.rc file.

  3. On Resource View tab, expand treedir.rc | Dialog.

  4. Right-click the IDD_ABOUT dialog, and then choose Copy.

  5. Select the Dialog folder, and then click Paste.

  6. Select IDD_ABOUT1, and then click the Properties tab.

  7. In the Properties pane, change the ID value from IDD_ABOUT1 to IDD_ABOUT_WIDE.

  8. Double-click IDD_ABOUT_WIDE to open it in the Dialog Editor.

  9. Resize IDD_ABOUT_WIDE to be approximately 215 x 135, as shown in Figure 1. (You can find the size of the dialog in the status bar at the lower-right corner of the IDE).

    Figure 1. Resizing the IDD_ABOUT_WIDE dialog. Click the thumbnail for a larger image.

  10. Move the icon to the right of the text, as shown in Figure 1.

  11. In Solution Explorer, expand dirtree | Header Files, and double-click resource.h.

  12. In resource.h, add the following line near the other #define statements.

    #define IDD_ABOUT_WIDE                  200
    
  13. In Solution Explorer, under dirtree | Header Files, double-click globals.h.

  14. In globals.h, add the following line near the other #include statement.

    #include <DeviceResolutionAware.h>
    
  15. In Solution Explorer, under dirtree | Source Files, double-click wndproc.cpp.

  16. In wndproc.cpp, locate void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify).

  17. Replace DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ABOUT), hwnd, (DLGPROC)AboutDlgProc); with the following code.

    DialogBox(g_hInstance, DRA::GetDisplayMode() != DRA::Portrait ? MAKEINTRESOURCE(IDD_ABOUT_WIDE) : MAKEINTRESOURCE(IDD_ABOUT), hwnd, (DLGPROC)AboutDlgProc);
    
  18. Locate LRESULT CALLBACK AboutDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam), and then add the following CASE statement to the existing switch(uMsg) statement.

    case WM_SIZE:
        DRA::RelayoutDialog(
        g_hInstance, 
        hwnd, 
        DRA::GetDisplayMode() != DRA::Portrait ? MAKEINTRESOURCE(IDD_ABOUT_WIDE) : MAKEINTRESOURCE(IDD_ABOUT));
        return (TRUE);
    

    The code for LRESULT CALLBACK AboutDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) should now look like the following.

    LRESULT CALLBACK AboutDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam,
                                  LPARAM lParam)
    {
        SHINITDLGINFO shidi;
    
        switch(uMsg)
        {
        case WM_INITDIALOG:
            //On Pocket PC devices, you normally create all dialogs as         // full
            // screen dialogs with an OK button in the upper corner. 
            // Create a Done button and size it.
            shidi.dwMask = SHIDIM_FLAGS;
            shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
            shidi.hDlg = hwnd;
            //Initialzes the dialog based on the dwFlags parameter
            SHInitDialog(&shidi);
            // Should return nonzero to set focus to the first control         // in the
            // dialog, or zero if this routine sets the focus manually.
            return (TRUE);
    
            case WM_COMMAND:
                switch (LOWORD(wParam))
                {
                    case IDOK:
                        EndDialog(hwnd, 0);
                        break;
                    case IDCANCEL:
                        EndDialog(hwnd, 0);
                        break;
                }
                return (TRUE);
            case WM_SIZE:
                DRA::RelayoutDialog
                (g_hInstance, 
                hwnd, 
                DRA::GetDisplayMode() != DRA::Portrait ? MAKEINTRESOURCE(IDD_ABOUT_WIDE) : MAKEINTRESOURCE(IDD_ABOUT));
                return (TRUE);
        }
        return (FALSE);
    }
    

To run the application on a Pocket PC 2003 emulator

  1. In the Configuration Manager box, be sure that Pocket PC 2003 (ARMV4) is selected, as shown in Figure 2.

    Figure 2. Configuration Manager

  2. To enable the Device Deployment toolbar in Step 3, it may be necessary to build the project and save the solution. Press F6 to build, and if prompted, save the Visual Studio 2005 solution file.

  3. On the Device Deployment toolbar, be sure that Pocket PC 2003 SE Emulator is selected, as shown in Figure 3.

    Figure 3. Device Deployment toolbar

  4. Press F5 to run the application.

    Note   If you receive an error during deployment that indicates that the process or file is in use, this means that the program is still running on the emulator and must be closed before a new copy can be deployed and run. This error may appear anytime in the lab that you deploy the emulator. See Appendix A in this HOL for instructions about exiting a running application.

  5. After the application is started in the emulator, in the application, select Help | About, as shown in Figure 4.

    Figure 4. The DirTree application. Click the thumbnail for a larger image.

  6. Rotate the screen orientation by pressing the Calendar button, as shown in Figure 5.

    Figure 5. The Calendar button on the Pocket PC 2003 SE emulator. Click the thumbnail for a larger image.

  7. Observe that the landscape version of the About screen is loaded.

  8. In Visual Studio, click Debug | Stop Debugging to end the application.

To run the application on a Windows Mobile 5.0 Pocket PC emulator

  1. In the Configuration Manager box, be sure that Windows Mobile 5.0 Pocket PC SDK (ARMV4I) is selected.

  2. On the Device Deployment toolbar, make sure that Windows Mobile 5.0 Pocket PC Emulator is selected.

  3. Press F5.

  4. After the application is started in the emulator, in the application, select Help | About.

  5. Rotate the screen orientation by pressing the Calendar button, as shown in Figure 6.

    Figure 6. Rotating the Windows Mobile 5.0 Pocket PC emulator

  6. Observe that the landscape version of the About screen is loaded.

  7. In Visual Studio, click Debug | Stop Debugging to end the application.

Exercise 2: Creating a Smart Device CAB Project

In this exercise, you will create a .cab file that will be used to install the Win32 project that you converted in Exercise 1.

To create a Smart Device CAB Project

  1. In Solution Explorer, right-click the solution, and then click Add | New Project.
  2. Expand Other Project Types | Setup and Deployment.
  3. Select Smart Device CAB Project.
  4. In the Name box, type DirTreeSetup, and then click OK.
  5. In Solution Explorer, right-click the newly created DirTreeSetup project, and then click View | File System.
  6. On the File System window, right-click Program Files Folder, and then click Add | Folder.
  7. Name the newly added folder DirTree.
  8. Right-click the DirTree folder, and then click Add | Project Output.
  9. In the Project drop-down list box, be sure that DirTree is selected, and then click Primary Output.
  10. In the Configuration drop-down list box, be sure that (Active) is selected.
  11. Click OK.
  12. In Solution Explorer, right-click the DirTreeSetup project, and then click Build.
  13. Verify that you can find the DirTreeSetup.cab file in C:\Program Files\Windows Mobile Developer Samples\HOLs\MEDC06_HOL303\Exercises\DirTreeSetup\Debug.
  14. In Visual Studio 2005, click File | Close Solution.

Summary

In this lab, you performed the following exercises:

  • Migrating an eMbedded Visual C++ Win32 project to Visual Studio 2005
  • Creating a Smart Device CAB Project

Lab 2: Migrating an eMbedded Visual C++ MFC Project to Visual Studio 2005

Many of the typical questions should be covered in What's New in Visual Studio 2005 for Native Developers and Migrating Microsoft eMbedded Visual C++ Projects to Visual Studio 2005.

If you press CTRL+SPACEBAR to get Microsoft IntelliSense to complete a line, the IDE might freeze. If this occurs, understand that it's a known bug, and do not press CTRL+SPACEBAR.

Lab Objective

The objective of this lab is to migrate a Windows Mobile 5.0–based Pocket PC project that was created in eMbedded Visual C++ to Visual Studio 2005, and then to create a Smart Device CAB Project for it.

In this HOL, you will perform the following exercises:

  • Migrating an eMbedded Visual C++ MFC project to Visual Studio 2005
  • Creating a Smart Device CAB Project

Exercise 1: Migrating an eMbedded Visual C++ MFC Project to Visual Studio 2005

In this exercise, you will convert an MFC project that was originally created in eMbedded Visual C++ to a Smart Device C++ project in Visual Studio 2005. You will also open the project in two device emulators.

To open an eMbedded Visual C++ project in Visual Studio 2005

  1. In Visual Studio 2005, click File | Open | Project/Solution.
  2. Browse to C:\Program Files\Windows Mobile Developer Samples\HOLs\MEDC06_HOL303\Exercises\Chkbook.
  3. Select chkbook.vcp, and then click Open.
  4. Click Finish | Close.

To migrate code (part 1)

  1. In Solution Explorer, expand chkbook | Source Files, and then double-click checkdlg.cpp.

  2. In checkdlg.cpp, replace all three occurrences of _tcslen with ::wcslen.

    This step is needed to disambiguate between the platform API and the MFC API.

  3. In Solution Explorer, under chkbook | Source Files, double-click chkbkdoc.cpp.

  4. In the chkbkdoc.cpp file, comment out the following code because Dump is not supported in MFC 8.0 for devices.

    void CCheckBookDoc::Dump(CDumpContext& dc) const
    {
        CDocument::Dump(dc);
    }
    
  5. In Solution Explorer, under chkbook | Header Files, double-click chkbkdoc.h.

  6. In the chkbkdoc.h header file, comment out the following code.

    virtual void Dump(CDumpContext& dc) const;
    
  7. In Solution Explorer, under chkbook | Source Files, double-click chkbkedt.cpp.

    In the chkbkedt.cpp file, replace static bSetTabStops = FALSE; with the following code.

    static BOOL bSetTabStops = FALSE;
    

    This step is necessary due to the tighter conformance characteristics of the Visual Studio 2005 device compilers (as compared to the eMbedded Visual C++ compilers).

  8. In Solution Explorer, under chkbook | Source Files, double-click chkbkvw.cpp.

  9. In the chkbkvw.cpp file, comment out the following code.

    void CCheckBookView::Dump(CDumpContext& dc) const
    {
        CView::Dump(dc);
    }
    
  10. Also comment out the following code.

    m_dlg.m_bFullScreen=FALSE;
    

    The m_dlg.m_bFullScreen class variable member is always set to True for Windows Mobile platforms (set in dlgcore.cpp).

  11. In Solution Explorer, under chkbook | Header Files, double-click chkbkvw.h.

  12. In the chkbkvw.h file, comment out the following code.

    virtual void Dump(CDumpContext& dc) const;
    

To migrate resources

  1. In Solution Explorer, under chkbook | Resource Files, right-click chkbook.rc, and then click View Code.

  2. In the Menu section, replace the following code:

    IDR_MAINFRAME MENU PRELOAD DISCARDABLE 
    BEGIN
        POPUP "&File"
        BEGIN
            MENUITEM "&New...\tCtrl+N",    ID_FILE_NEW
            MENUITEM "&Open...\tCtrl+O",  ID_FILE_OPEN
            MENUITEM SEPARATOR
            MENUITEM "E&xit",      ID_APP_EXIT
        END
        POPUP "&Edit"
        BEGIN
            MENUITEM "&Commit Check",  ID_EDIT_COMMIT
            MENUITEM SEPARATOR
            MENUITEM "&New Check",    ID_EDIT_NEW_CHECK
            MENUITEM SEPARATOR
            MENUITEM "Ne&xt Check",    ID_NEXT_CHECK
            MENUITEM "&Prev Check",    ID_PREV_CHECK
        END
        POPUP "&View"
        BEGIN
            MENUITEM "&Check",      ID_VIEW_CHECK
            MENUITEM "&Book",      ID_VIEW_BOOK
        END
        POPUP "&Help"
        BEGIN
            MENUITEM "&About...",    ID_APP_ABOUT
        END
    END
    

    with the following:

    IDR_MAINFRAME MENU PRELOAD DISCARDABLE 
    BEGIN
        POPUP "Menu"
        BEGIN
            POPUP "File"
            BEGIN
                MENUITEM "New...",      ID_FILE_NEW
                MENUITEM "Open...",     ID_FILE_OPEN
                MENUITEM SEPARATOR
                MENUITEM "Exit",        ID_APP_EXIT
            END
            POPUP "Edit"
            BEGIN
                MENUITEM "Commit Check",   ID_EDIT_COMMIT
                MENUITEM SEPARATOR
                MENUITEM "New Check",      ID_EDIT_NEW_CHECK
                MENUITEM SEPARATOR
                MENUITEM "Next Check",     ID_NEXT_CHECK
                MENUITEM "Prev Check",     ID_PREV_CHECK
            END
            POPUP "View"
            BEGIN
                MENUITEM "Check",      ID_VIEW_CHECK
                MENUITEM "Book",       ID_VIEW_BOOK
            END
            POPUP "Help"
            BEGIN
                MENUITEM "About...",   ID_APP_ABOUT
            END
        END
    END
    
  3. Comment out the following code.

    STRINGTABLE DISCARDABLE 
    BEGIN
        ID_FILE_MRU_FILE1       "Open this document"
        ID_FILE_MRU_FILE2       "Open this document"
        ID_FILE_MRU_FILE3       "Open this document"
        ID_FILE_MRU_FILE4       "Open this document"
        ID_FILE_MRU_FILE5       "Open this document"
        ID_FILE_MRU_FILE6       "Open this document"
        ID_FILE_MRU_FILE7       "Open this document"
        ID_FILE_MRU_FILE8       "Open this document"
        ID_FILE_MRU_FILE9       "Open this document"
        ID_FILE_MRU_FILE10      "Open this document"
        ID_FILE_MRU_FILE11      "Open this document"
        ID_FILE_MRU_FILE12      "Open this document"
        ID_FILE_MRU_FILE13      "Open this document"
        ID_FILE_MRU_FILE14      "Open this document"
        ID_FILE_MRU_FILE15      "Open this document"
        ID_FILE_MRU_FILE16      "Open this document"
    END
    
  4. In the String Table section, at the end of the last STRINGTABLE DISCARDABLE section, add the following lines of code.

    IDS_MENU                "Menu"
    IDS_NEW                 "New"
    

To add RCDATA to the .rc2 file

  1. In Solution Explorer, right-click the Resource Files folder, and then click Add | Existing Item.

  2. Double-click the Res directory in the Chkbook sample directory, and then change Files of type to All Files (*.*).

  3. Select chkbook.rc2, and then click Add.

  4. In Solution Explorer, right-click chkbook.rc2, and then click View Code.

  5. In the Add Manually Edited Resources Here section, add the following code.

    IDR_MAINFRAME RCDATA
    BEGIN
        IDR_MAINFRAME, 
        2,
    
        I_IMAGENONE, ID_FILE_NEW, TBSTATE_ENABLED, TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE,
        IDS_NEW, 0, NOMENU,
    
        I_IMAGENONE, IDM_MENU, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
        IDS_MENU, 0, 0,
    END
    

To migrate code (part 2)

  1. In Solution Explorer, under chkbook | Header Files, double-click resource.h.

  2. In the resource.h header file, add the following lines near the other #define statements.

    #define IDS_NEW        70000
    #define IDS_MENU       70001
    #define IDM_MENU       70002
    
  3. In Solution Explorer, under chkbook | Source Files, double-click chkrec.cpp.

  4. In the chkrec.cpp file, change all three occurrences of if (m_file.m_hFile != (UINT)CFile::hFileNull) to the following code.

    if (m_file.m_hFile != (HANDLE)CFile::hFileNull)
    

    Note Take care when searching: one occurrence of the line to be replaced has no space after the if.

  5. In Solution Explorer, under chkbook | Header Files, double-click chkrec.h.

  6. In the chkrec.h header file, change m_nRecordLength = sizeof(CCheckRecord); if (m_file.m_hFile != -1) m_file.Close(); to the following code.

    m_nRecordLength = sizeof(CCheckRecord); if (m_file.m_hFile !=  (HANDLE) -1) m_file.Close();
    
  7. In Solution Explorer, under chkbook | Source Files, double-click mainfrm.cpp.

  8. In the mainfrm.cpp file, make the following changes:

    • Comment out the following code.

      void CMainFrame::Dump(CDumpContext& dc) const
      {
        CFrameWnd::Dump(dc);
      }
      
    • Replace the entire int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) function with the following code.

      int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
      {
          if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
              return -1;
          if (!m_wndCommandBar.Create(this) ||
          !m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) ||
          !m_wndCommandBar.AddAdornments(dwAdornmentFlags))
          {
              TRACE0("Failed to create CommandBar\n");
              return -1;      // fail to create
          }
      m_wndCommandBar.SetBarStyle(m_wndCommandBar.GetBarStyle() | CBRS_SIZE_FIXED);
      
          return 0;
      }
      
    • Add the following line of code near the top of the mainfrm.cpp file, but below the #define statements (just above the // CMainFrame comment is a good place).

      DWORD dwAdornmentFlags = 0;
      
  9. In Solution Explorer, under chkbook | Header Files, double-click mainfrm.h.

  10. In the mainfrm.h header file, make the following changes:

    • Change CCeCommandBar m_wndCommandBar; to the following code.

      CCommandBar m_wndCommandBar;
      
    • Comment out the following code.

      virtual void Dump(CDumpContext& dc) const;
      

To change the project's properties

  1. In Solution Explorer, right-click the chkbook project, and then click Properties.

  2. In the Configuration drop-down list box, select All Configurations.

  3. In the Platform drop-down list box, select All Platforms.

  4. Expand Linker | Advanced.

  5. Change the Entry Point property from wWinMainCRTStartup to WinMainCRTStartup, as shown in Figure 7. Click Apply.

    Figure 7. Entry Point property in the ChkBook Property Pages dialog box. Click the thumbnail for a larger image.

  6. Expand C/C++ | Preprocessor.

  7. In the Platform drop-down list box, click Multiple Platforms.

  8. In the Multiple Platforms dialog box, be sure that the Pocket PC 2003 (ARMV4) and Windows Mobile 5.0 Pocket PC SDK (ARMV4I) check boxes are selected, and clear the Smartphone 2003 (ARMV4) and Windows Mobile 5.0 Smartphone SDK (ARMV4I) check boxes.

  9. Click the ellipsis in the Preprocessor Definitions property, and then add the following definitions.

    _ARM_
    ARM
    _WIN32_WCE=$(CEVER)
    WIN32_PLATFORM_PSPC
    WINCE
    UNDER_CE
    _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA
    
  10. Click OK, and then click OK.

  11. In Solution Explorer, under chkbook | Header Files, double-click stdafx.h.

  12. In the stdafx.h header file, add the following #define statement immediately following the existing #define statement.

    #define WINVER _WIN32_WCE
    

To run the application on the Pocket PC 2003 emulator

  1. In the Configuration Manager box, be sure that Pocket PC 2003 (ARMV4) is selected, as shown in Figure 8.

    Figure 8. Configuration Manager

  2. To enable the Device Deployment toolbar in Step 3, it may be necessary to build the project and save the solution. Press F6 to build, and if prompted, save the Visual Studio 2005 solution file.

  3. On the Device Deployment toolbar, be sure that Pocket PC 2003 SE Emulator is selected, as shown in Figure 9.

    Figure 9. Device Deployment toolbar

  4. Press F5 to run the application.

  5. Verify that the application operates properly.

  6. In Visual Studio, click Debug | Stop Debugging to end the application.

To run the application on a Windows Mobile 5.0 Pocket PC emulator

  1. In the Configuration Manager, be sure that Windows Mobile 5.0 Pocket PC SDK (ARMV4I) is selected, as shown in Figure 10.

    Figure 10. Configuration Manager

  2. On the Device Deployment toolbar, be sure that Windows Mobile 5.0 Pocket PC Emulator is selected, as shown in Figure 11.

    Figure 11. Device Deployment toolbar

  3. Press F5 to run the application.

  4. Verify that the application operates properly.

  5. In Visual Studio, click Debug | Stop Debugging to end the application.

Exercise 2: Creating a Smart Device CAB Project

In this exercise, you will create a .cab file that will be used to install the MFC project that you converted in Exercise 1.

To create a Smart Device CAB Project

  1. In Solution Explorer, right-click the solution, and then click Add | New Project.
  2. Expand Other Project Types | Setup and Deployment.
  3. Select Smart Device CAB Project.
  4. In the Name text box, type ChkbookSetup, and then click OK.
  5. In Solution Explorer, right-click the newly created ChkbookSetup project, and then click View | File System.
  6. On the File System window, right-click Program Files Folder, and then click Add | Folder.
  7. Name the newly added folder Chkbook.
  8. Right-click the Chkbook folder, and then click Add | Project Output.
  9. In the Project drop-down list box, be sure that Chkbook is selected, and then click Primary Output.
  10. In the Configuration drop-down list box, be sure that (Active) is selected.
  11. Click OK.
  12. In Solution Explorer, right-click the ChkbookSetup project, and then click Build.
  13. Verify that the ChkbookSetup.cab file has been generated in C:\Program Files\Windows Mobile Developer Samples\HOLs\MEDC06_HOL303\Exercises\ChkbookSetup\Debug.
  14. In Visual Studio 2005, click File | Close Solution.

Summary

In this lab, you performed the following exercises:

  • Migrating an eMbedded Visual C++ MFC project to Visual Studio 2005
  • Creating a Smart Device CAB Project

Appendix A: Terminating an Application That Is Running on a Device or Emulator

This appendix describes how to terminate an application that is running on a device or emulator. This is useful for cases where an application has been started without having the debugger attached and the application needs to be terminated so a new copy of the application can be deployed. You will terminate the application by using the Remote Process Viewer remote tool in Visual Studio.

Before you can terminate a process, you need to know the name of the executable file. In most cases, this is the same name as the Visual Studio project. If you are uncertain about the name of the executable file, you can find it in the project's properties.

To terminate an application that is running on a device or emulator by using the Remote Process Viewer remote tool

  1. In Visual Studio, click Project | xxx Properties, where xxx represents the name of the current project.

  2. In the Project Properties dialog box, click Linker from the tree on the left, and then note the value of the Output File field (format $(PlatformName)\$(ConfigurationName)/chkbook.exe).chkbook.exe.

    This is the name that the executable file will be running on the device or emulator.

  3. Close the Properties dialog box.

    Now, you can terminate the process.

  4. On the desktop computer, click Start | Microsoft Visual Studio 2005 | Visual Studio Remote Tools | Remote Process Viewer.

  5. When prompted by the Select a Windows CE Device dialog box, select the emulator or device where the application is running, as shown in Figure 12, and then click OK.

    Figure 12. Select a Windows CE Device dialog box

  6. After the connection to the emulator or device completes, select the application that you want to terminate in the top pane of the Remote Process Viewer, as shown in Figure 13.

    Figure 13. Selecting the application to terminate. Click the thumbnail for a larger image.

    You may need to widen the Process column (the leftmost column) to fully view the process names.

  7. In Windows CE Remote Process Viewer, click File | Terminate Process to terminate the process.

    Note Be certain that the correct process is selected before you click Terminate Process. Terminating the incorrect process may render the device or emulator unusable, requiring it to be reset before you can use it again.

  8. Verify that the process is terminated by selecting Target | Refresh. Scroll to the top pane of Windows CE Remote Process Viewer again. If the application name still appears, the process was not terminated, and you need to repeat these steps.

    Note   Most processes terminate in one try; however, depending on the state of the application, terminating a process occasionally takes two attempts.

Appendix B: Setting Up Your Computer

The following lab files are required to set up your computer to run this HOL:

  • Pre-existing Visual Studio 2005 project, code, and data files.

To install these files to the correct path, download and run the following installation program: MEDC06_HOL303.msi.

Note If you used an emulator in a previous HOL, you should do a hard reset on the emulator before starting this HOL. (On the emulator, click File | Reset | Hard.)

Note If you receive an error during deployment that indicates that the process or file is in use, this means that the program is still running on the emulator and must be closed before a new copy can be deployed and run. This error may appear anytime in the lab that you deploy the emulator. See Appendix A in this HOL for instructions about exiting a running application.