윈도우프로그래밍 Windows Programming Introduction. Introduction 2 Windows Programming...
-
Upload
evelyn-holt -
Category
Documents
-
view
251 -
download
0
Transcript of 윈도우프로그래밍 Windows Programming Introduction. Introduction 2 Windows Programming...
윈도우프로그래밍
Windows ProgrammingWindows ProgrammingIntroductionIntroduction
Introduction 2
Windows ProgrammingWindows ProgrammingIntroductionIntroduction
Windows Operating System Windows Application Program .NET Framework C# 소개
Introduction 3
Windows Operating SystemWindows Operating System
Graphical User Interface• 일관성 있는 사용자 인터페이스
Introduction 4
Windows Operating SystemWindows Operating System
Message-Driven Architecture (Event-Driven)• Message : 프로그램의 외부나 내부에서 변화가 발생했음을 알리는 신호
윈도우 시스템메시지큐
이벤트 발생
응용 프로그램메시지 큐 #1
응용 프로그램메시지 큐 #2
응용 프로그램메시지 큐 #3
...
처리
대기
처리
Introduction 5
Windows Operating SystemWindows Operating System
Multitasking• 하나의 윈도즈 시스템에서 여러 개의 응용 프로그램을 수행하는
기법• 응용프로그램 사이의 상호작용 가능
Multithread• 하나의 응용 프로그램에 여러 개의 실행 흐름을 생성
장치에 독립적• 장치 드라이버 (device driver) 에 의해 주변장치들을 제어
Introduction 6
윈도우 운영체제 윈도우 운영체제 & & 윈도우프로그램윈도우프로그램Windows Application Program
Windows Operating System (Win32 API)
GDI32.DLL USER32.DLL KERNEL32.DLL
Device Driver
Introduction 7
.NET Application.NET Application
Introduction 8
.NET Framework.NET Framework
정의• 차세대 응용 프로그램 및 XML Web services 를 만들고 실행하는
것을 지원하는 필수적인 Windows 구성 요소
기능• 일관된 개체 지향 프로그래밍 환경 제공 ( 로컬 , 원격 )
콘솔 응용 프로그램 /Windows GUI 응용 프로그램 (Windows Forms) /ASP.NET 응용 프로그램 /XML Web services/Windows services
=> Framework Class Library (FCL)
• 안전한 코드 실행환경 제공 프로그래밍언어 통합 , 자원관리 , 형안전성 , 보안 , 배포 및 버전
관리 , 상호 운용성
=>Common Language Runtime(CLR)
Introduction 9
차세대 응용프로그램 및 웹서비스 모델차세대 응용프로그램 및 웹서비스 모델
Introduction 10
Framework, Languages, And ToolsFramework, Languages, And Tools
Base Class Library
Common Language Specification
Common Language Runtime
Data and XML
VB C++ C#V
isual S
tud
io.N
ET
WebServices
JScript …
UserInterface
Introduction 11
Common Language Runtime (CLR)Common Language Runtime (CLR)
.NET 기반의 각 언어들로 작성된 어플리케이션을 동작시키고 협력할 수 있는 실행환경 (Virtual Machine)
특징• 코드관리 ( 로드 및 실행 )• 보안 (Security manager) • 형안정성 (Type checker)• 예외처리 (Exception manager) • 디버깅 (Debug Engine) • 자동적인 자원관리 (Garbage Collection) • IL 을 기계어로 번역• 상호 운용성 (COM 객체 )
Introduction 12
CLR ArchitectureCLR Architecture
Class Loader
IL to NativeCompilers
CodeManager
GarbageCollector
Security Engine Debug Engine
Type Checker Exception Manager
Thread Support COM Marshaler
Base Class Library Support
Introduction 13
System
System.Data System.Xml
System.Web
Globalization
Diagnostics
Configuration
Collections
Resources
Reflection
Net
IO
Threading
Text
ServiceProcess
Security
Design
ADO
SQLTypes
SQL
XPath
XSLT
RuntimeInteropServices
Remoting
Serialization
Serialization
Configuration SessionState
Caching Security
ServicesDescription
Discovery
Protocols
UIHtmlControls
WebControls
System.Drawing
Imaging
Drawing2D
Text
Printing
System.WinForms
Design ComponentModel
Class LibraryClass Library
BCL
Introduction 14
LanguagesLanguages
CLS 규정에 따르는 .NET 기반 언어 종류
• C# .NET 을 위하여 설계된 새로운 언어 component-oriented language
• C++ • J#• Visual Basic.NET• JScript.NET…
CLS (Common Language Specification) CLR 에서 동작하는 .NET Application 을 만들기 위한 공통언어 규약
Introduction 15
CTS (Common Type System)CTS (Common Type System)
.NET 의 데이터 타입을 설명하는 공식화된 명세 Data Type 종류
• Class type • Struct type • Interface type • Type member : 이벤트 , 필드 , 메서드 , 속성• Enumeration type• Delegate type• 고유 데이터 타입 :System.Byte, System.Int16, System.Int32, System.Single, System.Double, System.
Object, System.Character, System.String, System.Decimal, System.Boolean
Introduction 16
.NET Codes.NET Codes
Managed code• CLR 이 위에서만 동작하는 코드
• PE 파일형태 .EXE / .DLL Self Description ( Meta Data) + IL
Unmanaged code• CLR 이 없이도 동작하는 코드 • Win32 dll, COM 객체• Managed code 와 상호 호환성을 위한 기능 제공
Introduction 17
MSIL & JITterMSIL & JITter
IL(Intermediate Language)• CLS 규정에 따르는 언어로 작성된 어플리케이션을 Compil
e 하였을 때 생성되는 언어 독립적인 변환 언어• Java Bytecode / 어셈블리어와 유사한 개념• CLR 이 지원되는 곳이면 어디서든 실행 가능한 언어• 빠른 수행속도와 성능 향상을 목적으로 설계
JITter (Just-In Time) 컴파일러를 통하여 IL 을 고유 CPU 명령으로 컴파일 하여 실행
Introduction 18Native CodeNative Code
Execution levelExecution level
Compilation levelCompilation level
SourceSourceCodeCode
C# C++ VB.NET Etc.
Language Language CompilerCompiler
Compiled by Language Compiler
WinCE CPUWinCE CPUJIT CompilerJIT Compiler
X86 CPUX86 CPUJIT CompilerJIT Compiler
64Bit CPU64Bit CPUJIT CompilerJIT Compiler
UNIX/LINUXUNIX/LINUXJIT CompilerJIT Compiler
PE (exe/dll)PE (exe/dll)IL + MetadataIL + Metadata
ManagedManagedCodeCode
Compilation and ExecutionCompilation and Execution
Introduction 19
Metadata & ReflectionMetadata & Reflection
Metadata• 컴파일 시 생성되는 exe (dll) 코드에 포함되는 IL 에 대한 정보를
가지는 데이타 • 소스코드에 정의되어 있거나 참조하는 데이터 형과 멤버들에
대한 정보 Reflection : metadata 에 접근할 수 있는 기능 ILDASM
• Reflection 을 이용하여 metadata 를 분석하여 어플리케이션의 구조를 계층적으로 보여주는 .NET 도구
• 실행파일 (exe, dll) 의 구성요소 (namespace, class, type, code) 에 대한 내용을 제공
Introduction 20
Assembly Assembly
Assembly • application 의 code 와 resource 를 가지고 있는 실행파일 (EXE , D
LL) 의 논리적인 집합• ILDASM 도구를 이용하여 assembly 에 포함된 목록 확인• 배포를 위한 여러 문제점 ( 충돌 , 유지보수 , 하위 버전과의 호환
성 , registry 등 ) 해결
Mainfest(assembly metadata)• assembly 관련 정보 저장 목록• 버젼정보 , 구성요소 목록 , 사용권한등의 정보를 포함
Introduction 21
NamespaceNamespace
NET 에서 사용되는 객체의 이름을 고유하게 하기 위해 나누어진 논리적인 부분
Class library 는 기능별로 구조화된 namesapce 를 가지며 포함된 클래스 , 메소드들은 계층구조를 이룸
Ex> System.Console.WriteLine(“test”); Namespace 를 프로그램에 포함하여 이용 C#: Using , VB.NET : Imports EX> Using System … Console.WriteLine(“test”); … 사용자 정의 namespace 는 회사명 이나 프로젝트명으로 한다 .
Introduction 22
.NET .NET 객체 예 객체 예 (1)(1)
‘VB.NET codeImports Microsoft.VisualBasicNamespace TimeComponentNS Public Class TimeComponent Public Function GetTime(ByVal ShowSeconds As Boolean) As String If (ShowSeconds = True) Then Return Now.ToLongTimeString Else Return Now.ToShortTimeString End If End Function End ClassEnd Namespace
Introduction 23
.NET .NET 객체 예 객체 예 (2)(2)
//C# code
using System ;using TimeComponentNS ;class MainApp {
public static void Main() {
TimeComponent tc = new TimeComponent ( ) ;Console.Write (tc.GetTime (true)) ;
}}
Introduction 24
C# C# 프로그램 구조프로그램 구조
// A skeleton of a C# program using System; namespace MyNamespace1 { class MyClass1 { } struct MyStruct { } interface IMyInterface { } delegate int MyDelegate(); enum MyEnum { } namespace MyNamespace2 { } class MyClass2 { public static void Main(string[] args) { } } }
Introduction 25
Console Application Console Application 예 예
// greetings.cs
using System;namespace ConsoleApplication1{ public class Greetings { static void Main(string[] args) {
string myName; // 문자열 변수 선언 Console.WriteLine("Please enter your name"); // 표준 출력 myName = Console.ReadLine(); // 표준입력 ( 문자열 ) Console.WriteLine("Hello {0}", myName); // 입력문자열 출력 Console.ReadKey(); } }}
Introduction 26
Windows Application Windows Application 예 예
//Program.cs
using System;using System.Collections.Generic;using System.Windows.Forms;
namespace WindowsApplication1{ static class Program { [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } }}
Introduction 27
//Form1.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;
namespace WindowsApplication1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { label1.Text = textBox1.Text + " 님 안녕하세요 "; } }}
Introduction 28
//Form1.Designer.cs, Windows Form 디자이너에서 생성한 코드namespace WindowsApplication1{ partial class Form1 { private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox textBox1;
protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // button1 this.button1.Location = new System.Drawing.Point(107, 191); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 0; this.button1.Text = " 확인 "; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); //… }}
Introduction 29
ReferenceReference
Web Site• MSDN( 마이크로소프트 개발자 네트워크 )
NET Framework 설명서 (msdn.microsoft.com/library/kor/default.asp?url=/library/KOR/cpguide/html/cpovrIntroductionToNETFrameworkSDK.asp)
C# 자습서 (msdn.microsoft.com/library/kor/default.asp?url=/library/KOR/csref/html/vcoriCSharpTutorials.asp)
• www.codeproject.com/csharp• www.codeguru.com/csharp• www.csharp-station.com• www.devpia.com
Book • Tom archer , Inside C# , 정보문화사 , 2001.
( 무료기술서적 다운로드 사이트 : http://www.microsoft.com/korea/msdn/vbrun/staythepath/additionalresources/InsideCSharp/default.aspx)
• David S. Platt, Introducing Microsoft .NET, 정보문화사 , 2001.• Jeffrey Richter, APPLIED Microsoft .NET FRAMEWORK Programming, 정보문화사 , 2002.• Andrew Troelsen, C# and the .NET Platform Second Edition , APRESS, 2003.• Charles Petzold, Programming Microsoft Windows with C#, 정보문화사 , 2002.