0% found this document useful (0 votes)
88 views

Overview of Windows Programming History of Windows GUI in Windows Multitasking in Windows Memory in Windows DLL's API COM

The document provides an overview of key concepts in Windows programming, including: - Dynamic Link Libraries (DLLs) allow code and data to be shared among multiple programs, improving efficiency. Common Windows DLLs provide functions for graphics, dialog boxes, and memory/process management. - The Application Programming Interface (API) defines routines and protocols for building software. It interfaces programs with processors through functions, structures and constants declared in projects. - The Component Object Model (COM) standardizes class interfaces to allow components written in different languages like C++ and Visual Basic to communicate seamlessly. - Resources like menus, icons and dialog boxes are stored in executable files and accessed via functions based on their type,

Uploaded by

JayalaxmiS
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views

Overview of Windows Programming History of Windows GUI in Windows Multitasking in Windows Memory in Windows DLL's API COM

The document provides an overview of key concepts in Windows programming, including: - Dynamic Link Libraries (DLLs) allow code and data to be shared among multiple programs, improving efficiency. Common Windows DLLs provide functions for graphics, dialog boxes, and memory/process management. - The Application Programming Interface (API) defines routines and protocols for building software. It interfaces programs with processors through functions, structures and constants declared in projects. - The Component Object Model (COM) standardizes class interfaces to allow components written in different languages like C++ and Visual Basic to communicate seamlessly. - Resources like menus, icons and dialog boxes are stored in executable files and accessed via functions based on their type,

Uploaded by

JayalaxmiS
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 28

Overview of Windows Programming

 History of windows
 GUI in windows
 Multitasking in windows
 Memory in windows
 DLL’s
 API
 COM
DLL’s
 Dynamic Link Library
 DLLs - introduced with the first releases of the
Microsoft Windows OS, and today are a
fundamental structural component of the OS
 DLLs allow certain code fragments to be compiled
into a single library, and to be linked to by multiple
programs.
 This means that only one copy of the library
needs to exist, and multiple programs can share
the functions and the data between them.
Examples of DLL
 COMDLG32.DLL-controls the dialog
boxes
 GDI32.DLL-contains numerous functions
for drawing graphics, displaying text and
managing fonts
 KERNEL32.DLL-contains hundreds of
functions for the management of memory
and various processes
API
 Application Programming Interface
 API is a set of routines, protocols, and
tools for building software applications
 API is set of commands, which interfaces
the programs with the processors.
 API consists of thousands of functions,
structures, and constants that can declare
and use in projects
COM
 Component Object Model
 Microsoft implemented a technology known as the COM
for Windows.
 COM essentially takes the object-oriented programming
paradigm to the next level, by standardizing the class
interface, and allowing classes to be written in different
languages (C++, VB, etc.) and interfaced together
seamlessly.
 COM programs (or "COM clients") can be written in
most languages that allow object-orientation.
Windows Data types
 Hungarian Notation
 LPVOID
 LONG, INT, SHORT, CHAR
 DWORD, WORD, BYTE
 STR, LPSTR
 TCHR
 HANDLE
 HINSTANCE
 HMENU
 WPARAM, LPARAM
Hungarian Notation
 The Win32 API uses the so-called "Hungarian
Notation" for naming variables.
 Hungarian Notation requires that a variable be
prefixed with an abbreviation of its data type, so
that when you are reading the code, you know
exactly what type of variable it is.
 The reason this practice is done in the Win32
API is because there are many different data
types, making it difficult to keep them all straight.
LPVOID
 LPVOID data types are defined as being a
"pointer to a void object".
 ANSI-C standard allows for generic pointers to
be defined as "void*" types.
 This means that LPVOID pointers can be used
to point to different types of objects, without
creating a compiler error.
 However, the burden is on the programmer to
keep track of what type of object is being pointed
to.
LONG, INT, SHORT, CHAR
 These types are not defined to a specific length.
It is left to the host machine to determine exactly
how many bits each of these types has.
 LONG notation
 LONG variables are typically prefixed with an "l" (lower-
case L).
 UINT notation
 UINT variables are typically prefixed with an "i" or a "ui"
to indicate that it is an integer, and that it is unsigned.
 CHAR, UCHAR notation
 These variables are usually prefixed with a "c" or a "uc"
respectively.
DWORD, WORD, BYTE

 These data types are defined to be a specific


length, regardless of the target platform
 DWORDs (Double WORDs), the most commonly
occurring of these data types, are defined
always to be unsigned 32-bit quantities
 WORDs (Single WORDs) are defined strictly as
unsigned 16-bit values, regardless of what
machine you are programming on.
 BYTEs are defined strictly as being unsigned 8-
bit values
STR, LPSTR

 STR data types are string data types, with storage


already allocated.
 STR data types are used when the string is supposed to
be treated as an immediate array, and not as a simple
character pointer.
 The variable name prefix for a STR data type is "sz"
because it's a zero-terminated string (ends with a null
character).
 LPSTR can be used exactly like other string objects,
except that LPSTR is explicitly defined as being ASCII,
not unicode, and this definition will hold on all platforms.
LPSTR variables will usually be prefixed with the letters
"lpsz" to denote a "Long Pointer to a String that is Zero-
terminated".
TCHR

 TCHAR can hold either standard 1-byte


ASCII characters, or wide 2-byte Unicode
characters. Because this data type is
defined by a macro and is not set in stone,
only character data should be used with
this type.
HANDLE
 HANDLE data types are some of the most important
data objects in Win32 programming.
 Inside the kernel, Windows maintains a table of all the
different objects that the kernel is responsible for.
Windows, buttons, icons, mouse pointers, menus, and
so on, all get an entry in the table, and each entry is
assigned a unique identifier known as a HANDLE.
 If you want to pick a particular entry out of that table,
you need to give Windows the HANDLE value, and
Windows will return the corresponding table entry.
 HANDLEs are defined as being unsigned 32-bit
quantities in <windows.h>, but HANDLEs should never
be used like integers.
HINSTANCE
 HINSTANCE variables are handles to a program instance.
 Each program gets a single instance variable, and this is
important so that the kernel can communicate with the program.
 If you want to create a new window, for instance, you need to
pass your program's HINSTANCE variable to the kernel, so that
the kernel knows where the new window belongs to.
 If you want to communicate with another program, it is
frequently very useful to have a copy of that program's instance
handle.
 HINSTANCE variables are usually prefixed with an "h", and
furthermore, since there is frequently only one HINSTANCE
variable in a program, it is canonical to declare that variable as
such: HINSTANCE hInstance;
HMENU

If your program has a drop-down menu


available (as most visual Windows
programs do), that menu will have an
HMENU handle associated with it.
 To display the menu, or to alter its
contents, you need to have access to this
HMENU handle.
 HMENU handles are frequently prefixed
with simply an "h".
WPARAM, LPARAM
 In the earlier days of Microsoft Windows, parameters
were passed to a window in one of two formats: WORD-
length (16-bit) parameters, and LONG-length (32-bit)
parameters. These parameter types were defined as
being WPARAM (16-bit) and LPARAM (32-bit). However,
in modern 32-bit systems, WPARAM and LPARAM are
both 32 bits long. The names however have not
changed, for legacy reasons.
 WPARAM and LPARAM variables are generic function
parameters, and are frequently type-cast to other data
types including pointers and DWORDs.
Resource Script

 The resource compiler compiles a special


type of file known as a Resource Script.
Resource scripts contain GUI data, and,
when compiled, can be linked into a
program. The program then can access
the data contained in the resource script.
Types of resources

 Here is a list of common resources:


 Drop-down Menus
 Popup Menus
 Text Strings
 Keyboard Accelerators (keypress combinations, such as
[Ctrl]+[C] to copy text)
 Icons
 Bitmap Images
 Dialog Boxes
 Version information
 Mouse Cursors
Making a Resource Script

 The syntax for writing resource scripts is similar


to C. For instance, the resource script compiler
uses the standard C preprocessor. This is
important because you must include the header
file <afxres.h> to make a resource script. Also,
most resource scripts contain macro values, so
programmers will frequently store the related
macro definitions in a header file "resource.h".
This way, the same macros can be included and
used in the main program files.
Using a Resource

 Once a resource is stored in your executable there are


various methods to access it. These methods differ
depending on what type of resource you are trying to
access. For instance if you want to access a string
resource, you would need to use the LoadString
function; correspondingly the LoadIcon function is
needed to access an icon.
 To access a resource you must have the instance
handle of the executable file that contains the resource.
This means, that if you obtain an instance handle to
another executable (or DLL) file, you can access the
resources remotely! Occasionally, programmers will
create DLL files that contain nothing but resources for
use in other programs.
MAKEINTRESOURCE

 The MAKEINTRESOURCE keyword that we will occasionally see


when dealing with resources is an important keyword, and a
program will crash (or not even compile) if it is not used correctly so
taking a minute to understand it is well worth the effort.
 Resources are all stored with a name which can be a string or a
numerical identifier. If it is numerical, the number must be no larger
than an unsigned 16-bit integer (65535, max). Resources are all
called by name, that is the system is expecting an unicode string
with the name of the resource. However if we use a numerical
identifier we need to inform the system that we are doing so, so that
it doesn't get confused and try to treat your integer as a string. For
that we pass the MAKEINTRESOURCE macro to make. The macro
takes a single argument - the numerical identifier - and it returns a
string pointer suitable for use in the system. We will demonstrate
this later.
Graphics Device Interface

 From Wikipedia, the free encyclopedia


 Jump to: navigation, search
 The Graphics Device Interface (GDI) is a
Microsoft Windows application programming interface
and core operating system component responsible for
representing graphical objects and transmitting them to
output devices such as monitors and printers.
 GDI is responsible for tasks such as drawing lines and
curves, rendering fonts and handling palettes. It is not
directly responsible for drawing windows, menus, etc.;
that task is reserved for the user subsystem, which
resides in user32.dll and is built atop GDI
Windows Platform SDK
 Microsoft Windows SDK, Platform SDK,
are software devlopment kits from
Microsoft that contain header files,
libraries, samples, documentation and
tools required to develop
 Obtaining the SDK
 SDK support for older operating system
 Tools, headers and libraries
Obtaining the SDK
 Windows SDKs are available free on the Microsoft
Download Center, in ISO and Web-download formats.
Users can install the entire SDK or choose to install only
some SDK components, such as code samples
demonstrating only native development or only the tools
for managed development. Some Windows SDK
components are also included in Microsoft Visual Studio.
The latest Windows SDK is the Microsoft Windows
SDK for Windows 7 and .NET Framework 4, released
May 21, 2010[3]. This SDK release supports Windows 7,
Windows Server 2008 R2, Windows Vista,
Windows Server 2008, Windows XP SP3, and Windows
Server 2003 R2 and is compatible with Visual Studio
2010, Visual Studio 2008, and Visual Studio 2005 SP1,
including Visual Studio
SDK support for older operating
systems
 A developer might want to use an older
SDK for a particular reason. For example,
the Windows Server 2003 Platform SDK
released in February 2003 was the last
SDK to provide full support of Visual
Studio 6.0. Some older PSDK versions,
including the February 2003 SDK can still
be downloaded from the Microsoft
Download center [8]; others can be
ordered on CD/DVD.
Documentation
 The Windows SDK documentation
includes the following:
 Manuals documenting managed code
development
 Manuals documenting Win32 development
 "New in Windows Vista" topics;
 All SDK documentation is part of the
online and disc-based MSDN Library
Tools, headers and libraries
 The Windows SDK contains the following:
 For Win32 development:
 1,915 Headers
 348 Libraries
 100 Tools
 For .NET (managed code) development:
 14 Reference Assemblies supporting .NET, Tablet PC,
windows PowerShell, MMC, etc.
 33 Intellisense Files
 70 .NET 2.0 Tools + 10 .NET 3.0 Tools + 35 .NET 4.0 Tools
 For Visual Studio 2005/2008/2010 integration :
 Utilities to enable Visual Studio 2005/2008 to easily use
Windows SDK headers and libraries
 Visual Studio 2005/2008 Wizards for creating Windows Media
Player applications
THANK YOU

You might also like