Module 3: Preparing an Application Development Environment

Post on 16-Jan-2016

26 views 0 download

Tags:

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 of Module 3: Preparing an Application Development Environment

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

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

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

Importing an SDK

Importing to Embedded Visual C++

Importing to Embedded Visual Basic

Using the Platform Manager

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++

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

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

Win32 Programming Primer

Creating a Win32 Application

Useful Win32 Functions

The Unicode Character Set

Processes and Threads

Structured Exception Handling

Creating a Win32 Application

Creating a Win32 Application (continued)

Creating a Win32 Application (continued)

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);

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

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

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

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

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)

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

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

Creating Threads:

CreateThread (Win32)

Suspending Threads:

SuspendThread (Win32)

ResumeThread (Win32)

Destroying Threads:

ExitThread (Win32)

TerminateThread (Win32)

Processes and Threads - Thread API

__try {

// Protected block.

}

__except (/* filter */ )

{

// Exception handler.

}

Structured Exception Handling - Exception Syntax

__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

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

Lab A: Exploring the Embedded Visual Tools 3.0

Review

Exporting an SDK from Platform Builder

Importing an SDK

Win32 Programming Primer