Chapter 2: Windows Programming Basics

Overview

In this chapter, I cover the two aspects most important for everyone who is going to start programming for Windows in Assembly language. These are application programming interface (API) function calls and possible structures of Windows programs. [i] There are several types of program structures, conventionally classified as follows : [ii]

  • Classical structureThe structure with one main window.

  • Dialog structureThe main window is a dialog box.

  • Console applicationThe main window is the console window (either created or inherited).

  • Nonwindowing structureA Windows application that has no main window. [iii]

  • ServicesSpecialized programs that play a specific role in the operating system.

  • DriversSpecialized programs for controlling peripheral devices.

In this chapter, the main attention will be concentrated on the first (classical) program structure.

Well, let me start by explaining several fundamental concepts of Windows programming. Those of you who already have some experience in the field of Windows programming can skip this material.

  • Windows programming is based on the calls to API functions. The number of such functions is about 2,000. Most of your program will consist of such calls. All interaction with peripheral devices and operating system resources will be carried out using these functions.

  • The list of API functions and their descriptions can be found in the WIN32.HLP file, which is supplied, for example, with the Borland C++ compiler.

  • In the Windows environment, the main element of the program is its window. For every window, a special message-processing procedure [i] must be defined. More information on this topic will be provided later.

  • A window can contain various controls: command buttons , drop-down lists, edit fields, etc. Principally, these controls also represent windows with special properties. All events related to the window controls and to the window itself dispatch messages to the window procedure.

  • Windows uses flat memory addressing. In other words, the entire memory space can be considered one segment. For the programmer writing programs in Assembly language, this means that the address of any memory cell will be defined by the content of a single 32-bit register (e.g., EBX ).

  • As a consequence of the previous statement, there are practically no limitations to the size of the data, code, or stack (the size of the local variables ). Segments now play another role in the program text. They allow you to specify certain properties for individual code sections: protection against writing, general access, etc.

  • Windows is a multitasking environment. Every task has its own address space and its own message queue. Furthermore, multitasking is possible within a single taskevery procedure can be executed as a separate task.

Now, after explaining some theoretical aspects, it is time to proceed with considering some programming examples.

[i] Not to be confused with the structure of executable modules.

[ii] I developed this classification.

[iii] As will be shown later, console applications also can have dialogs.

[i] Based on the terminology once adopted in MS-DOS, such a procedure must be called the "interrupt procedure." Windows, however, uses different terminology. Such procedures, called by the operating system itself, are CALLBACK procedures.



The Assembly Programming Master Book
The Assembly Programming Master Book
ISBN: 8170088178
EAN: 2147483647
Year: 2004
Pages: 140
Authors: Vlad Pirogov

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net