module 3: preparing an application development environment

27
Module 3: Preparing an Application Development Environment

Upload: alvaro

Post on 16-Jan-2016

29 views

Category:

Documents


0 download

DESCRIPTION

Module 3: Preparing an Application Development Environment. Overview. Exporting an SDK from Platform Builder Importing an SDK Win32 Programming Primer. Exporting an SDK from Platform Builder. Need for an SDK The Exporting Process. Need for an SDK. Platform Builder. Custom SDK. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Module 3: Preparing an Application Development Environment

Module 3: Preparing an Application

Development Environment

Page 2: Module 3: Preparing an Application Development Environment

Overview

Exporting an SDK from Platform Builder

Importing an SDK

Win32 Programming Primer

Page 3: Module 3: Preparing an Application Development Environment

Exporting an SDK from Platform Builder

Need for an SDK

The Exporting Process

Page 4: Module 3: Preparing an Application Development Environment

Need for an SDK

Windows CE OS configuration

Run-time libraries

OAL

Device drivers

Libraries

Header files

Help files

Runtime files

Platform extension

Platform Manager

components

Toolkits for Visual C++

Toolkits for Visual Basic

Platform Builder Custom SDK Windows CE Toolkits

Page 5: Module 3: Preparing an Application Development Environment

The Exporting Process

You Must Build A Platform Before Exporting an SDK

Menu : Platform/Export SDK

Choose Add-on technologies (MFC, ATL, Console application)

Select configuration

Check Platform Manager Transport Layer

Page 6: Module 3: Preparing an Application Development Environment

Importing an SDK

Importing to Embedded Visual C++

Importing to Embedded Visual Basic

Using the Platform Manager

Page 7: Module 3: Preparing an Application Development Environment

Decompress SDK into \Windows CE Tools directory

Run Embedded Visual C++

Select File | New… then [Projects] tab

Select Active WCE Configuration on WCE Configuration Toolbar.

Example:

Importing to Embedded Visual C++

Page 8: Module 3: Preparing an Application Development Environment

Decompress SDK into \Windows CE Tools directory

Run Embedded Visual Basic

Select File | New Project

On New Project Window, Select:

Windows CE Formless Project

Platform-Specific Project

Importing to Embedded Visual Basic

Page 9: Module 3: Preparing an Application Development Environment

Using Platform Manager

Platform Manager manages the interaction between desktop and target platform

Operates with toolkits (Visual C++, Visual Basic) to download applications

Connects target platform with remote tools

Target-side and host-side components

The target side - built by Platform Builder in your Windows CE image

The host side - created by toolkits with the exported custom SDK

Page 10: Module 3: Preparing an Application Development Environment

Win32 Programming Primer

Creating a Win32 Application

Useful Win32 Functions

The Unicode Character Set

Processes and Threads

Structured Exception Handling

Page 11: Module 3: Preparing an Application Development Environment

Creating a Win32 Application

Page 12: Module 3: Preparing an Application Development Environment

Creating a Win32 Application (continued)

Page 13: Module 3: Preparing an Application Development Environment

Creating a Win32 Application (continued)

Page 14: Module 3: Preparing an Application Development Environment

Useful Win32 Functions

MessageBox – Displays message window

Example:MessageBox(NULL, _T("Hello"), _T("Title"), 0);

NKDbgPrintfW – Format & debug output

Example:NKDbgPrintfW(_T("Value is %d\n\r"), iVal);

Page 15: Module 3: Preparing an Application Development Environment

ANSI Characters and Strings:

‘H’

“Hello Unicode”

==> Store as ‘char’ or ‘unsigned char’

Unicode Characters and Strings:

L’H’

L”Hello Unicode”

==> Store as “short’ or ‘unsigned short’

Bi-Modal (_UNICODE)

TEXT(‘H’)

TEXT(“Hello Unicode”)

Unicode - Compiler Support

Page 16: Module 3: Preparing an Application Development Environment

ANSICHAR - resolves to charLPSTR - resolves to char *

UnicodeWCHAR - resolves to unsigned shortLPWSTR - resolves to unsigned short *

Bi-Modal (_UNICODE)TCHAR - resolves to char or unsigned shortLPTSTR - resolves to char * or unsigned short *

Unicode - Data Types

Page 17: Module 3: Preparing an Application Development Environment

ANSI strlen() - query length strcpy() - copy string strcat() - concatenate string

Unicode wcslen() - query length wcscpy() - copy string wcscat() - concatenate string

Bi-Modal (_UNICODE) _tcslen() - query length _tcscpy() - copy string _tcscat() - concatenate string

Unicode - C-Runtime Functions

Page 18: Module 3: Preparing an Application Development Environment

Converting to Unicode mbstowcs(

wchar_t *wcstr, // Output string.

const char *mbstr, // Input string.

size_t count ); // Character count. Converting From Unicode

wcstombs(

char *mbstr, // Output string.

const wchar_t *wcstr, // Input string.

size_t count ); // Character count.

Unicode - C-Runtime Conversion Functions

Page 19: Module 3: Preparing an Application Development Environment

Processes and Threads

Processes

Maximum 32 processes can be loaded at the same time Support for console applications

Threads

Smallest unit of execution Number of threads only limited by available memory Preemptive priority-based scheduling (256 priorities) Quantum default length is 100ms (configurable)

Page 20: Module 3: Preparing an Application Development Environment

CreateProcess(

LPCTSTR lpszImageName, // EXE file name

LPCTSTR lpszCmdLine, // Parameters

LPSECURITY_ATTRIBUTES lpsaProcess, // = NULL

LPSECURITY_ATTRIBUTES lpsaThread, // = NULL

BOOL fInheritHandles, // Windows CE requires FALSE

DWORD dwFlags, // See docs for details

LPVOID lpEnvironment, // = NULL

LPTSTR lpszCurDir, // Startup directory // = NULL

LPSTARTUPINFO lpStart, // = NULL

LPPROCESS_INFORMATION lppi); // Return handles

Processes and Threads - Creating a Process

Page 21: Module 3: Preparing an Application Development Environment

1G

0

Slot 32Slot 32Slot 31Slot 31Slot 30Slot 30

..

..

..Slot 3Slot 3Slot 2Slot 2Slot 1Slot 1Slot 0Slot 0

private.dllprivate.dllshared.dllshared.dllcoredll.dllcoredll.dll

App.ExeApp.Exe

64K NML64K NML

32M AddressSpace

Processes and Threads –System and Process Memory

Page 22: Module 3: Preparing an Application Development Environment

Creating Threads:

CreateThread (Win32)

Suspending Threads:

SuspendThread (Win32)

ResumeThread (Win32)

Destroying Threads:

ExitThread (Win32)

TerminateThread (Win32)

Processes and Threads - Thread API

Page 23: Module 3: Preparing an Application Development Environment

__try {

// Protected block.

}

__except (/* filter */ )

{

// Exception handler.

}

Structured Exception Handling - Exception Syntax

Page 24: Module 3: Preparing an Application Development Environment

__try { ... ... ... ... ... ...}

__except ( ) { ... ... ... ... ... ... }

// hard code a value__except (EXCEPTION_EXECUTE_HANDLER)

// hard code a value__except (EXCEPTION_EXECUTE_HANDLER)

// call a function__except (CheckIt(GetExceptionCode())...int CheckIt (DWORD dwCode) { switch (dwCode) { case xxxx:... } return EXCEPTION_EXECUTE_HANDLER; }

// call a function__except (CheckIt(GetExceptionCode())...int CheckIt (DWORD dwCode) { switch (dwCode) { case xxxx:... } return EXCEPTION_EXECUTE_HANDLER; }

// expression__except((GetExceptionCode()== EXCEPTION_ACCESS_VIOLATION) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)

// expression__except((GetExceptionCode()== EXCEPTION_ACCESS_VIOLATION) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)

Structured Exception Handling - The Filter

Page 25: Module 3: Preparing an Application Development Environment

Create an exception

VOID RaiseException(dwCode, dwFlags, cArgs, lpArgs)

Query exception

DWORD GetExceptionCode (VOID)

Query abnormal termination

BOOL AbnormalTermination (VOID)

Query exception information

LPEXCEPTION_POINTERS GetExceptionInformation (void)

Structured Exception Handling - Exception API

Page 26: Module 3: Preparing an Application Development Environment

Lab A: Exploring the Embedded Visual Tools 3.0

Page 27: Module 3: Preparing an Application Development Environment

Review

Exporting an SDK from Platform Builder

Importing an SDK

Win32 Programming Primer