SlideShare a Scribd company logo
1 of 39
Computer System
and Multimedia (Week 1):
Windows Architecture and Intro to
Programming using Visual Studio
Textbook: Programming Windows / Charles Petzold. -- 5th ed.
Chapter 1. Getting Started
1
Pre-requisite
• Familiar With Windows
• Familiarity with the C language, particularly
with C structures and pointers.
• A computer system with Windows XP/Vista/7
installed with Visual Studio 2010.
• Open-minded and ready to enjoy writing
programs on one sophisticated operating
system.
2
Aspects of Windows
• Preemptive multitasking and multithreading
graphical operating systems.
• Programs themselves can split into multiple
threads of execution that seem to run
concurrently
3
User Interface
• Interaction between humans and machines occurs.
• Input: allowing the users to manipulate a system
• Output: allowing the system to indicate the effects of the
users' manipulation
• Type of User Interface
– Text
• command need to be typed-in from a keyboard) and user must
have knowledge on the valid command entries and their functions.
– Graphics (command selected by a mouse operation or
typed-in
• the user directly interacts with the objects on the display which
give the information of what the selection will be.
4
Advantage of GUI
• Users no longer expect to spend long periods of time learning how
to use the computer or mastering a new program.
• Windows helps because all applications have the same fundamental
look and feel.
• The program occupies a window—usually a rectangular area on the
screen.
• Each window is identified by a caption bar. Most program functions
are initiated through the program's menus.
• A user can view the display of information too large to fit on a
single screen by using scroll bars.
• Some menu items invoke dialog boxes, into which the user enters
additional information.
• One dialog box in particular, that used to open a file, can be found
in almost every large Windows program.
• This dialog box looks the same (or nearly the same) in all of these
Windows programs, and it is almost always invoked from the same
menu option.
5
Programmer's Perspective
• The consistent user interface results from
using the routines built into Windows for
constructing menus and dialog boxes.
• All menus have the same keyboard and mouse
interface because Windows—rather than the
application program—handles this job
6
Dynamic-link Libraries
• Programs running in Windows can share routines that
are located in other files called "dynamic-link libraries."
• Windows includes a mechanism to link the program
with the routines in the dynamic-link libraries at run
time.
• Windows itself is basically a set of dynamic-link
libraries.
• These are files with the extension .DLL or sometimes
.EXE, and they are mostly located in the
WINDOWSSYSTEM subdirectory or
WINDOWSSYSTEM32
7
Graphics Device Interface
• Programs written for Windows do not directly access the
hardware of graphics display devices such as the screen and
printer.
• Instead, Windows includes a graphics programming
language (called the Graphics Device Interface, or GDI) that
allows the easy display of graphics and formatted text.
• Windows virtualizes display hardware.
• A program written for Windows will run with any video
board or any printer for which a Windows device driver is
available.
• The program does not need to determine what type of
device is attached to the system.
8
Dynamic Linking
• Windows provides a wealth of function calls that an application, mostly to
implement its user interface and display text and graphics on the video display.
– Kernel (the 32-bit KERNEL32.DLL) handles all the stuff that an operating system kernel
traditionally handles—memory management, file I/O, and tasking.
– User (USER32.DLL) refers to the user interface, and implements all the windowing logic.
– GDI (GDI32.DLL) is the Graphics Device Interface, which allows a program to display text and
graphics on the screen and printer.
• When you run a Windows program, it interfaces to Windows through a process
called "dynamic linking."
– A Windows .EXE file contains references to the various dynamic-link libraries it uses and the
functions therein.
– When a Windows program is loaded into memory, the calls in the program are resolved to
point to the entries of the DLL functions, which are also loaded into memory if not already
there.
• When you link a Windows program (handled by Visual Studio programming
environment) to produce an executable file, special "import libraries" that contain
the dynamic-link library names and reference information for all the Windows
function calls in a table that Windows uses to resolve calls to Windows functions
when loading the program.
• When you run a Windows program, it interfaces to Windows through a process
called "dynamic linking" the calls in the program are resolved to point to the
entries of the DLL functions, which are also loaded into memory if not already
there. 9
Function Calls
• Windows supports several thousand function
calls that applications can use. Each function has
a descriptive name, such as CreateWindow.
• All the Windows functions that an application
may use are declared in header files (windows.h).
• Windows function calls is generally the same as C
library functions.
– Primary difference
• the machine code for C library functions is linked into your
program code
• the code for Windows functions is located outside of your
program in the DLLs.
10
APIs
• To a programmer, an operating system is defined by its API.
• An API encompasses all the function calls that an
application program can make of an operating system, as
well as definitions of associated data types and structures.
• In Windows, the API also implies a particular program
architecture
• The API for the 16-bit versions of Windows (Windows 1.0
through Windows 3.1) is now known as Win16. The API for
the 32-bit versions of Windows (Windows 95, Windows 98,
and all versions of Windows NT) is now known as Win32.
• We will deal with Win32 API in this course.
11
About Compiler
• A compiler is a program that reads code and produces a stand-alone executable
code that the CPU can understand directly.
• Once your code has been turned into an executable, you do not need the compiler
to run the program.
• Although it may intuitively seem like high-level languages would be significantly
less efficient than assembly languages, modern compiTo write a prog lers do an
excellent job of converting high-level languages into fast executables.
• Sometimes, they even do a better job than human coders can do in assembly
language!
• Here is a simplified representation of the compiling process:
2/20/2024 12
About Intepreter
• An interpreter is a program that reads code and essentially compiles and executes
(interprets) your program as it is run.
• One advantage of interpreters is that they are much easier to write than compilers,
because they can be written in a high-level language themselves.
• However, they tend to be less efficient when running programs because the
compiling needs to be done every time the program is run.
• Furthermore, the interpreter is needed every time the program is run.
• Here is a simplified representation of the interpretation process:
2/20/2024 13
Why High Level language
• Any language can be compiled or interpreted, however, traditionally
languages like C, C++, and Pascal are compiled, whereas “scripting”
languages like Perl and Javascript are interpreted. Some languages, like
Java, use a mix of the two.
• High level languages have several desirable properties. First, high level
languages are much easier to read and write.
• Here is the same instruction as above in C/C++: a = 97;
• Second, they require less instructions to perform the same task as lower
level languages. In C++ you can do something like a = b * 2 + 5; in one line.
In assembly language, this would take 5 or 6 different instructions.
• Third, you don’t have to concern yourself with details such as loading
variables into CPU registers. The compiler or interpreter takes care of all
those details for you.
• And fourth, they are portable to different architectures, with one major
exception, which we will discuss in next slide.
2/20/2024 14
Portability
• The exception to portability is that many platforms, such as Microsoft Windows,
contain platform-specific functions that you can use in your code.
• These can make it much easier to write a program for a specific platform, but at
the expense of portability. In these tutorials, we will explicitly point out whenever
we show you anything that is platform specific.
2/20/2024 15
Building a Program!
2/20/2024 16
Compiling
• In order to compile a program, we need a compiler. The job of the compiler is
twofold:
1) To check your program and make sure it follows the syntactical rules of the
C++ language:
2) To take your source code as input and produce a machine language object
file as output. Object files are typically named name.o or name.obj, where
name is the same name as the .cpp file it was produced from. If your
program had 5 .cpp files, the compiler would generate 5 object files.
2/20/2024 17
Linking
• Linking is the process of taking all the object files for a program and combining them into a single
executable.
• In addition to the object files for a program, the linker includes files from the
runtime support library.
• The C++ language itself is fairly small and simple.
• However, it comes with a large library of optional components that may be
utilized by your program, and these components live in the runtime support
library.
• For example, if you wanted to output something to the screen, your program
would include a special command to tell the compiler that you wanted to use
the I/O (input/output) routines from the runtime support library.
2/20/2024 18
One Of The Solution Available
To Build A Program
The Visual Studio Integrated Development Environment
(IDE) offers a set of tools that help you write and
modify code, and also detect and correct errors.
In these topics, you create a new standard C++ program
and test its functionality by using features available in
Visual Studio for the C++ developer.
2/20/2024 19
Language Options
• Using C and the native APIs is not the only way to write
programs for Windows.
• However, this approach offers you the best
performance, the most power, and the greatest
versatility in exploiting the features of Windows.
• Executables are relatively small and don't require
external libraries to run (except for the Windows DLLs
themselves, of course).
• Most importantly, becoming familiar with the API
provides you with a deeper understanding of Windows
internals, regardless of how you eventually write
applications for Windows.
20
Windows Programming
• Writing C or C++ program using native
Windows APIs a one of techniques of
Windows programming
21
Programming Tutorial
• Get a copy of Visual Studio 2010
• Refer to the following site on Installing Visual
Studio 2010
– http://msdn.microsoft.com/en-
us/library/e2h7fzkw.aspx#installing
22
Setting up Visual Studio for a console project(1)
• Start Visual Studio.net.
Select 'File', then 'New Project‘
• You will see the following screen.
23
Choose 'Win32 Console Application' and choose a name for the project. Then
select OK.
Setting up Visual Studio for a console project(2)
• You will see the following screen. Select 'next'
24
Setting up Visual Studio for a console project(3)
• You will see the following screen.
25
Select 'Empty project' and click 'Finish'
Creating the Source File (1)
• After the Visual Studio IDE opens, in the Solution Explorer window, Right
click on 'Source files' and select 'Add -> New Item'
26
Creating the Source File (2)
• Choose 'C++ File' and enter 'main' into the name field and click Add button.
27
Writing the program
• Type in the following program in the “main.cpp” edit tab area.
28
Running the program without debug
• Press Ctrl-F5 and you will see the following display
29
• “hello, world” is the output of the program
• “Press any key to continue . . .” is the interaction required by the Visual Studio
IDE which will wait for a response from you before closing the window so that
you can see the output of the program on the display.
If The is Error During Compilation
1. If there is error during compiling, an error message dialog box will
appear. Select <No>
2. The Output window displays information about the compilation
progress, for example, the location of the build log and a message
that states the build status.
3. Double click the line which has the words “error cXXXX”. The line
with where the compiler fond the error will be pointed in the .CPP
window. It is not necessary that the real error is there. You need
to have knowledge on C++ programming which you will learn in
this class and develop experiences to solve this. So get the
knowledge and experience after this.
4. Whatever you must remove all errors before an executable file
will be created.
30
Finding the Executable file
By Default:
• For Vista/Window 7 system the file is located at the following folder
…DocumentsVisual Studio 2008Projects<Projectname>Debug
• For XP system the file is located at the following folder
…My DocumentsVisual Studio
2008Projects<Projectname>Debug
• You can execute the program by clicking the application icon from the
relevant directory
• You can also execute the program from the Command Prompt Window
• To open a command prompt
– In Windows XP select Start|Run and enter “cmd” in the entry field.
– In Windows Vista /Window 7 select Start and enter “cmd” in the entry field.
– Change to the default directory where the executable file is located
– The you can run the program by entering the file name on the command
prompt of the Command Prompt Window
– This method is “hectic” since to change directory you hate to a long string of
characters and prones to re-entry of strings.
• The next slide shows how to open command prompt at the folder which
you find using windows explorer. 31
Right Click to Open Command Prompt
in Selected Folder in Windows XP:
A shortcut in the right click context menu of Windows Explorer to open a
command prompt in the current directory. When you need to run scripts in a
very long directory name, this is very handy.
So here's how you set it up:
• Open up windows explorer
• Tools -> Folder Options.
• File Types Tab
• Select the Folder file type
• Click Advanced
• Click New
• For the Action type what ever you want the context menu to display, I
used Command Prompt.
• For the Application used to perform the action use
c:windowssystem32cmd.exe (note on win2k you will want to specify
the winnt directory instead of the windows directory)
32
To open a Command Prompt on a
folder in Windows Vista
This very useful shortcut to the DEFAULT installation inside
Windows Vista Explorer's context menu!
• Open a Windows Explorer windows, browse to the required
folder.
• Right-click that folder in the right pane of the Windows
Explorer window. Note that you do NOT have the "Open
Command Prompt Here" option.
• Now, hold the SHIFT key while you right-click the folder.
Behold!
• Note: As in most cases, Microsoft has only gone part of the
way with this cool feature. It's silly but this context menu
add-on in only available when you right-click on the folder
in the right pane, and not in the left pane or in a My
Computer window...
33
To Customize Command Prompt in
Windows XP/2000/2003/Vista
To configure the command prompt in Windows XP, Windows 2000 and Windows Server 2003:
• Open Command Prompt.
• Click the upper-left corner of the Command Prompt window, and then click Properties.
• Click the Options tab.
• In Command History, type or select 999 in Buffer Size, and then type or select 5 in Number of Buffers.
• In Edit Options, select the Quick Edit Mode and Insert Mode check boxes.
• Click the Layout tab.
• In Screen Buffer Size, type or select 9999 in Height.
• Do any of the following optional tasks:
– In Screen Buffer Size, increase Width.
– In Window Size, increase Height.
– In Window Size, increase Width.
– Clear the Let system position window check box, and then, in Window Position, change the values in Left and Top.
• In the Apply Properties dialog box, click Save properties for future windows with same title.
• Note:
• To open Command Prompt Properties from the keyboard, press ALT+SPACEBAR+P.
• By selecting the Quick Edit Mode check box, you enable copy and paste from the Command Prompt
window. To copy, select the text in the Command Prompt window with your left mouse button, and then
right-click. To paste, either at the command prompt or in a text file, right-click.
• By increasing the screen buffer size to 999, you enable scrolling through the Command Prompt window.
• By increasing the number of buffers to five, you increase the number of lines in the Command Prompt
window to 5000. 34
Conventional Way Running The
Program
By double-clicking the program executable icon.
• In windows Explorer, open the window where the
ex1-1.exe is located.
• Run the Program and the exit.
From the Command Prompt.
• Open a command prompt window from the
where the ex1-1.exe is located.
• Execute the program by entering “ex1-1” at the
DOS prompt.
2/20/2024 35
Debugging
1. Single-stepping
a. Press F10 to Step Over a process (eg. a function or a Control structure like a
while loop).
b. Press F11 to Step Into a process (eg. a function or a Control structure). This
method allow you to debug a function or a control structure.
c. If you Press F10 of F11 before a Project is being build, IDE will compile and
create the executable file if there is no error.
d. IDE will stop the flow of program at the entry into the program.
e. Continue debugging by ether pressing F10 or F11 depending on situation.
f. You may not need to debug Step Into a process if you know that the process
in bug-free.
2. Using breakpoints
a. Setting Breakpoints will let you stop your program at any location in the
program
b. You can also just select the Start Debugging button or press F5 and if there is
no error, the IDE will execute the program and stop if the flow of the
program finds a breakpoint or an exit process.
c. If you press F5 again, IDE will continue the flow of the program until a
breakpoint or an exit process.
d. If you need to single step, use the appropriate single-step key.
36
Watching Variables
• There are a number of important windows to monitor objects as the code
executes, these are located in the bottom left by default but if not visible they can
be opened from Debug>Windows.
• The Watch window allow monitoring of any object which can simply be
highlighted in the code window and dragged to the Watch window.
– The Watch window monitor objects regardless of whether they are in scope or now.
• The Locals window cannot have objects dragged into it and shows all objects that
are currently in scope.
– A powerful feature of the locals window is that it allow the objects to by modified. In this
example, the value of the vsTutor variable can be modified by clicking and changing the
number in the Value column.
• The Autos window shows the objects used in the execution of the current
statement.
• The Immediate window allows for statements to be written and executed as the
program’s execution is paused.
• The Breakpoints window allows the breakpoints for the project to be managed by
enabling, disabling or deleting them.
• At all times the yellow arrow shows the line of code that will be executed next.
This arrow can be dragged down to execute subsequent lines of code without
executing the code that it is dragged over.
• When in debug mode the Debug toolbar will either appear in the main tool bar of
Visual Studio or a floating toolbar as show below.
37
Selecting Debug|Window
38
Review
• Write the program REVIEW.CPP and with the
help of debugging technique available in
Visual Studio, answer the Questions in the
comment field, identified by the prefix Q.
• For Lecturer run this Week 1 Visual Studio
Project
39

More Related Content

Similar to Computer and multimedia Week 1 Windows Architecture.pptx

Btech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageBtech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageRai University
 
Mca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageMca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageRai University
 
Bsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageBsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageRai University
 
Diploma ii cfpc u-1 introduction to c language
Diploma ii  cfpc u-1 introduction to c languageDiploma ii  cfpc u-1 introduction to c language
Diploma ii cfpc u-1 introduction to c languageRai University
 
Week 08_Basics of Compiler Construction.pdf
Week 08_Basics of Compiler Construction.pdfWeek 08_Basics of Compiler Construction.pdf
Week 08_Basics of Compiler Construction.pdfAnonymousQ3EMYoWNS
 
Lecture-1&2.pdf Visual Programming C# .net framework
Lecture-1&2.pdf Visual Programming C# .net frameworkLecture-1&2.pdf Visual Programming C# .net framework
Lecture-1&2.pdf Visual Programming C# .net frameworkAbdullahNadeem78
 
Introduction to Computer Programming (general background)
Introduction to Computer Programming (general background)Introduction to Computer Programming (general background)
Introduction to Computer Programming (general background)Chao-Lung Yang
 
Introduct To C Language Programming
Introduct To C Language ProgrammingIntroduct To C Language Programming
Introduct To C Language Programmingyarkhosh
 
Introduction.pptx the event driven course
Introduction.pptx the event driven courseIntroduction.pptx the event driven course
Introduction.pptx the event driven courseworldchannel
 
Dotnet Basics Presentation
Dotnet Basics PresentationDotnet Basics Presentation
Dotnet Basics PresentationSudhakar Sharma
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterHossam Hassan
 

Similar to Computer and multimedia Week 1 Windows Architecture.pptx (20)

Btech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageBtech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c language
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Mca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageMca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c language
 
Bsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageBsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c language
 
Diploma ii cfpc u-1 introduction to c language
Diploma ii  cfpc u-1 introduction to c languageDiploma ii  cfpc u-1 introduction to c language
Diploma ii cfpc u-1 introduction to c language
 
The Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.NetThe Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.Net
 
C programming part1
C programming part1C programming part1
C programming part1
 
Week 08_Basics of Compiler Construction.pdf
Week 08_Basics of Compiler Construction.pdfWeek 08_Basics of Compiler Construction.pdf
Week 08_Basics of Compiler Construction.pdf
 
W1.pptx
W1.pptxW1.pptx
W1.pptx
 
Lecture-1&2.pdf Visual Programming C# .net framework
Lecture-1&2.pdf Visual Programming C# .net frameworkLecture-1&2.pdf Visual Programming C# .net framework
Lecture-1&2.pdf Visual Programming C# .net framework
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Introduction to Computer Programming (general background)
Introduction to Computer Programming (general background)Introduction to Computer Programming (general background)
Introduction to Computer Programming (general background)
 
E.s unit 6
E.s unit 6E.s unit 6
E.s unit 6
 
Introduct To C Language Programming
Introduct To C Language ProgrammingIntroduct To C Language Programming
Introduct To C Language Programming
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Introduction.pptx the event driven course
Introduction.pptx the event driven courseIntroduction.pptx the event driven course
Introduction.pptx the event driven course
 
C
CC
C
 
Dotnet Basics Presentation
Dotnet Basics PresentationDotnet Basics Presentation
Dotnet Basics Presentation
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals master
 

Recently uploaded

CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 

Recently uploaded (20)

CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 

Computer and multimedia Week 1 Windows Architecture.pptx

  • 1. Computer System and Multimedia (Week 1): Windows Architecture and Intro to Programming using Visual Studio Textbook: Programming Windows / Charles Petzold. -- 5th ed. Chapter 1. Getting Started 1
  • 2. Pre-requisite • Familiar With Windows • Familiarity with the C language, particularly with C structures and pointers. • A computer system with Windows XP/Vista/7 installed with Visual Studio 2010. • Open-minded and ready to enjoy writing programs on one sophisticated operating system. 2
  • 3. Aspects of Windows • Preemptive multitasking and multithreading graphical operating systems. • Programs themselves can split into multiple threads of execution that seem to run concurrently 3
  • 4. User Interface • Interaction between humans and machines occurs. • Input: allowing the users to manipulate a system • Output: allowing the system to indicate the effects of the users' manipulation • Type of User Interface – Text • command need to be typed-in from a keyboard) and user must have knowledge on the valid command entries and their functions. – Graphics (command selected by a mouse operation or typed-in • the user directly interacts with the objects on the display which give the information of what the selection will be. 4
  • 5. Advantage of GUI • Users no longer expect to spend long periods of time learning how to use the computer or mastering a new program. • Windows helps because all applications have the same fundamental look and feel. • The program occupies a window—usually a rectangular area on the screen. • Each window is identified by a caption bar. Most program functions are initiated through the program's menus. • A user can view the display of information too large to fit on a single screen by using scroll bars. • Some menu items invoke dialog boxes, into which the user enters additional information. • One dialog box in particular, that used to open a file, can be found in almost every large Windows program. • This dialog box looks the same (or nearly the same) in all of these Windows programs, and it is almost always invoked from the same menu option. 5
  • 6. Programmer's Perspective • The consistent user interface results from using the routines built into Windows for constructing menus and dialog boxes. • All menus have the same keyboard and mouse interface because Windows—rather than the application program—handles this job 6
  • 7. Dynamic-link Libraries • Programs running in Windows can share routines that are located in other files called "dynamic-link libraries." • Windows includes a mechanism to link the program with the routines in the dynamic-link libraries at run time. • Windows itself is basically a set of dynamic-link libraries. • These are files with the extension .DLL or sometimes .EXE, and they are mostly located in the WINDOWSSYSTEM subdirectory or WINDOWSSYSTEM32 7
  • 8. Graphics Device Interface • Programs written for Windows do not directly access the hardware of graphics display devices such as the screen and printer. • Instead, Windows includes a graphics programming language (called the Graphics Device Interface, or GDI) that allows the easy display of graphics and formatted text. • Windows virtualizes display hardware. • A program written for Windows will run with any video board or any printer for which a Windows device driver is available. • The program does not need to determine what type of device is attached to the system. 8
  • 9. Dynamic Linking • Windows provides a wealth of function calls that an application, mostly to implement its user interface and display text and graphics on the video display. – Kernel (the 32-bit KERNEL32.DLL) handles all the stuff that an operating system kernel traditionally handles—memory management, file I/O, and tasking. – User (USER32.DLL) refers to the user interface, and implements all the windowing logic. – GDI (GDI32.DLL) is the Graphics Device Interface, which allows a program to display text and graphics on the screen and printer. • When you run a Windows program, it interfaces to Windows through a process called "dynamic linking." – A Windows .EXE file contains references to the various dynamic-link libraries it uses and the functions therein. – When a Windows program is loaded into memory, the calls in the program are resolved to point to the entries of the DLL functions, which are also loaded into memory if not already there. • When you link a Windows program (handled by Visual Studio programming environment) to produce an executable file, special "import libraries" that contain the dynamic-link library names and reference information for all the Windows function calls in a table that Windows uses to resolve calls to Windows functions when loading the program. • When you run a Windows program, it interfaces to Windows through a process called "dynamic linking" the calls in the program are resolved to point to the entries of the DLL functions, which are also loaded into memory if not already there. 9
  • 10. Function Calls • Windows supports several thousand function calls that applications can use. Each function has a descriptive name, such as CreateWindow. • All the Windows functions that an application may use are declared in header files (windows.h). • Windows function calls is generally the same as C library functions. – Primary difference • the machine code for C library functions is linked into your program code • the code for Windows functions is located outside of your program in the DLLs. 10
  • 11. APIs • To a programmer, an operating system is defined by its API. • An API encompasses all the function calls that an application program can make of an operating system, as well as definitions of associated data types and structures. • In Windows, the API also implies a particular program architecture • The API for the 16-bit versions of Windows (Windows 1.0 through Windows 3.1) is now known as Win16. The API for the 32-bit versions of Windows (Windows 95, Windows 98, and all versions of Windows NT) is now known as Win32. • We will deal with Win32 API in this course. 11
  • 12. About Compiler • A compiler is a program that reads code and produces a stand-alone executable code that the CPU can understand directly. • Once your code has been turned into an executable, you do not need the compiler to run the program. • Although it may intuitively seem like high-level languages would be significantly less efficient than assembly languages, modern compiTo write a prog lers do an excellent job of converting high-level languages into fast executables. • Sometimes, they even do a better job than human coders can do in assembly language! • Here is a simplified representation of the compiling process: 2/20/2024 12
  • 13. About Intepreter • An interpreter is a program that reads code and essentially compiles and executes (interprets) your program as it is run. • One advantage of interpreters is that they are much easier to write than compilers, because they can be written in a high-level language themselves. • However, they tend to be less efficient when running programs because the compiling needs to be done every time the program is run. • Furthermore, the interpreter is needed every time the program is run. • Here is a simplified representation of the interpretation process: 2/20/2024 13
  • 14. Why High Level language • Any language can be compiled or interpreted, however, traditionally languages like C, C++, and Pascal are compiled, whereas “scripting” languages like Perl and Javascript are interpreted. Some languages, like Java, use a mix of the two. • High level languages have several desirable properties. First, high level languages are much easier to read and write. • Here is the same instruction as above in C/C++: a = 97; • Second, they require less instructions to perform the same task as lower level languages. In C++ you can do something like a = b * 2 + 5; in one line. In assembly language, this would take 5 or 6 different instructions. • Third, you don’t have to concern yourself with details such as loading variables into CPU registers. The compiler or interpreter takes care of all those details for you. • And fourth, they are portable to different architectures, with one major exception, which we will discuss in next slide. 2/20/2024 14
  • 15. Portability • The exception to portability is that many platforms, such as Microsoft Windows, contain platform-specific functions that you can use in your code. • These can make it much easier to write a program for a specific platform, but at the expense of portability. In these tutorials, we will explicitly point out whenever we show you anything that is platform specific. 2/20/2024 15
  • 17. Compiling • In order to compile a program, we need a compiler. The job of the compiler is twofold: 1) To check your program and make sure it follows the syntactical rules of the C++ language: 2) To take your source code as input and produce a machine language object file as output. Object files are typically named name.o or name.obj, where name is the same name as the .cpp file it was produced from. If your program had 5 .cpp files, the compiler would generate 5 object files. 2/20/2024 17
  • 18. Linking • Linking is the process of taking all the object files for a program and combining them into a single executable. • In addition to the object files for a program, the linker includes files from the runtime support library. • The C++ language itself is fairly small and simple. • However, it comes with a large library of optional components that may be utilized by your program, and these components live in the runtime support library. • For example, if you wanted to output something to the screen, your program would include a special command to tell the compiler that you wanted to use the I/O (input/output) routines from the runtime support library. 2/20/2024 18
  • 19. One Of The Solution Available To Build A Program The Visual Studio Integrated Development Environment (IDE) offers a set of tools that help you write and modify code, and also detect and correct errors. In these topics, you create a new standard C++ program and test its functionality by using features available in Visual Studio for the C++ developer. 2/20/2024 19
  • 20. Language Options • Using C and the native APIs is not the only way to write programs for Windows. • However, this approach offers you the best performance, the most power, and the greatest versatility in exploiting the features of Windows. • Executables are relatively small and don't require external libraries to run (except for the Windows DLLs themselves, of course). • Most importantly, becoming familiar with the API provides you with a deeper understanding of Windows internals, regardless of how you eventually write applications for Windows. 20
  • 21. Windows Programming • Writing C or C++ program using native Windows APIs a one of techniques of Windows programming 21
  • 22. Programming Tutorial • Get a copy of Visual Studio 2010 • Refer to the following site on Installing Visual Studio 2010 – http://msdn.microsoft.com/en- us/library/e2h7fzkw.aspx#installing 22
  • 23. Setting up Visual Studio for a console project(1) • Start Visual Studio.net. Select 'File', then 'New Project‘ • You will see the following screen. 23 Choose 'Win32 Console Application' and choose a name for the project. Then select OK.
  • 24. Setting up Visual Studio for a console project(2) • You will see the following screen. Select 'next' 24
  • 25. Setting up Visual Studio for a console project(3) • You will see the following screen. 25 Select 'Empty project' and click 'Finish'
  • 26. Creating the Source File (1) • After the Visual Studio IDE opens, in the Solution Explorer window, Right click on 'Source files' and select 'Add -> New Item' 26
  • 27. Creating the Source File (2) • Choose 'C++ File' and enter 'main' into the name field and click Add button. 27
  • 28. Writing the program • Type in the following program in the “main.cpp” edit tab area. 28
  • 29. Running the program without debug • Press Ctrl-F5 and you will see the following display 29 • “hello, world” is the output of the program • “Press any key to continue . . .” is the interaction required by the Visual Studio IDE which will wait for a response from you before closing the window so that you can see the output of the program on the display.
  • 30. If The is Error During Compilation 1. If there is error during compiling, an error message dialog box will appear. Select <No> 2. The Output window displays information about the compilation progress, for example, the location of the build log and a message that states the build status. 3. Double click the line which has the words “error cXXXX”. The line with where the compiler fond the error will be pointed in the .CPP window. It is not necessary that the real error is there. You need to have knowledge on C++ programming which you will learn in this class and develop experiences to solve this. So get the knowledge and experience after this. 4. Whatever you must remove all errors before an executable file will be created. 30
  • 31. Finding the Executable file By Default: • For Vista/Window 7 system the file is located at the following folder …DocumentsVisual Studio 2008Projects<Projectname>Debug • For XP system the file is located at the following folder …My DocumentsVisual Studio 2008Projects<Projectname>Debug • You can execute the program by clicking the application icon from the relevant directory • You can also execute the program from the Command Prompt Window • To open a command prompt – In Windows XP select Start|Run and enter “cmd” in the entry field. – In Windows Vista /Window 7 select Start and enter “cmd” in the entry field. – Change to the default directory where the executable file is located – The you can run the program by entering the file name on the command prompt of the Command Prompt Window – This method is “hectic” since to change directory you hate to a long string of characters and prones to re-entry of strings. • The next slide shows how to open command prompt at the folder which you find using windows explorer. 31
  • 32. Right Click to Open Command Prompt in Selected Folder in Windows XP: A shortcut in the right click context menu of Windows Explorer to open a command prompt in the current directory. When you need to run scripts in a very long directory name, this is very handy. So here's how you set it up: • Open up windows explorer • Tools -> Folder Options. • File Types Tab • Select the Folder file type • Click Advanced • Click New • For the Action type what ever you want the context menu to display, I used Command Prompt. • For the Application used to perform the action use c:windowssystem32cmd.exe (note on win2k you will want to specify the winnt directory instead of the windows directory) 32
  • 33. To open a Command Prompt on a folder in Windows Vista This very useful shortcut to the DEFAULT installation inside Windows Vista Explorer's context menu! • Open a Windows Explorer windows, browse to the required folder. • Right-click that folder in the right pane of the Windows Explorer window. Note that you do NOT have the "Open Command Prompt Here" option. • Now, hold the SHIFT key while you right-click the folder. Behold! • Note: As in most cases, Microsoft has only gone part of the way with this cool feature. It's silly but this context menu add-on in only available when you right-click on the folder in the right pane, and not in the left pane or in a My Computer window... 33
  • 34. To Customize Command Prompt in Windows XP/2000/2003/Vista To configure the command prompt in Windows XP, Windows 2000 and Windows Server 2003: • Open Command Prompt. • Click the upper-left corner of the Command Prompt window, and then click Properties. • Click the Options tab. • In Command History, type or select 999 in Buffer Size, and then type or select 5 in Number of Buffers. • In Edit Options, select the Quick Edit Mode and Insert Mode check boxes. • Click the Layout tab. • In Screen Buffer Size, type or select 9999 in Height. • Do any of the following optional tasks: – In Screen Buffer Size, increase Width. – In Window Size, increase Height. – In Window Size, increase Width. – Clear the Let system position window check box, and then, in Window Position, change the values in Left and Top. • In the Apply Properties dialog box, click Save properties for future windows with same title. • Note: • To open Command Prompt Properties from the keyboard, press ALT+SPACEBAR+P. • By selecting the Quick Edit Mode check box, you enable copy and paste from the Command Prompt window. To copy, select the text in the Command Prompt window with your left mouse button, and then right-click. To paste, either at the command prompt or in a text file, right-click. • By increasing the screen buffer size to 999, you enable scrolling through the Command Prompt window. • By increasing the number of buffers to five, you increase the number of lines in the Command Prompt window to 5000. 34
  • 35. Conventional Way Running The Program By double-clicking the program executable icon. • In windows Explorer, open the window where the ex1-1.exe is located. • Run the Program and the exit. From the Command Prompt. • Open a command prompt window from the where the ex1-1.exe is located. • Execute the program by entering “ex1-1” at the DOS prompt. 2/20/2024 35
  • 36. Debugging 1. Single-stepping a. Press F10 to Step Over a process (eg. a function or a Control structure like a while loop). b. Press F11 to Step Into a process (eg. a function or a Control structure). This method allow you to debug a function or a control structure. c. If you Press F10 of F11 before a Project is being build, IDE will compile and create the executable file if there is no error. d. IDE will stop the flow of program at the entry into the program. e. Continue debugging by ether pressing F10 or F11 depending on situation. f. You may not need to debug Step Into a process if you know that the process in bug-free. 2. Using breakpoints a. Setting Breakpoints will let you stop your program at any location in the program b. You can also just select the Start Debugging button or press F5 and if there is no error, the IDE will execute the program and stop if the flow of the program finds a breakpoint or an exit process. c. If you press F5 again, IDE will continue the flow of the program until a breakpoint or an exit process. d. If you need to single step, use the appropriate single-step key. 36
  • 37. Watching Variables • There are a number of important windows to monitor objects as the code executes, these are located in the bottom left by default but if not visible they can be opened from Debug>Windows. • The Watch window allow monitoring of any object which can simply be highlighted in the code window and dragged to the Watch window. – The Watch window monitor objects regardless of whether they are in scope or now. • The Locals window cannot have objects dragged into it and shows all objects that are currently in scope. – A powerful feature of the locals window is that it allow the objects to by modified. In this example, the value of the vsTutor variable can be modified by clicking and changing the number in the Value column. • The Autos window shows the objects used in the execution of the current statement. • The Immediate window allows for statements to be written and executed as the program’s execution is paused. • The Breakpoints window allows the breakpoints for the project to be managed by enabling, disabling or deleting them. • At all times the yellow arrow shows the line of code that will be executed next. This arrow can be dragged down to execute subsequent lines of code without executing the code that it is dragged over. • When in debug mode the Debug toolbar will either appear in the main tool bar of Visual Studio or a floating toolbar as show below. 37
  • 39. Review • Write the program REVIEW.CPP and with the help of debugging technique available in Visual Studio, answer the Questions in the comment field, identified by the prefix Q. • For Lecturer run this Week 1 Visual Studio Project 39

Editor's Notes

  1. Pre-emptive multitasking involves the use of an interrupt mechanism which suspends the currently executing process and invokes a scheduler (time-shared scheduling, or time-sharing)to determine which process should execute next. Therefore all processes will get some amount of CPU time at any given time.