Вы находитесь на странице: 1из 463

, , ,

.
..

, ,
.
. .


.
..

Brian Johnson
Craig Skibo
Marc Young

Inside
Microsoft

VISUAL STUDIO

.NET

Microsoft Press

Microsoft'

VIUAL TUDI

.NET 2003

2003

004.43
32.973-26-018

53
Microsoft Corporation
53

Microsoft Visual Studio .NET 2003 /. . - M.: - , 2003. 464 .: .


ISBN 5-7502-0225-9
[ Microsoft Visual Studio
.NET. , , , . ,
, Visual Studio .NET 2003.
15 , .
004.43
32.973-26-018
Microsoft Corporation, , , .
Macintosh Apple Computer Inc. ActiveX, BackOffice.
JScript, Microsoft, Microsoft Press, MSDN, NetShow, Outlook, PowerPoint, Visual Basic, Visua! C++, Visual
IntcrDev. Visual J++, Visual SourceSafe, Visual Studio, Win32, Windows Windows NT Microsoft /
. .
, , , , , , .

ISBN 0-7356-1874-7 (.)


ISBN 5-7502-0225-9

,
Microsoft Corporation, 2003

, Microsoft Corporation,
2003

<

, - , 2003

XII






Microsoft Press

XIII
XIII
XIV
XIV
XV
XV
XV

VISUAL STUDIO ,NET

Visual Studio .NET

Visual Studio .NET


.NET



C++

(IDE)
Visual Studio .NET
,
Visual Studio .NET
Visual Studio .NET

Visual Studio (VSIP)



2 Visual Studio .NET

2
3
5
5
7
7
7
8
8
8
16
19
19
19
20
21
21
22
22
24
24
26
27
31
31
32
40
45
46
47

VI

3 Visual Studio .NET


IDE



,
( )

48
48
49
51
56

4 Visual Studio .NET


: Visual Studio .NET


Macros IDE









78
78
79
81
82
85
86
86
88
90
91
94
94
95
97

59
59
62
64
65
66
68
69
71
72
73
75
76
77

II

VISUAL STUDIO .NET


5

Add-in Wizard





99
100
100
101
102
107
109
111
111
..111

VII

112
120

121


Basic
Basic -
Basic Visual Studio .NET



IDTExtensibUity2
EnvDTE
OnConnection
OnStartupComplete
OnAddlnsUpdate
OnBeginShutdown
OnDisconnection

CommandPreload PreloadAddinScate
LoadBehavior ComrnandLineSafe
SatelliteDLLPath SatelliteDLIAame
FriendlyName Description
AboutBoxDetails AboutBoxIcon

7

?














devenv /setup




121
122
123
125
127
127
128
130
130
131
133
133
137
137
138
138
140
142
144
144
146
147
147
148
149
150
151
151
153
154
155
156
156
157
158
1
161
161
162
15
168
169
173

VIII

8

,






,
VSProject
Visual Studio .NET
Miscellaneous Files
Solution Items






IDE

9 Visual Studio .NET

174
174
175
17
177
182
184
184
187
189
189
195
195
197
197
198
200
200
207
210
212
213
214


214

214

215
.-
218
.vsz-
219

221

222

223

224
, .... 227

227

228

229

231

234

235
WizardBuilder
236

237
10

Windows
Object

238
238
238
241
.. 241

- UIHierarchy
UIHierarchy
UIHierarchy
UIHierarchylterns
UIHierarchyTtem
Toolbox

Toolbox
Task List


Taskltem
Task List

Output
Output

(Designer-Host


Selection
Options



11


Window
TextWindow HTMLWindow
TextPane

Document
TexcDocument

TextPoint
VirtualPoint
EditPoim
TextSelection
TextSelection EditPoint



.

IX

243
243
244
246
246
247
247
248
251
251
252
256
257
259
262
262
264
264
264
265
266
266
267
270
273
273
274
274
278
281
282
282
283
284
285
288
289
292
292
293
293
295
296
297
298
299
299
302


LineChanged
LineChanged

12



CodeEIement


304
308
309
310
310
310
321
322
322
326

III

327

13

328

Microsoft Windows Installer (MSI)



File System
Registry
File Types
User Interface

Launch Conditions

.

328
329
330
334
339
342
348
353
357
358
364

14 Visual Studio .NET

365






Command Window
Dynamic Help
XML Help Provider


365
366
367
368
369
370
371
372
376
381
383

15 Visual Studio .NET


Visual Studio .NET



VSIP
Visual SourceSafe
VSS ..

384
384
384
388
390
390
.. 390


FileCodeModel CodeModel
CodeElement



Add-
Add-

XI

390
393
398
398
399
400
400
400
404
406
419
419
420
423
42

428

06

441

.
. , ,
. , .
. , ,
, , . , , . , , ,
, .
Web- , .
.
:

Microsoft Visual Studio .NET.
, , .
, , ,
. , , . Big Bang ,
.

2000 ( ) Microsoft
Visual Studio .NET .
, , Windows- Web-
. , ,
, . , : Inside
Visual Studio .NET.
, ,
. , - , Visual Studio .NET.
,
Visual Studio .NET, (IDE) .
IDE.
2002 .
Visual Studio .NET. ,
, , .
, , , , .
, API ,
. ,
.
, , ,
.
, , , ,
. Microsoft Visual
Studio .NET 2003. , .
, Visual Studio .NET 2003 , IDE
, , , Visual Studio .NET 2003 .NET
Framework .


,
Visual Studio .NET. , Visual Studio .NET 2003,
Visual Studio ,NET 2002.
, , -

XIV

Visual Studio .NET. , - , IDE.


,
.


.
Visual Studio .NET, . IDE, , ,
, . IDE,
, , .
Visual
Studio .NET. API ,
, , Visual Studio .NET, Visual Studio .NET,
.
,
. , Visual
Studio .NET 2003 Microsoft Visua, SourceSafe.
,
12.


Web: http://www.microsoft.com/
mspre$$/books/6425.a$p. Companion Content More Information . .
Visual Studio .NET.
Program Files\Microsoft Visual Studio ,NET 2003\ Cornmon7\IDE\PubHcAssemblies,
My Documents\Microsoft Press\InsideVSNET,
Visual Studio .NET 2003- , Add Or Remove Programs ( ) Control
Panel ( ). Web- , .
Visual Studio .NET 2003, , Visual Studio .NET 2002.
Visual Studio .NET 2002
, -

XV

. ,
.


, Visual Studio .NET
2003. Visual Studio .NET 2003 Professional Edition, ,
, . Visual C# .NET,
Visual Basic .NET Visual C++ ,NET, , ,
, , ,
.


brianjjo@botmail.com.
,
, .
http://groups.msn.com/insidevsnet/. Microsoft Press (. ).
Visual Studio .NET,
,
Microsoft: news:// msnews.microsoft.com. Visual Studio .NET
microsoftpubiic.v$net. , , ,
Yahoo: http://grottps.yaboo.com/group/vsnetaeieiin/. .

Microsoft Press
, ,
. Microsoft Press World Wide Web no :
http://www.microsoft.com/mspress/support/
Microsoft Press, :
http://www.microsoft.com/mspress/support/search.asp
, , ,
, , Microsoft Press
:
Microsoft Press
Attri: Inside Microsoft Visual Studio .NET 2003 Editor
One Microsoft Way
Redmond, WA 98052-6399
:
MSPINPUT@MICROSOFT.COM
, , . Microsoft Visual
Studio .NET 2003 . http://msdn.microsoft.com/vstudio/

VISUAL STUDIO .NET


1
Visual Studio .NET

Microsoft . Visual
Studio .NET, 2002 , .
.NET Microsoft Web- XML, 2002 }'. Visual
Studio .NET 2003 .NET.
Microsoft .NET Server 2003-
1.1 .NET Framework.
.NET Visual Studio .NET .
(IDE). , ,
Visual Studio ,NET .

Visual Studio .NET


Microsoft . . 1993 .,
Microsoft C/C++ *, Visual C++ 1.0. Microsoft C/C++
MS DOS-.
, Visual C++.
IDE, Windows, , , Visual C++ . Microsoft Foundation
Classes (MFC) 2,0 Visual
C++. Visual C++ Win32- MFC- Windows,
MS DOS. , ,

1 Visual Studio .NET

Windows- Windows- .
,
.NET, Web- XML. .
Visual Studio, 1998 .,
. , (Visual C++, Visual Basic, Visual InterDev Visual J++),
. Visual Studio : Win32, MFC, COM, ActiveX, Active Template Library
(ATL), Java. DirectX Web. - Windows, Visual Studio 6. Visual Studio 6
Visual Studio .NET , Microsoft C/C++ Visual
C++ 1.0. , MS DOS Windows. Web- XML , , .NET Visual Studio .NET.
, .NET
Visual Studio .NET .

.NET
- MS DOS , Windows
3.1, , : ,
, ,
, MS DOS. .NET, , .NET
, Windows MS-DOS.
.NET Framework . ,
, .
(common language runtime, CLR), , , . , CLR, .NET Framework. . 1-1 ,
CLR .NET Framework.

/' .

CIR


. 1-1. NET Framework CLR
NET Framework

I Visual Studio .NET


(Common Language Specification, CLS) , .NET- .
(common type system, CTS) , , , CLS, CLS .
, CLR, Microsoft Intermediate Language (MSIL IL). (portable executable) DLL, . . . Windows-. MSIL . ,
CLS- , CLR,
. Visual Basic .NET
, Visual C#
C++.
.NET . Applied
Microsoft .NET Framework Programming (Microsoft Press, 2002)'.
CLR . DLL.
. , , API, Windows-,
Web-.
.NET Framework ,
. .NET Framework , . (, Internet Explorer ASP.NET) CLR . CLR .
CLR .
Visual Basic, C/C++ COBOL . , . , CLR, .
.NET Framework .
.NET- (. 1-2).
Web- 3ML.
CLR
. Visual Studio .NET , V isual C++, Visual Basic .NET, Visual J# .NET Visual

. Microsoft .NET Framework. M.: , 2002. , .

Visual Studio .NET

C# . , , COBOL, Eiffel, Python Perl


Web forms
Visual C#


.Visual Basic JffiT

Visual C++ .NET

MSIL

JIT-

MSIL

H MSIL

. 1-2. NET
,



Visual C++, , Visual Studio
.NET , . , IDE, . .


Visual C++ .NET, C++ Visual Studio .NET, ++ , .
7.1 . Microsoft Visual C++ .NET 17 12 , IDE .NET

.
: /GL

/GL .
, , , .
, /GL,
. .
(inline) ,
.
Microsoft, , . ,
/GL

Visual Studio .NET

, Ensemble Studios Age of Empires*, 10%.


: /GS


. ,
. , .
,
, . /(75 ,
.
. cookie
. , cookie .
, .
,
.
_set_security_errar_bandler.
Writing Secure
Code1 , , : Visual
Studio .NET . ,
, 7 , , . ,
, Visual Studio
.NET, .
: /

,
. /RTCn , (/RTCs), (/RTCs) , ,
(/RTCc).
/GS,
.
/RTCn /,
. /RTCn Visual Studio .NET.
, .
Xoeapd .. . . : , 2003. . .

Visual Studio .NET

IDE Visual
Studio .NET (Property Pages),
Solution Explorer: ,
, Properties.
. 2.


Visual C/C++ .NET . Microsoft Visual Studio .NET , . Windows.
Microsoft , . .NET Framework,
API Windows-,
, Visual Studio .NET, , Visual Studio .NET, . .
7. MFC 7, Windows XP,
Windows 2000 ATL 7. DHTML,
MFC-. , , ATL MFC , CSfring,
ATL- MFC. MFC.
ATL ATL. ATL- Web- ISAPI,
Web- XML. ATI-
Web- XML ATL .NET-.
, ,
Standard Template Library (STL) - (CRT).

C++
C++ C++ (Interface Definition Language, IDL),
, , ATL,
, >
.


Visual C++ ANSI/
ISO C++. Visual C++ .NET 2003 C++
98%.

I Visual Studio .NET

(IDE)
.NET , . Visual Studio .NET , . Windows, Web-, .NET.
-, Visual Studio .NET IDE ,
Visual Studio 6.
IDE. , , Visual
Studio .NET .
-, , Visual Studio .NET, CLR.
Visual Basic .NET Visual 0# CLR. Visual C++
CLR,
Windows. , .NET, MSIL, , CLR
, : Visual C# Visual
Basic .NET. CLR , CLR- . , , . .NET , ,
- , .
, , Visual Studio .NET ,
IDE .
IDE
. API
IDE, , Visual Studio.

Visual Studio .NET


Visual Studio .NET, , . , IDE, ,
, , , , IDE .

,
IDE Visual Studio ,NET .
IDE , .
Web- . IDE, : Solution Explorer,
Class View, Properties . , IDE (. 1-3).
API , Visual Studio .NET, , F. IDE. API -

Visual Studio .NET

IDE, . Visual Studio (Visual Studio Integration Program, VSIP).

. 1-3- Visual Studio AET


, Visual Studio .NET 2003,
IDE.


Visual Studio .NET
My Profile (. 1-4). ,
, . My Profile IDE.
, Visual Studio
Visual Studio .NET. .NET Visual Studio 6, , ,
Visual Studio .NET Visual Studio Developer,
. , , .

10

I Visual Studio .NET

. 1-4-
Visual Studio NET
IDE.
Visual Basic Visual InterDev .
C++ Visual C++ 6, , ,
, . , Visual Studio Developer Alt+7
Ctrl+Alt+D. ,
IDE , , , (Keyboard Scheme). . 3-

:
Visual Studio .NET, API , |
(Macros IDE). 4,

. Alt+Fl 1, IDE .
Project Explorer, IDE .
, , - IrtsideVSNET, Samples.
AutoHideToggle, , - :
Visual Studio .NET, WiridQwAutdtiideAll Visual Studio .NET.
, . WinetawAutolJnbideAB."
Reset

1 Visual Studio .NET

11

Window layout Options,


My Profile
. , .
i,
,
.
: DTE.Win4ou^Configurations.
Window. ,
, . ,
,
,
:

Sub AutoKideToggleO
:

Static As tfindowConfiguratlon * Nothing ;


Dira cmdo'bj As
' AutoHideAli.
osdobj * DTE.GoBBiands.Iteffl("Hindow.AutoHideAll")
With DTE.wifldowConfigurations
' , .
1
, .
: If Is Nothing Then
' ,
' , .
@ = .AddC'aTeinjT)
. aTemp.ApBlyO
' AutoHideAli.
OTE.CoBiHiands,Raise(cfflfobj,6uld, cnidobj.ID, Nothing, Nothing)
Else
' ,
' , .
aTeBJp.ApplyO
= Nothing
ERd if

ER With
Snd Stib
, ( ,
).
( Apply). 4 ,
, . 3 .
Help Filter , Visual Studio .NET . ++, MFC ATL,
, ,
. -

12

I Visual Studio .NET

Filtered By Search, ,
My Profile. 14 , .
My Profile Visual Studio .NET
. At Startup Show Start Page (no ),
IDE Get Started , . :
, , IDE,
.

Visual Studio .NET


,
.
,
IDE (Macros IDE).
Visual Studio .NET ,
IDE.
,
(. ).

Visual Studio .NET : Windows


Forms, Windows Forms; Web Forms, Web Forms WYSIWYG (What You See Is What You Get); , , XML-, XML (XML
Schema Definition, XSD).
Visual Studio .NET 2003 .NET. , Windows Forms
Web Forms, , .
,
Visual Basic, Visual C++. .NET -
, .


( ) IDE, . IDE
, , Command . Visual Studio .NET , .

Visual Studio .NET

13

Solution Explorer (Ctrl-t-Alt+L)

Solution Explorer (. 1-5) , Visual


Studio .NET. , Visual Studio .NET,
. ,
. Solution Explorer .
, .
Solution Explorer-

erances
ussemblylnfo.vb
Wizard, vb
WiiardFrm.vb

i Solution Explorer SJ Oass Vie*

. 1-5-

Solution Explorer

Class View (Ctrl+Shift+C)

Class View (. 1-6) . ,


Class View, Solution Explorer.
Cfass View -

(I ThumbWizard
+: *!* ThumbnailWi;ard
;-, *!* WinWapper
:
'- * Base; and [nherfaces
Gf HandK) As SysCem.lp
appkaCionObject
+ -** WcardFrm

. 1-6. Class View



Properties (F4)

, Windows Forms Web Forms. :


, , -

I Visual Studio .NET


Solution Explorer. . 1-7 Properties , ,

CpdCity

0,0
100%

WghtToWt

No

Show] nT a sto

Fake

Minimum5ize

502, 390
Auto
SnapToGrid
i StartPosiBon

True
CenlerParent

;Tag.

Thumbnail Wizard
Tart
The text contained J

. 1-7. Properties
, it
Server Explorer (Ctrl+Alt+S)

Server Explorer
. , , . ,

. . 1-8 Server Explorer ; ,
Visual Studio .NET, .
.
Toolbox (Ctrl+Alt+X)

Toolbox Visual Studio .NET , Windows Forms Web


Forms.
Web-, . Clipboard Ring . . . 1-9 Toolbox,
Visual Studio .NET ( http://
msdn.microsoft.com/vstudio/productinfo/tour.asp),

Visual Studio .NET

15

Server Explorer

Data Connections
Servers
, brianjoSlQO
Event Logs
&t Message Queues
Performance Counters
B]|g Services
?ij SQL Servers
master
model
msdb
Northwhd
^t tempiih
briarqoSSO
(3 Event Logs
S? Message Queues
[3 Performance Counters
*jjij| Services
Q| SQLServer;
Enfibrer I

. 1-8. Server Explorer


,

Data
Windows For ITS
lit ftoiriter'
A

Label

UnH.abel

ffl

Button

jsbi
|j Main-Menu
[7 ChedSox
(* RadioButtcfi

Panel

CheckedListBox
CkobaardRing

. 1-9- Toolbox

Command Window (Ctrl+Alt+A)

Visual Studio .NET Command Window


Immediate Visual Basic (.
2). ( med
commands) Visual Studio .NET. -

16

I Visual Studio .NET

IDE, ,
Visual Studio
.NET , , Command Window.
Command Window . (Command)
(. 1-10).
(Immediate) , , .
, immed.
,
>cmd.
*> , .
.
tlommand WHiilii
>Pilc.NewFil
Ffc.NewFile

1-10.
Command Window Visual Studio NET
IDE
Macro Explorer (AU+F8)

Macro Explorer (. 1-11) , IDE, :


IDE , .
(Ctrl+Shift+R) Macro Explorer MyMacros\Recording Module \Tempo Macro.
, ,
IDE , . 4.
IDE , . , Object Browser.

Visual Studio .NET


, Visual Studio .NET
. Teivcy ,
, ,
IDE . Visual Studio .NET 2003
\Program Files\Microsoft Visual Studio .NET 2003- .
(
, ).

Visual Studio .NET

17

Macro
^ InsideVSNET
3 MyMdcros
'^g Samples
| Dev5tudio6Editor
| mateflddfn
'

nr

| Debugger
| V5Editor
SI Beginning Of Function
i3 Cents-Screen

^BB
tED CountGccurrences
DoFotWholeRle
53 EmacsStylelndentLine
& FillCommentParagraph
FixLineEnds
S InsertDate
insertTirre
Dfer |

. 1-11. Macro Explorer



Visual Studio .NET SDK\vl.l .
Framework SDK. .NET Framework,
, , .NET,
. .NET Framework SDK StartHere.htm
SDK\vl.l.
, Visual Studio .NET, ,
.
. , C++, VC7, # VC#, Visual Basic .NET Vb7. IDE.
IDE Samptes.vsmacros. Visual Studio .NET, IDE, My Documents\Visual Studio Project\VSMacros.
IDE . Samples.vsmacros,
My Documents\Visual Studio Project\VSMacros,
IDE . -
, Samples.vsmacros,
IDE,
IDE Devenv.exe.
Common7\IDE. IDE , . PublicAssemblies
PrivateAssemblies, , IDE. HTML . MacroProjectltems
MacroProjects. ( ) NewFilelterns NewScriptltems.
2-1116

18

Visual Studio .NET

Tools IDE
, Tools IDE.
.
1. Ctrl+Alt+A, Command "Window, Tools.ExtemalTools, External Tools.
2. Add, ,
IDE Fobier.
3> Command 1....
4- Arguments IDE. (
C:\Program Files\ Microsoft V:sual Studio .NET 20Q3\Cornrnon7\lDE}.
5. .

, Tools IDE Folder,


IDE,
External Tools , .


, Crnd.exe
Visual Studio .NET. . -,
Visual Studio .NET Command Prompt Tools, Microsoft Visual Studio .NET 2003.
Visual Studio .NET Command Prompt
,
.
Visual Smdio vsvars32.bat.
Common7\Tools.
Cmd.exe, , C:\Program
Files\Microsoft Visual Studio .NET 2C03\Common7\Tools .
( : , ,) , , vsvars32,
Visual Studio .NET.
Tools Command.
External Tools: Add,
(Command Prompt) cmd.exe Command. S(ProjectDir) Initial Directory ( ).
, . , ;, .
, , Common7\IDE . C:\Piogram Files\Microsoft Visual Studio .NET 2003\Common7\IDE. Devenv.exe
. vsvars32.bat,
Devenv.exe.

Visual Studio .NET

19

Devenv
. ,
.

Visual Studio .NET


Visual Studio .NET ,
Visual C++ 5. Visual Studio .NET DTE (Development Tools Extensibility)
, 200 .
DTE API , ,
.
, Visual Studio Integration Program
(VSIP). ( .)
, , Visual Studio .NET.

Visual Studio .NET


, API . Macro Explorer,
IDE ,
DTE.
, ,
. 4
IDE .
Visual Studio .NET Visual Basic .NET ,
.NET,
.NET Framework , , .NET-.
IDE , Visual Studio .NET, Alt+Fll.
IDE .
Visual Studio .NET. ,
Visual Studio .NET, .
. 1-12 IDE ,
Project Explorer,
.

IDE Visual Studio


.NET IDE . , Visual Studio .NET. , (, , ,

20

Visual Studio .NE~~

IDE
, , IDE.

. 1-12.

IDE Visual Stvdio NET

.NET-,
- Visual C++. IDTExtensibility2. Visual C#. , Web,
#, Visual Basic .NET.
Microsoft ,
IDE Visual
Studio .NET. http:// nisdn.microsoft.com/vstudio/
downloads/automation.asp.
, Visual Studio .NET .
5 , .

Visual Studio .NET ,


JTDWizard , .
. )' . IDE, MFC Event Handler Wizard
(. 1-13), .

1 Visual Studio .NET

21

n! Handler Wizard MFCApp!


Wefcome to the Event Handler Wizard
;rator command hamfci or dWog ?* - pi event fonder (a (he

. 1-13. Event Handler Wizard


Visual Studio (VSIP)


VSIP, .
API, API , . , .NET- IDE.
, ,
ActiveStale ( Visual Perl .NET Visual Python .NET), Compuware ( DevPartner Profiler) Fujitsu ( NetCOBOL .NET).
VSIP . http://msdn.microsoft.com/ vstudio/vsip/.


2 Visual Studio .NET,
IDE .
Visual Studio ,NET
.

2

Visual Studio .NET

11 , Microsoft Visual Studio .NET, (solutions) (projects). ,


. , Visual Studio .NET , IDE.


Visual Studio .NET ,
( ),
. , ,
, ,
, - .
.NET- /.
! Visual Studio .NET . , ,
. ,
,
Visual Studio .NET Solution
Explorer (Ctrl+AIt+L) (. 2-1). Solution Explorer ( ) ,
,
, .
Visual Studio .NET , , , Visual Studio.

Visual Studio .NET

23

i 5oluticn 'ChapterOZ' (7 projects)


CPPWin32
CSWebApp
CSWebService
CSWinApp
!+ 1^3 Reference?
[3 AssemblyInfo.vb
ajj Global,asax
Ag styles.ess
*3 VBWebApp.vsdiscc
[y Web.config
WeoForml.aspx
Jp VBWinApp
+ References
'"'] tesemblylnfo.vb
F i 1 ii
^j
SetupApplicattor

J_j Detected Dependencies

. 2-1.

,
( , Visual Studio), ,
Visual Studio .NET 2003 Microsoft Visual Basic .NET, Visual
C, Visual J# Visual C++ .NET.
, , ,
.
.
Windows Forms Windows-
, .
Web Forms Visual Studio Projects, My Documents, Web-, Web- ,
. Visual Studio .NET ,
. .

:
. ,
, , , .
Chaptr02, , . Visual C# Windows
Application Sampledl.csproj.
Sampled.sin. ,
SampIeOl,
. . .

24

Visual Studio .NET

Solution Explorer, , File Save Sampled I.sin As Chaptcr02, , Chapter02.sln.


. ; Chapter02, SampleOl. Chapter02sift.
. Ctrl+Alt+A, FJle-AddNewProject Command Window. Add New Project
# Windows Application Sample02.
Chapter02 . Chaptet02 Yt& .
Sample02 . Sample02.csproj,
Sample02.
Chapier02 . ,
, .
Visual Studio .NET.

Visual Studio .NET . Visual Studio . , , -


. , ,
Visual Studio .NET, , .


,
. HTML-, , ,
XML-, . . , Miscellaneous
Files Solution Explorer, Show Miscellaneous Files In Solution
Explorer Documents Environment Options (.
2-2). : Miscellaneous Files, IDE
, , Fue.OpenFile.
, IDE , , , . IDE Miscellaneous Files.
Miscellaneous Files, .
: , Visual Studio .NET,
Miscellaneous Files. -

2 Visual Studio .NET

, Miscellaneous Files Project Saves Last , ,


3 . , , ,
(. 2-3).

Environment
General
4- Documents
Dynamic Help
Fonts and Colors
Help
International Setting?
Keyboard
Projects and Solution
Task list
Web Browser
^ Source Control
j Text Editor
03 Analyzer
Q Database Tools
iH) Debugging
ll^j HTML Designer

Settings "
" -use current document window, if saved
Detect when file is changed outside the environment
f Auto-feed chances (if * )' modified inside the
Environment)
s" AiojvwftlngofreacS-Qnlyfiles, wain when attempt to save
i"? f te using directory of currently active document
fjKellaneous rles prefect saves last

stems

Find and Replace


P* Show messege \>xes
\ 1 terf from editor

Help

. 2-2. Miscellaneous Files


Options
Solution npterer ?-ttcellaneine Fifes

Solution 'CSharpflddin'(l project)


S^l CSharpAddwi
, IMJ References
1*3 Assemblylnfo.es
Connect,cs
^J Miscellaneous Files
180 AddrDev5chedule,mpp
Readme.txt

. 2-3. Miscellaneous Files ,


26

I Visual Studio .NET


Solution Property Pages , . , ,
,
, ,
, .
Solution Property Pages (. 2-4) ,
Solution Explorer, Ctrl+Alt+A Project.Properties
Command Window >
Properties.

!?.J Configuration *
CPPWinj.

Ncns

CSWebApp

40T.J

C5*'eb5ervice

Non;

CSWnApp

Hen;

VBWfbApp

Non.'

, 2-4. Solution Property Pages




Common Properties ( )
. Startup Project ( ). , Debug.
Solution Explorer Set As Startup,
Multiple Startup Projects Start Start Without Debugging
Debug.
DebugStart DebugStartWitboutDebugging.
Start, Start Without Debugging None. Move Up Move Down
,
.

. , .

2 Visual Studio .NET

27

. , ,
.
Common Properties Project Dependencies. ,
. Project Dependencies , , , .
Common Properties
. , , , , . , .NET-, Visual Studio .NET . , , , .

,
, . Debug Release ,
, Configuration Manager, . Solution Property Pages Build
(Buud.ConfigurationManager).
Visual Studio .NET : . . ,
, .
, , .
, , . , , .


(.sin) ,
, , .
. ,
Visual Studio .NET 2002, Microsoft Visual Studio Solution
File, Format Version 1.00, ,
Visual Studio .NET 2003, Microsoft Visual Studio Solution File, Format Version -WO.
infif '' mmrmnrnmi'iTf "i *1*11 ^^ !^

! Visual Studio .NET


2003 Visual Studio .NET 2002,

28

Visual Studio .NET

.sin , , ,
. ( 2-1).
2-1.

Chapter02.sln
Microsoft Visual Studio Solution File, Format Version 7.00
Projectr{F184BG8F-C81C-45F6-A57F-5A8D9991F28Fr) * "VBWinApp",
"VBtfinAppY/BWinApp.vbproj",
487AFF922-38D5-46lC-AQ78-859080BFCFBFr
EndP reject
Project('4F184B08F-C81C-4SF6-A57F-5ABD9991F28F}") = "VBWebApp",
"http://locainost/VBWebAppABWebApp . vbproj " ,
"{0654F4FC~7144-457A~9D73-A14!)ECDODB40}"
EndP reject
Projeetr4FA04EeO-3G1F-11D3-BF4B-aOC04F79EFBCr) " "CSWinApp",
"C$WinApp\CSWiriApp . cspro j " ,
"{9D585FB1-AA56-4227-A814-23F16E4F07E4}"
Preject("{FAE04ECO-301F-1103-BF4B~OOC04F79EFBC}"> = "CSWebApp",
"http://localhOst/CSWebApp/CSHebApp.CsproJ",
4AB66I)7EB-1>B6F-45EB-AE70-B97;!02AB52F1}"
Project("{8BC9CEB8-8B4A-1!DO-8D11-OQAOC918C942}")
"CPPWif32\OPPWiRa2. vcproj",
"{912ECF9E-5ABA-4E85-8955-2SOCrC464C377}"
End!P reject
Projeot("{E6FOF86B-F3D1-11D4-857e-30Q2A516ECE8}") - "VJConsoleftpp",
" VJConsoleApp\VJConsoleApp . v j s p ro j " ,
-{2022B3FD-6AFB-4912-8687-4BOE257A48A1)"
End Project
Project('4FAE04ECO~301F-1tD3-BI:4B*OOC04F79EFBeK'> "CSWebService",
"http://localhost/CSlebServicfr/CSWeb8ervice,csproj"1
"{22A37BFE-687D-44E6-9COC-711735BC5018}"
EndP reject
Global
GlobaI^ctiort{Solution.Gonfi8uration) - preSolution
ConftgName.O = Debug
ConfigNaffle,2 PostCHD
ConfigNase.3 * PostE^lorer
ConfigNaffle.4 = Release
EndGlobalSeetion
GlobalSection(ProjectBe^entfencies)

postSolution

GlobalSection(ProjectConfiguration) - postSolution
{D7AFF922-38D5~461C-AiS7B-S5908QBFCF8F}.Debug. ActiveCfg = Debug|.NET

2 Visual Studio .NET

{D7AFF922-38D5-461C-AG7B-859G8QBFCFBF}.Debug.Build. 0 = Debug).NET
{D7ftFF922-38D5-46lC-A078-8590BOBFCFBF}.Defeug1.ActlveCfg = Debug|.NET
{U7AFF922-38&5-481C-A07B-859GBQBFCFBF}.Debugl.Build,& ~ Debugl.
{D7AFF922-3805~461CAQ78-85908Q&FCFBFbPostCHu, ActiveCfg * ftelease|.NET
{D7AFF922~38D5-461C-AQ7B-859Q8QBFCFBFbPostGMB. Build.0 = Raima).NET .
{D7AFF922-38D&-46tC-AQ7B-859Q8QBFCFBF}.PostExplorer.ActiveCffl =
Release).NET
iS7AFF922-38D5-461C-A07B-859080BFCFBFbPQstExpaorer.Build. 0 =
Release i- NET
{D7AFF922-38DE-461C-AG7B-85908QBFCF8F}.Release.ActiveCfg *

29

-..'.''

ReJeasel-tET
{07AFF922-38D5-461G-A07B-B59080BFGFBF).Release.Build,0 Release!.SET
{D654F4FC-7144-457A-9D73-A149ECDODB4Q}.Debug.ActiveCfg = Debugt-NET
{DS54F4FC-7144-457A-9D73-A149ECD0084Q}.Debug.Build.Q - Debugl-NET
{D654F4FC-7144-457A-9D73-A149ECDGBB40}.Debu^l.ActiveCfg - Oebug{.
{D654F4FC-7144-457A-9D73-A149ECDODB4QbDebug1.Buiia.O = Defeugl-WET
{D654F4FC-7144-457A-9073-A149ECDOOB40},PostCHD.ActiveCfe Release!.NET
iD654F4FC-7144-457A-9073-A149ECDODB40}.PostCHO.Build,0 = Release|.MET
{D654F4FG-7144-457A-9D73-A149ECD00840>.PDStExplorer,ActiveCfg
Releasel.NET
{D654F4FC-7144~457A-9D73-A149ECDODB40}.PostExplorer.Suilcl.O =

FteleasBl.HET
{D654F4FC-7144-45rA-9D73-A149EGDODB40>.Release.AGtiveCfg = Release|.
{D54F4FC-7144-457A-9D73-A149ECDODB40).Release.Build.0 = Release!.NET
{9B585FB1-AA56-4227-A814-23F16E4F07E4).Debug.ActiveCfg = Debugi,ET
{9D585FBVAA56-4227-A814-23F16E4F07E4bOebug.Build.0 = Debug|.HET
{9&585F81-AA56-4227-AB14-23F16E4F07E4}.Debug1.ActiveCfg * Debugir.HET
{9D585m-AAS6-4227-AB14-23F16E4F07E4}.Debtjg1.Build.0 uebugtl-NET
{90S8SF81~AA56-4227~A814-23F164F07E4}.PostCHO.ActiveCfg = Debugl|-NET
{90585FB1-AA56-4227-A814-23F16E4F07E4}.PostCMD.Build.0 = Debugl[.KET
{9D585FS1-AA56-4227-AB14-23F164FQ7E4>.PostExplorer.ActiveCfg =
Debugl|.
{90S8&F81-AA56-4227-AB14-23FieE4F07E4bPostExplorer.Build.0 *
Debugl|,NET

.J*t

{90585F81-AA5&-4227-AB14-23F16E4F07E4}.Release.ActiveCfg * Release |. NET


{9D585FB1-AA56-4227-AB14-23F16E4F07E4>.Release.Build.0 Release!.
{AB6fiu7B-DB6F-458-AE7D-B972D2A652F1).Debug.ActiveCfg = Debugj.HET
{A866D7EB-OB6F-45E8-AE7D-B972D2A652F1}.Debug.Build.0 - Debug|.
{AB66Q7EB-086F-45E8-AE7D-B972P2A852F1}.Debygl.ActiveCfg * Debugj,NET
{AB66D7EB-DB6F-45E8-AE7B-B972D2A652F1}.Debugl.Build.0 = Debug!.ET
{ABe6B7EB-DB6F-45E8-AE7D-B97202A652F1}.PostCMD.ActiveCfg = Release t.NET
(ABS6D7EB-BB&F-45E8-AE70-B972D2A652F1}.PostCMD.Build.0 = Release!.NET
{AB66D7EB-OB6F-4SE8-AE7D-B972D2A652F1}.PostExplorer.ActiveCfg =
Releasel.NET
{AB6607E8-DB6F-4SE8-AE7D-B972D2A652F1b PostExplorer.Build.0 -

Release\,NET
{AB6607EB-DBSF-45E9-AE7D-B972D2A652F1}.Release.ActiveGfg * Rele.asef.NEl
{AB66D7EB-DB6F~4SE8AE7D-B972D2A652F1}.Release.&uild.0 * Releasej.NET
(912ECF9-5A8A-4E85-8955-2flOBC464C377}.Debug.AetiveCfg * DebugIin32
{912EeF9E-5ABA-4EB5-8955-28SDC464C377bDebu8.Build.0 Debug|Win32

. ^. .

30

Visual Studio .NET

{912ECF9E"5ASA~4ES5-8955-2BQDC464C377bDebug1.Actlvefg = DebugJW1R32
^912ECf9E~5ABA-4E85-8955-2BODC464C377}.De^ug1.Bulld.6 = BebugfWin32
{912ECF9E~5ABA-4E85-8955-2Bt}flC464C377}.PostCMD.AetiveCfg =
PostCMD|Win32
{912ECF9E-5A8A-485-8955~2BQDC464C377>.PQSteM0,BLJild.0 = PostC*ffi|Win32
{912ECF9E-5ABA-4E85-8955-2800C484C377}.PostExplorer.AetiveCfg *
PostExplorer|#ifi32
{912ECF9E-5ABA4E85-S955-2BOC3464C377b PostExplorer. Build.t PostExplorer|Win32
(9l2ECF9-5ABA-4E85-8955-2BOD::464e377}, Release, ActiveCfg =
Release|Wtn32
{9129-5~485~8955-201)46437?1. Build. 0 = Release[Win32
{2Q22B3Fa-6AFB-4912-8687-4809:>57A48A1}.Debug.ActiveCfg * Debug|.NET
*2G22B3FD-6AFB-4912~8687-4B00;>57A48A1}.Debug.Buil<j,0 * Oebug|.NET
{2022B3FD-6AFS-49l2-8687-4BQ9;?57A48A1}.Debug1. ActiveCfg =
{2022B3FD-8AfB-4912-8687-4B09;?57A48A1}.Debugl,Build.0
{2022B3FE)-6AFB-4912-86B?-4B0@:157A48A1}, PostCHD, ActlveCf g = Release f. NET
{2Q2283FB-6AFB-4Sl2-8687-4B09;?57A48A1.}.PostCHD. Build.S = Rel&8*e~f .NET
{2022B3FD-6AFB-4912-8687-4B09;!57A48A1}.Postxplorer.ActiveCfp *
Releasej.NET
^2022B3FP-6AFB-49l2-8e87-4B09E!57A48A1}.PostExplorer.Build.0 =
Release[.NET
{2022B3FD-6Af:8-49l2-a687-4B09;'57A48AlbRelease.ActlveCfe = Release! .NET
{2Q2283H3-6AF8-4912-8687-460957A48A1).Release.Build.6 = Releas&|.
{2237--44-9-7117355018}.Debug. ActiveCfg = Debyg|.NET
{22A37BFE-687D-44E6-9COG-7117a5BC5018bDebug. Build. 0 = Debug).NET
{22A37BFE-6870-44E6-9COC-711735BC60t8}.Debugl,ActiveCfg Debug[.NET
{22A37BFE~687D~44E6-9CGC-711735BC5018}.Debug1, Build. S = Oebugl-NET
: {22A378FE-68'7D-44B-9CaC-711735BC5018}.POStCMO.ActiveCfg = ReleaseJ.HET
{22A378FE-887D-44E6-9COC-7117358C5018}.POStCHD,Build. 0 = Release}.NET
{22A37BFE-687D~44E6-9GOC-7l1735BC5018}.PostExplorer.ActiveCfg Release I.NET
{22A37BFE-687D-44E6-9COC-7l1735BC5018}.PostExplorer.8yild.6 =
RsleaseJ.NET
{22A378FE-687D-44E6-9COC-7117358C5018bfEelease,ActiveGfg * Release(.NET
{22A37BFE~687Q-44E6~9COC-711735BC5018J.Release,8ulld.O = fieleasef.NET
EndGlobalSection
GlobalSectionCExtensibilityGlolials) = postSolution
EirdGlobalSection
G10balSectioci(Extei>sibilityAdd::ns) * postSolution
EndGlobalSectiofl
EndSlobal

, , , . , ;: , , (.suo). ,
.sin .suo, )'
, .suo, .

2 Visual Studio .NET

31

, .suo, ,
. , , , , Task List. , , .suo ,sln. , .suo , , e-mail.

, Visual Studio ,NET.


,
, Web- , . , Visual Studio .NET Solution
Explorer.


Visual Studio .NET .
, , . , . , Visual
C++, , Solution Explorer. ,
, .
Visual C++ , . , ,
Visual C++ ,
. Windows Forms
. Web Forms , .
Visual Studio .NET 2003 (. 2-1):
. 2-1. Visual Studio .NET 2003

Visual C++
Visual Basic .NET (Web)
Visual C# .NET (Web)
Visual Basic .NET
Visual * .NET
Visual J#

Solution Explorer Windows Forms,


Visual C# Visual Basic .NET, , ProjectSbowAllFHes.
. , , . , ,
, . Show-

I Visual Studio .NET

32

AilFiles Project
Solution Explorer. , . -JM (code-behind), ASP.NET. . 2-5 .
Sobjtioo Enptorer CSWebftpp

Solution 'Chdpter02' (8 projects)


CPPWin32
^j References
Jbri
'*$ usserrtrfylnfo.cs
CSWebApp. disco
Global, asax
Web.config
WebForml.aspw
1
C5Web5erMce
1 CSWrnApp
; VBWebftpp
1 VBWinApp
I VJConsoleApp
1 SetupApplication

. 2-5.

Visual

, ,
, , IDE,
. . .NET MSIL (Microsoft Intermediate Language),
,


Property Pages. ( Solution Explorer
Properties .)
Property Pages Solution Property Pages,
.
, ; .

, Visual Studio .NET,
. Visual Studio .NET ! ,
.

2 Visual Studio .NET

33


Configuration Manager Configuration
Manager Property Pages Build.ConfigurationM anager Command Window. ,
, Configuration Project Contexts, New . New Project
Configuration (. 2-6).
NewProjept Configuration
Project Configuration Nane;

Also create neiv solution confsguration(s}

<

. 2-6.

Cancel

Help

New Project Configuration

, , Copy Settings From. New Solution Configuration,



, Also Create New Solution Configuration(s).
, . HI
, ,
. ,
.


, Visual Basic .NET, Visual C# Visual Jt, Property Pages. ,
Windows Forms Web Forms,
.


. 2-7 General, Common Properties
Visual Basic .NET Windows Forms.
General Configuration Properties. :
Configuration, Platform, Configuration Manager , Common Properties.
,
. , Assembly
Name, Output Type, Namespace. Common Properties
Page Layout, (Flow Grid)
Web Forms Windows Forms: Target Schema,

34

Visual Studio .NET

Web-, , , .
VUtofinApp Properly Panes

. 2-7. General General


Visual Basic NET Windows Forms
,
General Visual C# Web Forms (. 2-8).
Visual Basic .NET , Visual C# .

* General
Designer Qetents
References Ruth
Configuration Propel

i Output Type
| QtfxJt Nar.ieipa
; Startup OC]ecI

Wrepoer AfSfmbly Key Ne


', Wreppe uissnblv Key Name

Nqmt
art the oUpolfite that hoM

. 2-8.

General Visual C# Windows Forms

.
,
.

Configuration Properties , (build).
-

Visual Studio .NET

35

Visual Studio .NET, IDE (. 15).


Configuration Properties, Visual C# Property Pages.
Property Pages Visual
Basic .NET, Visual C#,
.
. 2-9 Build Configuration Properties Visual C#.
. Output
Path. Visual C# Debug
\bin\Debug\. Relea.se
\bin\Release\. , . , ,
. , ,
, . ,
DebugOverflow (
), \bin\DebugOve flow.
CSWiiiApp Properly Pages

Conditional tDmpiafccn Ccnstan DEBUG;

I
False
' Check for flrttmBtic OvftrFlowJl. False
\ fJkm unsafe cede block*

. 2-9.

False

Build Visual Windows Forms

Debugging (. 2-10) , Web Forms Web- XML. , Start URL. , URL, Web- XML,
Start Application. .

I Visual Studio .NET

indicates :heupL fflatihould be bundled Shi


For example, joumight SHs tho uftlMa<*5b

. 2-10.

Debugging Web Forms


Command Line Arguments. : ' :
"
, .
,

. ,
,
. ,
, , .> ,
.
Advanced (, 2-11) , . Visual C Advanced Configuration Properties
DLL, .
. Windows 4 ,
.NET 512, 1024, 2048,4096,8192 16384- Incremental
Build , /doc
. /doc , , , ,
Incremental Build False, .
Visual C++
Property Pages Visual C++ ,
. , ,
Visual C++. , .

2 Visual Studio .NET

|j Confntr Properties
-jj omfifMatiun Propertta

'7

- '

Inrremtnlal buBd
EniWe the inoerenti

. 2-11.

Advanced Web Forms

. 2-12 Property Pages Visual C++


Win32: ,
.
Cfl*WtnJ? Property

. 2-12.

Visual C++

Property Pages Visual C++ , Configuration Properties. . 2-2


, ,
. 2-2. Configuration Properties Visual C++

C/C++

, ,
, .
, .
, ,
.
. . .

Linker
Resources

38

I Visual Studio .NET

. 2-2.

MIDI

()

Microsoft Interface Definition Language


(MIDL), .
Browse Information , BSCMAKE ( ).
Build Events
,
.
Custom Build Step
; . , .
Web References
, - Web-, .
Web Deployment
, Web .
Visual C++
. Web References , Visual
Studio .NET Web- XML, IDE , .
Build Events
. . 2-13 PostBuild Event.
Build Events.
Regsvr32.exe Post-Build Event,
,
Windows.

. 2-13-

2 Visual Studio .NET

39

;
, . , : , , , - Tools Visu.tl
, Studio .NET. Windows Explorer , ( , ;>.
.) -
, >jer.exe , .
; 1. PostExplorer.
2. Post-Build Event Command Line:
Explorer,exe $(TargetSir)
3. ,
, .
, Windows Explorer . -, < i , , Buildlog.hf .
Property Pages
(. 2-3).
. 2-3. , Property Pages

SfConftgurationName)
S(DevEnvDir)
S(FrameworkDir)
S(FrameworkSDKDir)
$ (Frame workVersion)
S(Inbent)
S(lnputDir)
S(InputExt)
S(Inputl-ileName)
S(InputName)
S(InputPath)


Visual Studio .NET
.NET Framework
.NET Framework SDK
.NET Framework
,
Visual Studio .NET
,


( + )

S(lntDir)

S(NoInherit)
t(OutDir)
S(PlatformName)
S(ProjectDir)



, Win32 .NET
,

S(ProjectExt)

f.vcproj)

. , .

40

. 2-3.

Visual Studio .NET

()

S(ProjectFileName)
t(ProjectName)
t(ProjectPatb)
S(RemoteMacbine)
S(SolutionDir)
S(SolutionExt)
S(SolutionFileName)

(CPPWm32.vcproj)
(CPPWin32)
i;
( )
,
(.sin)
(Chapler02.sln)
(Chapter02)

S(SolutionName)

;

(.)
(CPPWin32.exe)
(CPPWin32)

Visual C++ .NET
Visual Studio .NET

S(SolutionPath)
S(TargetDir)
S(TargetExt)
S(TargetPtteName)
S(TargetName)
$(TargetPatb)
S(VCInstallDir)
S(VSInstcUlDir)


, ,
(. 2-4). , Visual Studio Integration Program (VSIP) .
. 2-4.

Visual Basic .NET
Visual C#
Visual C++
Visual J#
Deployment

.vbproj
.csproj
.vcproj

.vjproj
.vdproj

CSWinApp.csproj Visual C# Visual Studio .NET ( 2-2)


, .
2-2.

CSWinApp.csproj
<VisualStudioProject>

ProjectType * "Local"
ProductVersiori = "7.10,2215"
SchemaVersion = "2,0"

2 Visual Studio .NET

ProjectGuid = "{9DC32270-2155-414F-9BE5-C593ADE47FFD}"

'-' -

<Build>
<Settings
Applicationlcon = "App.ico"
AssejiblyKeyContainerName = ""
AssemblyNanie = "CSWinApp"
AssfiBblyQrigiflatorKeyFile = "
DefaultClientScript = "JScript"
DefaultHTHLPageLaywat = "Grid"
- EtefaultTargetSchem = "IE50"
DelaySign = "false"
OtrtputType = "WinExe"
PreBuildEvent - ""
PostBuiIdEvent = ""
RootNaiespace "CSWiRApp"
RunPostBuildEvent = "Ort&uildSuccess"
StartopObject = ""
>
;:;..'-;

41

'' '

.- "

<Config
Uame = ""
AllowUnsafelocks = "false"
BaseAddress = "25212672"
CheckForQverflowUnderflow = "false"
ConfigurationOverricteFllB =
DefineConstants * "DEBUG;TRACE"
DoGuiaentationFile a ""
DebugSymbols * "true"
FileAlignraent = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize - "false"
(btputPath "bin\Debug\"
RegisterForCoBtlRterop = "false"
ReiflovelntegerCfiecks ~ "false"
TreatWarningsAsErrors = "false"
WarningLevel - "4"
/>
<Config
Name ~ "Release"
AllowUnsafe81ocks = "false"
BaseAddress = "285212672"
OfceokForGverflowUnderflow * "false"
ConfigurationSverrideFile = "
DeflneConstants = "TRACE"
DocumentationFile
DebugSyrabols = "false"
FileAUgniaent * "4096"
IncreraentalBuild ~ "false"

. . .

42

Visual Studio .NET

NoStdtib - "false"
floWam = ""
Optimize - "true"
GtttpurtPath = "bln\fielease\"
flegisterForConilnterop = "false"
ReeioveZntegerChecks * "false"
TreatWarnlagsAsErrors = "false"
WarniRgLevel - "4"

Name = "Debugl"
AllowUnsafeBlt'Cks = "false"
BaseAddress = "21521267^"
CheckFofSyerflo^ntferflow = "true"
ConflguratlonCverrideFtle ""
DeflneConstants = "DEBUG;TRASE"
DocyraentationFtle = ""
~ "true"
= "4096"
Incremental Etui Id = "false"
NoStdLib = "fnise"
Optiitize - "fulse"
fiegisterForCofrrlnterop - "false"
aeiiovelntegerClrecks * "false"
TreattfarningsAsErrors ~ "true"
WarningLevel = "3"
</Settings>
<References>
Name = "Systwir
AssemWyNaifte * "System"
"C: \WINDOWS\Hicrosoft , NET\Fraiaework\v1 . 1 . 4322\Systeni. tttl"

f*

Reference
Nasie - "System. Data'
AssemblyNaiae = "System. Data"
HiRtPath
"C:\WINDOWS\Mic rosoft . NET\Fraraewor k\v1 . 1 . 4322\Systeni. Data.
A

Name = "System. Drawing"


AasentblyName "System.
HlntPatft *
"C : \WIIOW3\HlerGsaf t . NT\Frafflewor k\v1 . 1 , 4322\SysteB . 8 rawing . dll '
/>
<Reference

2 Visual Studio .NET

43

~ "System. Mlrtcfows. Forms"


AsseiiblyNatne = '"Systen, Windows, Forms"
HintPath
"C:\lWDQWS\Hicrosoft.:KBr\FraHiework\v1.1.4322\Systeffl. Windows. Forms.dll
Naiee "System. 1"
AsseeblyName = "System. Xntl"
HlntPath ~
": \WMDOWS\Microsoft. NET\Frante'Mork\v1.1.4322\Systein.XHt,dll
/>
</fteferences>
"

</8ullt>

<Include>
<File
fielPath - "App.ico"
BuildActiofi - "Content"
Belfath "AssemtJlyInfQ.es
SubType - "Code"
BulldAetion = "Compile"
/>
. . ..".
<Fle
:."
RelPatti = "Forni.es"
SubType - "Form"
BuildActlon = "Compile"
RelPath = "Fomt.resx"
Depend = "Formt.cs"
BuildAction * "Embeddedflesource

</CSHARF>
</VisualStydiof>roject>
Visual Basic .NET, Visual C#, Visual J# : ProjectNameProjectExt.user.
Visual Basic .NET .vbroj.user,
XML-
. Visual C# 2-3
.csproj 2-2.
, , Debug 1. .suo .user
.

44

2-3.

Visual Studio .NET

CSWinApp.csproj.user
<VisualStudioProject>
<CSHARP UstOpervVersion = ". 10.2215" >
<Settlngs ReferencePath = "" >
<Config
Mam = "Debug"
EnableASPDebuijging = "false"
EnableASPXCebusgirvg - "false"
EnableUnieanagiHiDebiigging * "false"
EnableSQLSenmrDebugging = "false"
RefBQteDebug Enabled = "false"
ReraoteDebugHachine = ""
StartAction = "Project"
StartArgumentji = ""
StartPage ""
StartProaram ""
StartURL ""
StartWorkingDirectory =* ""
= "true"
<Cnfig
~ "Release"
Enable AS PDebugg ing = "false"
EimbleASPXDebijgglng "false"
EnableUnmanagadDebugging * "false
EnableSQLServiirDebugging = "false
Remote Be bugrt,abled = "false"
RenoteDebug^aohine = ""
StartAction = "Project"
StartArgiments - ""
StartPage = ""
StartPrograra = ""
StartURL = ""
StartWorkingDirectory = ""
StartWithlE - "false"

Name =
EnableASPDebugging = "false"
EnableASPXDebugglng = "false"
EnableUfiiBanagedDe bugging * "false"
EnableSQLServerDebugging = "false"
RemoteDebugEnabled ~ "false"
RemoteOebugHachine ""
StartActlon "Project"
StartArguments ""

2 Visual Studio .NET

45

Start Page * *
StartProgram * ""
StartUBL = StartWorkiRgDirectory

StarmtthlE * "true"
</SettriBS>

<OtherProjectSet tings
CopyProjectDestinatiofiFolder
CopyProjectUncPatfi = "
CopyProjectOptiofl = "0"
P'rojeetView = "ProjeetFiles"
ProjectTrust = "0"
</CSHARP>
</VisualStudioProjeet>


Solution Explorer
, . Solution Explorer "
, Web-. , , .
Add Reference,
, Solution Explorer
ProjectAddReference Command Window, Projects
(. 2-14).

: Frojei.1 Directory^
c:\Docurnerits arid Settings\Bnar,\De;ktop\lN5..,
CSWinApp
VBWebApp

i4i.|.

VJConsoleApp

C:\Documenb! and Setlings\EMdr^DesktopUN.


: \ inetpub!.wwwrootWB WebApp
C:\Documents and Setthgs\Brian\DesktopUN.
C:\Documents and Settings\aian\[>esktcipMN.

ebSer.

<

Help

. 2-14.

', I,

Visual Studio .NET


, .
, , ,
, - . Visual Studio .NET
Project Dependencies (ProjectsProjectDependencies) (, 2-15),
, .
. (
, Visual Studio .NET
.) , Web- XML,
, Build Order.

DopenffeiKies | Bu&f Order

CPPWin32
CSWehGervice
G CSWinApp
G SstupPpplicatlcn

VBWebAfp

."..". VeWinApp
i ) VJConsoleApp

2-15-


, ,
. Configuration Manager (. 2-16). , , ,
.

. B;itch Build (ProjectBatcbBuild)
, Web (. 2-17).
Batch Build ,
, . Build
,
. Rebuild Rebuild All
. Clean , -

2 Visual Studio .NET

47

,
. : Visual Studio .NET Clean
Visual Basic .NET Visual C#.
Visual Basic .NET Visual C# ,
.
Unit 1| ,ii in Manager
Solulran

project corf kjurattow to bufc) or deploy):


i

. _ _ |

CPPWin32

PostCMD

Win32

C5WebApp

Release

,NET

CSWebService

Release

.NET

CSVrtnApp

Debugl

Setup Application

Release

rlatfo-m _

Release

Close

Help

. 2-16. ,

Chedi the prelect configuration! to build:

!'T!^IL^:
j CWInflppl

Debug

.NET

Debug

CSWinAppl

Release

.NET

Release

CSWinApp2

Debug

.NET

Debug

tl

&ebwfcl
dean

Release

Deselect All

. 2-17. Batch Build


Visual Studio ,NET , IDE IDE.}'{ 3 .

3
Visual Studio .NET

L . , Microsoft Visual Studio .NET


. , Visual Studio .NET. , , (IDE), Visual Studio .NET .

IDE
Visual Studio .NET , . Visual Studio .NET
. ,
, , IDE.
(Code Editor) . ,
IDE, . ,
, ; , , Web- .
Visual Studio .NET 7.0 7.1 , (outlining), .
,
Command Window (Ctrl+Alt+A) , . , Visual Studio .NET.

3 Visual Studio .NET

49


- IDE . -
IDE ,
Dockable Window.
(Object Browser) (Ctrl+Alt+J) ,
- IDE. - IDE , >
.
, , ,
Dockable, ,
.


, , Visual Studio .NET
. ,
Visual Studio .NET , ,
, (Code Editor).
, IDE.
,
IDE, (Text Editor), , , ,
, , , . , .
. 3-1 IDE: ,


-|
1"}

-^

elscry r.Hs Aflci-ln.


L'fi

~1 Toa chonr;
i i i*J.B'
7-r-gi3ter iBe XtlO-in jiy ijuiiaine

: ;sstais ptc.!^

STDMETHOEIBT

pApplication->Query Interface!

. 3-13-1116

uuidDf (EnvDTE: : i>TE) .

ILPVOID'l Cai_l-DTtl :

50

I Visual Studio .NET

. ,
, , .
, , , ,
, .
(Navigation Bar) . Visual C# (Types) (Members).
Visual Basic .NET (Class Name) (Method
Name).
. Visual Basic .NET .
.
+ -, , /
(. ).

(Margin Indicator Bar) .
. ,
, , - , -. , (. 3-2). , , .
( .)

.

. 3-2.
,
,
. .

, . -

3 Visual Studio .NET

51

. ,
.
,
. . (MDI), Visual Studio 6,
Options.
, , , .

:
,
(Code Editor), (Designer),
(Solution Explorer) (Class View).
, . Ctrl+Alt+1, Solution Explorer.
# Enter. Windows- Web-, ,
. ' '
#-, F7. , - , ,
'> SliifHF?.
Ctri+Ait+L, Solution Explorer,
Enter.
, IDE. CtrRTab Ctrl+F6,
-...., , Class View, CtrH-Shift+C.
IDE,
,


.
, , Web- ,
. ( - ,
Visual Studio .NET !)
, , , , .


, Microsoft Windows,
, , . CUA- (Common User Accessibility),
, IBM

I Visual Studio .NET

52

. :
, Windows-,
Microsoft Office. ,
Microsoft.
Windows . Microsoft Windows
User Experience (Microsoft Press, 1999).
Visual Studio .NET (. 3-1):
. 3-1.

New

Open
Save
Save All
Print

Ctrl+N
Ctrl+O
Ctrl+S
Ctrl+ShifH-S
Ctrl+P


FileNewPile
Ftte.OpenFUe
FileSaveSelectedltems
FileSaveAll
FilePrin!

New File.
, . ,
, . ,
(Command Window) , . , LJserMotioacpp, Ctrl+Alt+A, , File.NewFile UserMotion.cpp. , ,
, , 4 , ,
Ctrl+N.

, . , (. 3-2).
Shift,

Ctrl.
. 3-2.

()
-
-
Ctrl-t- -
CtrH--
End
Home
-
-


Shift+ -
Shift+-
Ctrl+Shift+-
Ctrl+Shift+ -
Shift-bEnd
Shift+Home
Shift+-
Shift+-

3 Visual Studio .NET

. 3-2.

()

53

()
Page Down
Page Up
Ctrl+End
Ctrl+Home


Shift+Page Down
Shift+Page Up
Ctrl+Shift+End
Ctrl+Shift+Home

, .
(. 3-3):
. 3-3.

Ctrl+X

Edit.Cut

Ctrl+C

Edit.Copy

Ctrl+V

EditPaste
EdiWndo
EditRedo
EditSdectCurrentWord
EditSelectAll

Ctrl+Z
Ctrl+Y
Ctrl+W
Ctrl+A

:
. Clipboard Ring. - .
. , , , . , -.
Ctrl+Shift+Insert Ctrl+Shlft,
. : , Insert .
Insert s , ,
. ( .) Insert , , .
.
(. 3-4). , , Ctrl+T
* *,
Ctrl+Shift+T .
EditLineTranspose. Alt+Shift+T

I Visual Studio .NET


, , ,
.
. 3-4.

Ctrl+T
Ctrl+Shift+T

Alr+Shift+T


Edit.CharTranspose
EditWordTranspose
EditLineTranspose


Dockable ,
IDE, WindowDockable , , .
IDE ,
(Ctrl+AIt+A) Tools.Options.
Options (. 3-3). Jinvironment Keyboard,
Keyboard. IDE: , .
IDE - .

nvironment
General
Doomnents
Dynamic Help
Fonts and Colors
Help

Sr-ow iOf^mands containing:


fdock

International Settingi# Keyboard


Projects and ScJution
Task List
Web Browser
Source Control
Text Editor
L3 Andyier
[ Database Tools
U Detooging
&& Device Tools

. 3-3-

Sho^cut^s) |Or jebctE tf catimaiid;

Use Qew sttortwt n:


JGJobai

g-tss shortcut beyfc):


-ifori+Tctrl+D

Assign

ShertcutcurrenayuseiJby:

Keyboard Options

, , Show Commands Containing.


dock, Window.Dockable.
. Visual Studio .NET . ,

Visual Studio .NET

55

, . ,
. , ,
.
Visual Studio .NET (chorded
shortcut). , Ctrl . IDE , , . , Ctrl+, (Ctrl+) Visual
Studio .NET . -
,
, . WindowDockable
Ctrl+,, Ctrl+D (Ctrl+, Ctrl+D), Press Shortcut Key(s). Assign, .
Options,
Options, Show Commands
Containing Tools.Options Ctrl+,, Ctrl+O IDE ,
.
[DE,
, .
Keybindings Table
, Visual
Studio .NET, , Options . , ,
IDE .
Web- Visual Studio .NET hup://
msdn.microsqftom/vstudio/doiimloa(is/autornation.asp. C++,
, Visual Studio .NET Visual C++ .NET. Visual Studio .NET .
Visual Studio .NET, IDE .
Visual Studio .NET Help . Keyboard Help (. 3-4).
Keybindings Table
, IDE,
. , .
, Ctrl
. Microsoft Excel,
.

56

I Visual Studio .NET

6 Keyboard Help

(f<Cj

> 1 View JBoundCommaridi


:

.,--,.,;!-,-!!,-,-;,.-

Build BuldSdution
Build. Cancel
Build Compile
Dal abase. Run
D a 1 abase. R unS el ection
Daiabase.Steplnto
Debug App^iCodeChanges
Debug. Autos
Debug.BreakAII
Debug Breakpoint
Debug CalStack
D ebug. CleartIB i eakp oinl s
Debug. Disassembly
Debug EnableBreakpoint
Debug. Except ions
Debug Immediate
Debug. Locals
Debug. Memory!
Debug. Memory2
Debug. MemoryS
Debug. Memoi)4
Debug. Modules
D ebug. N ewB reakpont
Debug. QuickWalch

. 3-4.

_*]
1 Ke'Brnding

Scope
Global
Global
Global
Global
Global
Global
Global
Globa
Globa
Globa
.
Globa
Globa
Globa
Glob

Chl+Shft+B
D[l*6reak
ClrltR
Drl+E
DrltQ
AK-F5
Alt-FlO
Dil+AKW.A
Drl*AK+Bieak
Drl+AbB
Clrl+AK-C
1 Dil*ShilH-F9
CtrltAlt'D
Orl+F9
Pil-Att*E
Cli i- 1 ir|
CltHAINV, L
CM+AlttM, 1
CtrltAII+M, 2
QrlAlttM.3
Dri+AII+M.4
CMwW+U
QrltB
Shi't+

i , ,

Globa
Globa
Globa
Globa
Globe
Globa
Globa
Globa

Keyboard Help


. , IDE Visual Studio, Options Text Editor.
(All Languages), Text Editor (. 3-5).

jyj Environment
5ource Control
Text Editor
General
*2J All Languages
Gerierd
^ Tabs
j Baiic
C*

Indenting
!

i! selecBons cortfSct.

'' Stock

* Smart

Tab size:
Indent size;

[7

j HTML/XML
:
|
3 PL/SQL
Jj Plain Text
SI T-5QL
03 T-5QL7

3-5.

i This page sets option; for al languages, Tochange options For only
language., setect fee de sred tangyage From the bee on bhe foFt.

, Indenting () None,
Block Smart.

3 Visual Studio .NET

57

Tabs. None, Enter , . Block, , .


, ,
. Smart . , # Enter
({)
.

. ,
, , IDE. ,
, Visual C#
.
(white space), ,
Edit.ViewWbitespa.ee (Ctrl+R, Ctrl+W). . 3-6 , . -, .
ClaSSl.es ]

-*
-i

. 3-6.

[ STAThread]
static-void..Henn[stnng[] -ergs]

, ,
, , , Tab;s Options , , . , Ctrl+A. Ctrl+K, Ctrl+F
{EditformatSelection), .
Formatting Options (. 3-7).
, IDE. Basic -

I Visual Studio .NET

58

VB Specific. #.

Indentation

.....................

" Leave open braces on same Ine as construct


P' Indent case labels
S? &utamatica8y format jmptetsd constructs and pasted KWCo
$r Sraert comment editing
OuSnjng
I? Enter outfewig mode when Fies open
1

y oHapse tfretfon bfeek whw files apen

InteiseflSe Msrr
S* IntetHsense preseterts rrp*t frequently used-membefs
dear ftstay

Cancel

. 3-7-

Help

Formatting #

. Leave Open
Braces On Same Line As Construct (. 3-7). # .
, , . :
static void Main(string[] args)

// TODO: Add code to start application here

Leave Open Braces On Same Line As Construct ,


, K&R.
.
:
static void Main(string[] args) {

// TODO: Add code to start application here

I
, , EditFormatSelection.
, , , #
, K&R, , . EditformatSelection, -

Visual Studio .NET

. EditFormatDocument,
. ,, Leave Open Braces On Same Line As Construct, ,
.

,

( )
. , IDE,
.


, ,
Fonts And Colors, Environment
Options. , IDE (. 3-8): , , ianpo .

^ tndfcates fixed-width forts)


Help
International Setting;]
Keyboard
Projects and Solution'
Task List
E-rowser
^j Source Control
Text Editor
CJ
|^j Database Took
|Ci3 Debugging
Li3 Device Tools

. 3-8-

Iterr foreground:
I Selected Text
j Inactive 5el acted Text
Indicator Margin
I Line Numbers
iVisible White Space
1 Brace Matching

; Automatic
iterr background:
ID Automatic

Custop)..,

Sample:
AaBbCc&rYyZz

, , Display Items (Item Foreground) (Item Background).


, Bold. Text
, ,
, , ;
, . , Auto-

60

I Visual Studio .NET

matic Item Background Item Foreground,


Text. , . 3-9 Text
. Comment, , Automatic, Dark Green (-). ,
.

Environment
Genera!
Documents
Dynairic Help
$> Fonts and Color;
Help
International Settings
Keyboard
projects and Solution'
Task List
Web Browser
Source Control
Text Editor
/
ataba?e Tools
i_j Debugging
Qj Device Toob

. 3-9-

Rtnt (bold type indicates fixed-width fontsji


I Courier New

Custom...
|t_ompiler Error
CSS Property Name
CSS Property Value
iCSS Selector

Sample:

Fonts And Colors ,


IDE. , 3- , Dialogs And Tool
Windows . , Visual Studio .NET , Use Defaults
Fonts And Colors.
, -
IDE. Show Setting
For Printer , . Use Use
Defaults,
. -
, , , . ,
. , Text
Editor Settings (. 3-).
, . ,
. . 3-12 , ,
Fonts And Colors . , .

3 Visual Studio .NET

61

L i d e n t i f i e r type chancie
L operator
L s e p a r a t o r character
L- o p e r a t o r
identifier t*pe characte
separator character
Const d i r e c t i v e
Is* d i r e c t i v e
HE I s e l f d i r e c t i v e
tEnd It d i r e c t i v e
*E*t*rnalSource d i r e c t i v e
TIF ... B E N D I f preprocesso
It directive
K i t . . . Then..-HEIse d i r e o t i
X

identifi
identif i
opeiator
identifi
operator

. 3-. Index
Dialogs And Tool Windows

. 3-11. ,
1 1 i g X i a :i j '. s h t \ ' t j \ Ad d I

//Copy til)'* )"> KicEoaoIt CtHtporetioo.

All right ieerTd.

// Addln.cyp : Irapl(Bnntaeio!i of DLL Siporut.

. 3-12.


IDE, ,
. Regedit REG-.

I Visual Studio .NET

62

Visual Studio .NET 2002


HKEY_CURRENT_USEfl\Software\Hicrosoft\VisualStudio\7.0\FontAndColors

Visual Studio .NET 2003


HKEY_CURRENOSER\Software\Microsoft\VisualStudio\7.1\FontAndColors

REG-
Regedit. IDE,
.
no-Mtcrosoft'oBCKM
, Microsoft , , , ,

Windows, , . Microsoft
: ( ), ,
. (, - j:
.) , .
.
- , ,
,


, Text Editor,
General Options.
. Options.
, ,
. ,
Visual Studio .NET, / . : , ,
.
Macros.Samples.UtiUties.TurnOnLineNumbers
MacrosSampls.Utttities.TurnOffUneNumbers.
(InteiHSense) ,
,
. TumOnLineNumbers,
, Ctrl+Alt+A, :
>alias

Inon Macros.Samples.Utilities.TurnOnLineNumbers

3 Visual Studio .NET

63

, Inon, (
). ,
TurnOffLineNumbers, :
>alias Inoff Macros.Samples.Utilities.TurnOffLineNumbers
TurnOffLineNumbers Inoff.
, . : Numbers Keyboard Environment Options. ,
, Assign.
: TurnOnLineNumbers Ctrl+,, Ctrl+N (N ), TurnOffLineNumbers Ctrl+,, Ctrl+Shift+N. . 3-13 ,
, .

Keyboard mappHg scheme;

^3 Environment
General

I Brian's Shortcuts

Documents
Dynamic Help

Show tBTimande containing;

Fonts and Colors


Help
International Setting?
f Keyboard
Projects and 5olution:
Task List
Web Browser
Si Source Control
L.EI Text Editor
' Analyser
j Database TOP|S
Qj Debugging
LJ Device Tools

: numbers
* M a cr s . 5 amples . Utilities . TurnOnLineNumber s

9wrtajt(s) for setected command:


BeroCWt

"|ari+7ctrM^hlrt^^
Use QBW sharteyt ire
|aobal

PressshoftcLEkeyfs);
~~23l

Shortcut (1 usedfey:

Hefo

. 3-13-

TurnOffLineNumbers

, / ,
, ? , . ,
. , Visual Studio .NET Customize. Customize Commands Macros,
Samples.Utilities.TVirnOnLineNumbers .
, .
, ( Customize ). Turn On Line Numbers.
TurnOffLineNumbers (. 3-14).

I Visual Studio .NET

. 3-14.

TurnOffLine Numbers

, , , .

(outlining) . . 3-15
, .
. , , .
, Ctri+M, Ctrl+P (EdttStopOutlining).
. Ctrl+M, Ctrl+O
(Edtt.CoUapsetoDejmitions). CollapsetoDeftmtions
. Ctrl+M, Ctrl+L
(Edit.ToggleAllOutUning) .
, .
Ctrl+M, Ctrl+H (EditHideSelectiori).
. , Ctrl+M, Ctrl+U (EditStopHidingCurrenf).
, , (. 3-5).

3 Visual Studio .NET

clon(IDlspaloh

: iOnCc
HPESULT hr - a OK;

pAddlnlnat->QuEryInterface ; uuldot (EnvDTE: ilOdln), (LPVOID'J (m_pjLd[iIn Instance);


If(ConnectHade -- 5]
/5 1 !)
(
H<E5<JiThr-5_C;
T

] iff STWIITHODIHF CCon icct


j -jiSSTMIITHODIIIP CCon aect

OnP:

CCOTiP'-^offictiiCwiridriEflnjinlrol^pcommandBaiControl; aconnectHode / "?fuib^ ;


CComPtr<EnvDTE:: Command^ pCreflteOCofiyfifiridi
CCom<Officp::Conimandeflr>pMaiuBefCo(nmeriifiir;
"-

jr.- STDHETHODIHP CCon Met


S .|fj. CCon lect
|'V. STBHETHODIHP CCan npcc-

OnBl /(U*<Jfl-TAMT'...
Ouery3totu3 (B5TR , EnvCTE: :-/1 1
Exec [B3TR be^cCaiOMaire, nvDTE: ivaCoicfEiaridExeoOption CMecuteOption^

1
|

;,;

"t
<

~ --^
+f

*J
.

..

'

cdi

thi

IN,

. 3-15. /2(3 ,

. 3-5.

Ctrl+M, Ctrl+P
Ctrl+M, Ctrl+L
Ctrl+M, Ctrl+M
Ctrl+M, Ctrl+H
Ctrl+M, Ctrl+U


Ee&tStopOutiming
Edit.ToggleAllOutlining
Edit.ToggleOullmingMxpansion
EdtiHideSelection
E4itStopHidingCurrent

Visual Studio .NET ; F1. , .


F1
1 , .,
Visual Basic ,
(-, Visual Basic 4).
, . ! 10 , , ?* ~
. F1,

66

I Visual Studio .NET

(IntelliSense) , - , . API, ,
.
, , . , ,
.
, .NET Framework , .
Web- XML, .

: , , .
, . . , IDE, , . : , ,
. ,
, .
, , . , . , Text Editor
Options. , ( All Languages, ),
General Statement Completion Auto List Members.

(Parameter Information).
,
, Hide Advanced Members.
Visual Basic .NET , , .

.
, Ctrl+J (. 3-16).
, , - *, Tab.
Formatting # Options
Visual Studio .NET 2003 , Visual C# .

static v o i d M a i n ( s t r i n g [ ]

Visual Studio .NET

67

/ / : Add code to start explication here


Console.!
EfErrcr
Bffln
^ Open5tandardErrot
*-* Open5tandardlnput
--* OpenStandardOutput

?;

- Read
-i* ReadLine
- ReferenceEquals

::.
,

. 3-16.

Ctrl+J

, .
3-17, Ctrl+Shift+. . -
.
1

static void Bain(stnng[]

arga)

fl TOOO:

Add ode to statt application hen

//inc
Console.Write(
117 of 13 void Consde.Write (string format, object atgO, object argL)
Format: The format string.

. 3-17.
Ctrl+Shift+
, ( ), .
.

.
,

. ,
. Alt+- ,
Ctrl+J.
, , , ,
, . Quick
Info, , . . , Ctrl+K, Ctrl+I.
Visual , -

'

I Visual Studio .NET

, ///. ,
, .


. Visual Visual
C++ , .
(), [] {} .
#if, #efoe #/ .
, ?
. , Fonts And Colors Environment Options.
Display Items Brace Matching. Bold
Foreground Background Automatic,
. , ,
.


, , Visual Studio .NET.
IDE, , ,
IDE. , ,
.
, ,
IDE. Visual C# Console,
(. 3-18).
System.Console. : ,
Ctrl+Alt+F3 (HelpSearch) , .
Help

Console Members

Code and Text Edtor


Csdinn T>chniqij&s grid Programming Practices
Smart Device Projects
Samples
Visual c# Samples
Smart Device Sanries
Visual Studio Samples
Getting Started
Visual Studio Walkthroughs
Oynwrtc Help

. 3-18.

3 Visual Studio .NET

69

, - IDE, (Properties), . ]
.
Ctrl+Fl. , IDE, ,
. -
, , ,
. - F1, .
Ctrl+Alt+F3 , . , , Ctrl+Fl , . 90% .


Vim (Vi improved) , Visual
Studio .NET .
Keybindings Table, .,
IDE 1100 . 400
. ,
.
Visual Studio .NET . (Command Mode) . ,
(Immediate Mode) ,
, . : immed , >cmd . , (?):

>? i
:
>? i = 7
7
>? i + i
14

, (>):
i
7
i +1
14
>Edit.Find i
>immed

70

Visual Studio .NET

,
.
immed. , EditFind,
.

els .
. , .

Visual Studio .NET


IDE. , ,
, , *
(.) . , ,
(Ctrl+Alt+A). Find,
Edit.Find. ( EditFind)
. , .
, . EditFind. , . Edit.Find , . , Vi (\). EditFind :
>alias \ Edit.Find

, ,
. \
.
>\ main|args /regex
\ :
( ).
.
, ( . 4).
Visual Studio .NET Ctrl+Alt+A.
Find Standard,
Ctrl+D (Edit.GoToFindCombo). Find
.
(>), ,
, .
, Find , , (. 3-19)

Visual Studio .NET

File.NewBlankSolutkjn
Fite.NswFile
FJe.NewProject

. 3-19- Find

,
, . Visual Studio .NET , .
,
Visual Studio .NET.
Common User Accessibility (CUA), Windows Office
Find, Ctrl+F (. 3-20). Find (Match
Case), (Match Whole Word) (Search Up),
(Search Hidden Text).
, , .
Find what;

~
~ Match sshote word

Search
''' Curren

" Search hkifeti text

^~ Al documents

f~ Search yp

^' Current 0roct


!* Onfct MSenEx.Classl
help

. 3-20. Find
Find , IDE , Dockable ,
, - IDE.
Find, IDE. , .
,
Floating ( Close
). .:
.
Replace (. 3-21) Ctrl+H.
Find, (Replace With).
, .
, , .

I Visual Studio .NET

tt*tir

jengme

" Match case

Search

f" Match [hole word

^ Current do

* Search hjdden text

<" (Hspendocumerts

f Current prefect

Search

Mark All

Hefe

. 3-21. Replace
Find and Replace (Ctrl+Shift+F) (. 3-22)
Replace In Files (Ctrl+Shifc+H)
. ... Look In, : , . Find In Files Find Results.

. 3-22. Find in Files


Visual Studio .NET (. 3-6):
. 3-6.

Find
Replace
Find in files
Replace in files

Ctrl+F
Ctrl+H
Ctrl+Shift+F
Ctrl+Shift+H


EditFind
EdttReplace
EdilFindinFiles
FileReplaceinFiles


Use Find and Replace (wildcards)
. , Wildcards . .
, . ,
01, 02. , H03XD04 . ., ,

Visual Studio .NET

73

, #,
, ?,
. , , Find Use
Wild Cards. ?0# '
- ).

. '.
, ,
, , : '. , < >
.
, ' , , . , class
/', class Class 1. , , , ,
, , , .
, , [!]. , , ,
, ?0#, , . [!]0# .
[ ] , , . , D,
: H03X[AD]0#.
, ,
, , ,
. ,
Visual Studio .NET (. 3-7):
. 3-7. , Visual Studio.NET

[! ]

[]


.
Visual Studio .NET, , ,
. Visual Siudio
,NET 70 -

74

Visual Studio .NET

, . , Use
Regular Expressions Use.
- [ ] .
, . ,
d Find What [a-d]. [a-d]b
ab, bb, ch db.
, , , . [" ]
. , ft-vjs as, bs, cs, ds, ts,
us, vs . . .
- ,
. S . : < , > . . , int, <mt. , int. To
integers int, mint . , int , >.
.
, . ,
#-, MessageBoxSbow , ;
<MessageBox.Show\(:q|(<,>)\);

,
. , < . MessageBoxSbow , .
\ , ,
. :q . ((**)\'))- | :q , MessageBoxSbow , ,
<> . . ,
. , , .
, ,
. , ,
,
(white space), . :Wb ', ( ) .
: <MessageBoxShow\(:(j\(<.>):Wh*\);. -

3 Visual Studio .NET

75

, : <MessageBoxSbow\(
Wb':f^(<.>):Wb'\);. ?!
. Mastering Regular Expressions*, Jeffrey E. E Eriedel
(O'Reilly, 1997) Writing Secure Code, Second Edition, Michael Howard David
LeBlanc (Microsoft Press, 2003)'-
, .
. 3-8 , .
. Visual Studio .NET ( Help Find , Visual Studio .NET).
. 3-8.

[]
/7
< >

$
I

:q
:Wh

. - (),
.
, .
.
.
.
,
.
, .
.
.


.
, .
Find , Edit.Find , , Enter.
, ,
. , ,
:
Edit.Find

Class /Wild

Find
Find. ,
, Find.
, , Edit.Find /options:

^. *. : *, 2003. , .

76

I Visual Studio .NET

>Edit.Find /options
/wild /doc /names /sub
,
Find Visual Studio .NET (. 3-9).
EditJleplace, EditFindinFiles EditJKeplaceinFiles.
, help Edit.Find.
. 3-9. Find

/case
/doc

/hidden
/markall
/open
/options
/proc
/set
/up

/regex
/wild
/word


/
/d
/h
/m
/o
/t
/P
/s
/u

/1

/w

EditFind /reset, . , .


.
, .
, Ctrl+I. , (. 3-23).
.
, . , , Ctrl+I.
, . Ctrl+I, ,
.
, Ctrl+Shift+I. .
, Enter Esc.

Visual Studio .NET

77

//THPORTMJT'

,'.' Elding l-Le SCJUL-^P? coda i.o yjur juiii-in.


/ / 1 <

. 3-23-

Ctrl+I


IDE,
IDE ,
, . 4 , IDE .

4
Visual Studio .NET

. Microsoft Visual Studio .NET , ,


. , , .
Visual Studio .NET.
Macros IDE.
, .NET
. ,
(add-in) Visual
Studio .NET, , Visual Studio .NET.

: Visual Studio .NET


Visual Studio .NET Visual Basic .NET. , Visual Basic Scripting Edition (VBScript), Microsoft
Visual C++ 6.0. Visual Basic .NET .NET
Framework , , IDE. Visual Basic .NET,
.
1, Visual Studio .NET
.vsmacros VSMacros71,
Visual Studio .NET. Visual Studio .NET Options Projects and Solutions
Environment. My Documents\Visual Studio Projects.

Visual Studio .NET

79

Visual Studio .NET .


IDE (Ctrl+Shift+R); ,
, MyMacrosRecordingModule.TemporaryMacro. : Macros IDE (Alt+Fll) .
,
Visual Studio .NET IDE. ,
, .
Visual Studio .NET.
IDE , . Command Window (Ctrl+Alt+A),
, , , Macro
Explorer, Macros IDE.
Macro Explorer, . ,
, Macro Explorer,
,
.
Visual Studio .NET
.
. IDE, . , .

.


Ctrl+Shift+R Recorder (. 4-1) RecordmgModule, . : ,
.

**%
. 4-1.

Recorder


. , Connect .
Find Find In Files. , ];
, ,
.

80

Visual Studio .NET

.
1.
2.
3.
4.
5.

Ctrl+Shift+R, .
Ctrl+F, Find.
Connect Find What.
Find Next.
Ctrl+Shift+R, .

TemporaryMacro, RecordingModule
(. 4-2).
Map in Fxplorer
3 Macros
!+' - InsldeVSNET
!- -
1
S. Si MySevedMacros
'-' j RecordingModule

. 4-2.

Macro Explorer

, .
, (, Tab
Replace) . Visual Studio .NET
, .
Imports EnvDTE
Imports System.Diagnostics
Public Module RecordingModule
Sub TemporaryMacroO
DTE.ExecuteCommand("Edit.Find")
DTE.Find.FindWhat = "Connect'
DTE.Windows.Item("Connect.cpp").Activate()
DTE.Find.FindWhat = "Connect 1
DTE.Find.Target = vsFindTargot.vsFindTargetCurrentDocument
DTE.Find.MatchCase = False
DTE.Find.MatchWholeWord = False
DTE.Find.Backwards = False
DTE.Find.MatchlnHiddenText = False
DTE.Find.PatternSyntax = _
vsFindPatternSyntax.vsFindPatternSyntaxLiteral
DTE.Find.Action = vsFindAction.vsFindActionFind
DTE. Find. ExecuteO

Visual Studio .NET

81

End Sub
End Module
, Ctrl+Shift+P MacrosMacrosRecording^odule.TemporaryMacro. Find .
Connect Connect.cpp,
DTEWindowsltem(Connect.cpp)Acttvate(). Connect.cpp , IDE, ,
. ,
.
, TemporaryMacro
Macro Explorer
.


Macro Explorer IDE Visual Studio .NET.
, , IDE Macros
Tools Macro Explorer.
, , .
Macro Explorer
Macro. Macro
.
, Command Window. ,
(, 4-1):
. 4-1.

ToolsLoadMacroProject
TooisJVeti'MacroProject
ToolsMacrosIDE

Add Macro Project,


.
New Macro Project,
.
Macros IDE.
AH+F11.

Macro Explorer AH+F8.


, Macro Explorer,
Command Window ( Macro Explorer , Command Window).
, Macro Explorer, Ren ame.
. Delete .
Macro
Explorer,
, (. 4-2):

4-1116

82

Visual Studio .NET

. 4-2.

ToolsNewmodule
ToolsJVewmacro
Toolsdit

New Module,
Macro Explorer.
Macros IDE .
Macros IDE .

Macro Explorer
. Run ToolsJtun , Rename .
Macros IDE. Delete , a Edit Macros IDE.
Macro Explorer, Macros IDE.
, , IDE! , ,
IDE , .
Visual Studio .NET, Macros IDE.

Macros IDE
Macros IDE Visual Studio ,NET.
Macros IDE. Macros IDE
IntelliSense, IDE.
: Project Explorer. Visual Studio .NET , , Samples
Project Explorer Macros IDE (. 4-3).
,
,
, .
, , , , ,
Samples , .
, IDE Visual Studio .NET.
New Macro Project
Macro Explorer Tools.NewMacroProject Command
Window, New Macro Project (. 4-4).
.
Alt+Fl 1, Macros IDE, .

Visual Studio .NET

83

utmtjej
ptutmtlef
InsidtVSNET
lyM

. 4-3-

.
'. \-

"j-j | lM4pdJf*ieiKiiment
DTE.find.FindMhat - ta.Texc
End SuJj

Samples Macros IDE

Waffle;

'i TextMacros

Lccation.'

| D:\My Docijments^isud Studic Projects \V5Macros 71

Open

Help

. 4-4. New Macro Project


Project Explorer, ,
. References References IDE Visual Studio .NET. ,
: EnvironmentEvents , IDE, Modulel
.

I Visual Studio .NET

: IDE
Macros IDE IDE Visual Studio .NET, Visual
Studio Macros IDE. B Visual Studio .NET
, , .
Macros IDE . ,
IDE Visual Studio .NET, Customize.
Commands Tools Macros IDE
, . , rosIDE . .;' IDE, .
,
, Macros IDE, a
Visual Studio .NET.
Visual Basic .NET. Add Reference, Macros IDE Project Explorer (. 4-5). .

__]_
System, Security
System , Servic e P rotes s, dl
System, Web.d
System, Web. Mcbile.dll
System. Web , RegularExpr e s si.
System. Web, S ervices. dll

1.0,5000.0
1.0.5000.0
1.0.5000.0
1.0.5000.0
i,0.5000.0
1,0,5000,0

C:\WINDC'WS^Mfcrasoft.NET,..
C:\W1NDC WSlMicrosoft.rJET...
C:\WINDt'WS\Microsoft.NET,..
C:\WMX >WS\Mtrosoft.NET...
C:\WINDC'WS\Micro5oft.NET...
CilWJNDC'WSlMitrosoft.NET.,,

5ystem.Xml.dll
VJSBrowserStiilib

1,0,5000.0
L.0,5000,0
1.0.5000,0
7.0.5000.0

C;YwifCCW5\Mii:rosoFt.MET..,
C;\WWDC'WS\Mto-osoft.NeT...
C:\WINDCW544icrosQft.NET...
C:\Wir\DC WS\Micro5oft.NET...

V JSharpCodePravider

Select

Tyoe

. 4-5-

Add Reference

,
C:\Program Fi!es\Microsoft Visual Studio .NET 2003\Common7\IDE\PublicAssemblies.
Add Reference. , , . , , ,

Visual Studio .NET

85

COM . , .


FileNewFile Visual Studio .NET. , ,
, . : , , Command Window. , , TDE :
Imports EnvDTE

Imports System.Diagnostics
Public Module NewFile
Sub NewTextFileC)
DTE.ItemOperations.NewFile("General\Text File")
End Sub
End Module

, NewFile
NewTextFile.
Text File General New File. NetvFile,
, . ,
, IDE.
, , .
, .
: Macro Explorer IDE Visual Studio .NET.
, . : Command Window. , , .
, alias, . IntclliSense , , , ,
:
>alias nf Macros.InsideVSNET.Chapter04.NewFile.NewTextFile
/ Com. nand
Window. , Ctrl+Alt+A tn nf. , Options . ,
Ctrl+,, Ctrl+,, Ctrl+N. , (. 3).

86

I Visual Studio .NET

Imports. API
Visual Studio .NET EnvDTE. . 5-12. ,
. , , , . . ,
IDE. , , ,
.


IDE. IDE.
, . .


, , , . , , Document
DTE , .
, . IDE DTEActiveDocument,
Document. (: Visual Studio .NET
, IDE.)
, TextDocument.
TextDocument , ,
: StartPoint TextPoint,
, EndPoint , , a Selection TextSelection, .
TextPoint
. TextPoint ,
. TextPoint
,
.
, . , .

4 Visual Studio .NET

87

ActiveDocument, EditPoint
ActiveDocument :
Sub CommentWholeDoc()
Dim td As TextDocument = ActiveDocument.Object
Dim sp As TextPoint
Dim ep As TextPoint
sp = td.StartPoint.CreateEditPointO

ep = td.EndPoint.CreateEditPointO
sp.lnsertC'/* ")
ep.Insert(" */")

End Sub
Visual C# Visuaj C++
, . , , .
IntelliSense, .
:
HTML-.
Visual Studio .NET 2003, , . ts TextSelection ,
DTEActiveDocumentSelection-.
Sub HTMLCommentO
Dim ts As TextSelection = DTE.ActiveDocument.Selection
ts.Insert("<l- ", vslnsertFlags.vsInsertFlagsInsertAtStart)
ts.Insert(" ->", vslnsertFlags.vsInsertFlagsInsertAtEnd)
End Sub
TextSelection Insert
Selection. Insert ; ,
, vsInsertFlags,
. Insert vsInsertFlagsAfStart,
vslnsertFlagsAtEnd. . 4-3.
. 4-3. vsInsertFlags

vsInsertFlagsCollapseToStart
vsInsertFlagsCollapseToEnd
vsInsertFlagsContainNeivText
vsInsertFlagsInsertAiStart
vsInsertFlagslnsertAtEnd


TextPoint.

TextPoint.
.
.
.

88

Visual Studio .NET

Selection TextPoint, , DTE, ,


.


Visual Studio .NET Window DTE Windows. , Window, . ,
Window CommandWindow, OutputWindow, TaskList, TextWindow ToolBox.
OutputWindow . , print/ Console.Write MsgBox MessageBoxShow Windows-.
OutputWindow , , .
,
MsgBox. MsgWin, )'.
MsgBox, .
Sub MsgWin(6yVal msg As String)
Dim win As Window = DTE.Windows.Item(Constants.vsWindowKindOutput)
Dim cwin As Window =
DTE.Windows.Item(Constants.vsrtindowKindCommandWindow)
Dim ow As OutputWindow = win.Object
Dim owp As OutputWindowPane
Dim cwp As CommandWindow = cwin.Object
Dim i As Integer
Dim exists As Boolean = False
' , Command Window.
' , .
, Command,
If (DTE.ActiveWindow Is cwin) Then
cwp.OutputString(msg + vbCrLf)
Else
, .
, ,
.
For i = 1 ow.OutputWindowPanes.Count
If ow.OutputWindowPanes().Item(i).Name() = "MsgWin Output" Then
exists = True
Exit For
End If
Next
,
,
.
If exists Then
owp = ow.OutputWindowPane;;(). Item(i)

4 Visual Studio .NET

89

Else
owp = ow.OutputWlndowPanes.Add("MsgWin Output")
End If
1
Output , ,
,
win.Visible = True
owp.Activate()
owp.OutputString(msg + vbCrLf)
End If
End Sub

MsgWin , ,
Visual Studio .NET. ,
Command Window. ,
Command Window. , , , MsgWin
Output MsgWin Output.
Samples, Visual Studio .NET,
, .
MsgWin, . , IDE :
Sub MsgWinTestf)
Dim wins As Windows = DTE.WlndowsO
Dim i As Integer
For i = 1 To wins.Count
HsgWin(wins. Item(i).Caption.ToStringO)
Next
End Sub

. 4-6 IDE Visual Studio .NET MsgWmText


IDE.
MsgWin . MsgWin, ,
. MsgWin , :
Sub MsgWin(ByVal msg As String, ByVal clr As Boolean)
' clr True, .
If clr = True Then
owp.Clear()
End If

' Output ,
' ,
win.Visible = True

I Visual Studio .NET

90

owp.Activate()
owp.OutputStringCmsg + vbCrLf)
End If
End Sub
spfl DeuelopriiPiH Cnvtroiu
fS&tj

Jaeb

*AutoHideTogglF
US CMKtBd D^p^nds
-Jl ,*
aTemp 1= Nothing Then
1

If ce rn nr,4 in th

!; j li

Output
IxplOi

lit

tdl

. 4-6. OKWO MsgBox Output IDE


, ,
, MsgBoxTest , .

, .
CommandWindowPaneEx.


, ,
. -,
.NET, , ,
.
-, , Visual Basic,
, , , . ,
, Visual Basic: .
,
. Utilities, , Utilities. OutputWindowPaneEx,
InsideVSNET.Utilities.dll bin\debug

Visual Studio .NET

91

C:\Program Files\Microsoft Visual Studio .NET 2003\Comrnon7\IDE\PublicAssemblies.


Public Assemblies,
Macros IDE, References Project Explorer Add Reference
References ProjectAddReference Command Window
Macros IDE. .NET Add Reference InsideVSNET.Utilities. , Select, .
References.
,
Imports. :
Imports InsideVSNET.Utilities
, IntelliSense , OutputWindowPaneEx,
, , : Output
IDE Visual Studio .NET Macros IDE. Macros IDE,
DTEMacrosIDE . , Macros IDE IDE Visual Studio .NET, .
Sub OutputWindowPaneExTest()
Dim owp As New OutputWindowPaneEx(DTE.MacrosIDE)
Dim wins As Windows = DTE.MacrosIDE.WindowsO
Dim i As Integer

owp.ActivateO
For i = 1 To wins,Count
owp.WriteLinefwins. Item(i).Caption.ToStringO)
Next
End Sub
, QutputWindowPane, OutputWindowPaneEx , Output. , IDE . Write , , .
,
System.Console.Wnte System.ConsoleWritel.ine
.NET Framework.


IDE IDE .
, , IDI:,.
, IDE.

I Visual Studio .NET

92


Project Explorer Macros IDE. EnvironmentEvents. , IDE.
( ):
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public

WithEvents DTEEvents As EnvOTE.DTEEvents


WithEvents DocumentEvents As EnvDTE.DocumentEvents
WithEvents WlndowEvents As EnvDTE.WindowEvents
WithEvents TaskListEvents As EnvDTE.TaskListEvents
WithEvents FindEvents As EnvDTE.FindEvents
WithEvents OutputWindowEvents As EnvDTE.OutputWindowEvents
WithEvents SelectionEvents As EnvDTE.SelectionEvents
WithEvents BuildEvents As EnvDTE.BuildEvents
WithEvents SolutionEvents As EnvDTE.SolutionEvents
WithEvents SolutIonItemsEvents As EnvDTE.ProjectltemsEvents
WithEvents HiscFilesEvents As EnvDTE.ProjectltemsEvents
WithEvents DebuggerEvents As EnvDTE.DebuggerEvents

, , IDE. DTE,
. , .
, Class Name
(. 4-7).

DetxrggerEvantf
t
t

DTEEvwTts
FindEyents
MiHFJesEvents
Output wndouEvHfc

SoluSonltBrsEven

. 4-7.

Class Name

, Method Name
, (. 4-8).
, ,
.

.
MsgWin .

Visual Studio .NET

93

Private Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBulldScope,


ByVal Action As EnvDTE.vsBuildAction) _
Handles BuildEvents.OnBuildDone
MsgWin("Build is done!")
End Sub

. P u b l i c Hailule Er

. 4-8.

Method Name

IDE.
, , . , ,
, .


, Visual
Studio ., . ,
, :

,-.\
<_lA
**^

The macro pretedt ;\ Dotuments^Vtsuai Studio


F*c]ect$\u5Macro57l\IreSt
event handing code.

*"" fjiatJe eent handing code


f* Qisabte evens handling code

Dont Load Project \

SK . ,
, Disable Event Handling Code
Warning , .

94

I Visual Studio .NET


, , ,
.


Usenet.
, .
, ,
Visual Studio .NET, Macros
IDE Project Explorer.
Ctrl+E FtieSaveSelectedltemsAs,
Export File. File Export.
Export File .vb,
FtieAddExisitingltem (Shift+Alt+A).
*: EnvironmentEvents,
, .
,
. , , .vsmacros .
, IDE Visual Studio .NET
StorageFormat . Macro Explorer
StorageFormat Properties Binary (.vsmacros) Text
(UNICODE).
, Visual Studio .NET. . 4-9
Samples .

. 4-9- ,

4 Visual Studio .NET

95

, ;; IDE.
. ,
EnvironmentEvents.vb .

. , , , .
.


Visual Studio .NET , Samples
Visual Studio .NET . MakeAddin
,
. , . : , , .
1 AutoHideToggle MakeAddin. , , .
, . , , .
Visual Studio .NET , Ctrl+Shift+N
New Project. Other Projects,
Extensibility Projects, Visual Studio
.NET Add-in (. 4-10).

iiJ Visual * Projects


j:*3 Visual J# Projects
i': ^ Visual C++ Projects
1 Setup and Deployment Projects
! '"6' Projects
- Diabase Projects
'+" .'Ji Enterprise Template Projects
23 Visual Studio Analyzer Projects
'^| E^tensteSKyPrsjerts

i ( -1 '',. i

^:

| Create an Add-in badatfe in SBJotei ,T ba


garne:

1 AutoHideTo

created at D:\My DottmentsV/tojai StudB P

. 4-.

96

I Visual Studio .NET

,
Visual Basic .NET, IDE.
, Ctrl+Alt+A,
Command Window, Macros.Samples.MakeAddin.MakeAddinFromMacroProj. (. 4-11) , , .
Visual Studio Macros
Entei the name the MacraPrqect to an

_J3

Cants

lAutoHrieToggle)

. 4-11. ,
, , , . , MakeAddin . , (. 4-12), , MakeAddin
.
* ( in ! Miir.fD Project

. 4-12. ,
MakeAddin
, F5 ;
Visual Studio .NET IDE. Tools IDE , ,
. . 4-13 ,
AutoHideToggle .
. IDE, 1.
,
1, ,
. ,
Visual Studio .NET, ,
My Profile Start Page
Windows Layout. ,
, .

4 Visual Studio .NET

. 4-13.

97

AutoHideToggle IDE

Visual Studio .NET, , ,


, . Visual Studio
.NET Setup.exe. IDE, ,
.


Visual Studio .NET.
,
Visual Studio .NET.

VISUAL STUDIO .NET

LJ (Add-in Wizard) Microsoft Visual Studio .NET , : , ,


(IDE). , ,
, ( ), . . , , .
, , ,
Visual Studio .NET: .


4 Visual Studio .NET ,
IDE. , , , .
, DLL ( ),
IDE ( ). Add-in Wizard,
, .

101

Add-in Wizard
File | New | Project, Visual Studio .NET New Project . Other Projects
Extensibility Projects, Visual Studio .NET Add-in
(. 5-1); Add-in Wizard.

Project types
"~^1 3* Projects
* 03 Visual C++ Projects
LJ Setup and Deployment Projects
- CJ Other Projects
Si Database Projects
.*; \M Enterprise Template Projects

Shared Add-in

.1 Apple ation Center Test Projects


Q Visual Studio Solutions
Create an Add-inlaadable In a Visual audio .NET based host
My Addml
Location;
New Solution Nafne!

| Solution 1

Create directory for Solution

Project < be created at C:\SoiutlanHMyMdrii.


Help

. 5-1.

Visual Studio NET Add-in

Add-in Wizard . .
Add-in Wizard : *, Visual Basic .NET Visual C++ [ Active Template Library (ATL)]. ,
, -.
- IDE Visual Studio .,
Macros IDE . ,
IDE Visual Studio .NET,
Macros IDE. ( .)
. .,
.
Add-in Wizard ,
, .
, , .

102

II Visual Studio .NET

, (
).
,
Visual Studio .NET.

,
,

, Visual Studio .NET
About.
, Add-in Wizard : , DLL , ,
Windows Installer (MSI),
.


DLL, Add-in Wizard Class Library
. Connect, , Connect. Connect
IDTExtensibility2', IDE. (Connect IDTCommandTarget,
.)
IDTExtensibility2 (. 5-1):
. 5-1. IDTExtensibility2

OnStartupComplete
OnAddlnsUpdate
OnBegmShutdown
OnDisconnection

.
, Visual Studio .NET.
Visual Studio .NET.
, Visual Studio .NET .
.

Connect.cs ( 5-1) ,
# (
).
5-1. , Add-in Wizard
Connect.cs

namespace MyAddinl
{
using System;

using NiorosGft,Office.Core;
using Extensibility;
uslfig System. fiuntlae. InteropEiervices;

103

using EnvDTE;
/// <summary>
/// The object for implementing an add-in,
/// <seealso class=*iDTExtensibility2' />
[GuidAttrioiiterSA857E49-7873-45D2-8335~FCCD4123738E"),
ProgldCftyAdtfinl. Connect")}
public class Connect : Object, Extensibility. IDTExtensibility2,
IDTCotBifiandTa rget
{

Hi <8Ufflmary>
/// Implements the constructor for the add-in object.
/// Place your initialization code within this method.
/// </sumuiary>
... pg.blic Connect
\

///

Implements the QnConnection method of the

///

IDTExten.sibility2 interface,

/// .Receives notification that the add-in is being loaded.


/// </suimnary>
/// <param term='appllcatlon'>
/// Root object of the host application.
fft </paraiti>
/// <pararn terffi="connectMode'>
/// Describes how the add-in is being loaded,
/// </pararc>
/// <param terma'atfdlnlnst'>
/// Object representing this add-in.
public void QnGormectionCobject application,
object adtJInlnst, ref Systea,Array custost)
applicattonObject * (^OTE)application;
addlolrtstance = (Addln)addlnlnst;
:

; if (connectMotJe ==
ExteRsibility.ext_ConhectMode.ext_Gm_Ul^tup}
object tJcontextQUIDS * new objecttl { };
Coflfflands GoflHitands = applicationObject.Cofflieands;
_Couiffland8ars commandBars =
applicationQbject.GoifflnandBars; '
try

;;,:;-

! ;;

. , i mp.

104

II Visual Studio .NET

Command commend = commands.AddNamedCowandC


addlnlnstance, "MyAddinl", "MyAddinT,
"Executes the comieand for MyAddinl", true, 59,
ref contextGUIDS,
(int}vsGommandStatus.vsComfliandStatusSupported *
(int)vsCommandStatus.vsCcHMnandStatusEnabled);
CommanctBar commandBar =
(CoiBiBandfiar)cofflfflandBars[ "Tools"];
CommandBarGontrQl coimandBarCofntrol =
command. AddCantroKcoraraandBar, 1);
catch(Systera.Exception /*e*/)

}
/// <summary>
/// Implements the OnOisconnection method of the
/// IDTExtensitollitya interface.
/// Receives notification that the add-in is being unloaded.
/// param term='disconnctMode'>
/// Describes how the add-in is being unloaded.
/// </param>
/// <param terei^'custom':'

/// Array of parameters that are host-application specific.


/// </param>
public void QnDisconnect:Lon(
Extensibility. ext_DisconnectMode disconnect Mode,

ref System. Array custom)

/// <suaieiary>
///
Implements the OnAiidlnsUpdate method of the
/// IDTExtensibility? interface.
/// Receives notification that the collection of add-ins
///
has changed.
/// </summary>
/// <param terna* custom' >
/// Array of parameters that are fcost- application specific.
/// </param>
public void QnAddInsUpdate( ref System. Array custom)

/// <sufflBiary>
///
Implements the OnStartupComplete nethod of the

///

lDTExtensiblllty2 interface.

105

/// Receives notification that the host application has


///
completed loading,
/// </summary>
/// <param terei=' custom *>
/// Array of parameters that are host-application specific.
/// </param>
public void QnStartupComplete(ref System. Array custom)

tit <>
/// Implements the QnfieflinShutdown method of the
///

IDTExtenslblUtyZ interface,

/// Receives notification that the host application is


/// being unloaded.
/// </su!mary>
/// <param term='custora'>
/// Array of parameters that are host-application specific.
/// </param>
public void On8eginShutdown(ref System. Array custom)

fit <summary>
/// Implements the QueryStatus method of the :

///

lOTCoffiBiandlarget interface.

///
This is called when the command's availability is updated.
/// </summary>
/// <param term-'commandNanie'>
/// The name of the command to determine state for.
/// </param>
/// <param te rra= ' neededText ' >
/// Text that is needed for the command.
/// </param>
/// <param term' status '>
/// The state of the command in the user interface.
/// </>
I. /// <param term='commandText'>
/// Text requested by the neededText parameter,
/// </param>
public void ClueryStatusCstring commandName,
EnvDTE.vsCommandStatusTextWanted neededText,
ref HnvOTE.vsCoBiBiafidStatus status, ref otiject commandText)
{
if (neededText ==
EnvDTE.vsCoiftiftanclStatusTextWanted.vsCoffliBandStatiisTextWaRtedfifone)

if (commandName -- "HyAddinl. Connect. HyAddint")


{

status,, =
. ,. .

106

II Visual Studio .NET

{vsGoiBmandStatus)vsCOfflmantlStatus.vsCommandStatusSupporteci
vsCofflfflandStatus.vsCoBfflafidStatusEnabled;

jfl <summary>
///
Implements the Exec method of the lOTCoiaftandTarpet Interface.

///

This is called when the command is invoked.

/// </summary>
/// cparatn term='GQnimaRdNaBie'>

///
///
///
///
///
///
///
///

! :: :

The of the to execute.


: ,:-\:sy ' V
</param>
<param term='exeeuteC'ptlon'>
Describes how the command should be .
</param>
<param term='varln'>
Parameters passed from the caller to the command handler,
</parant>

/// <param teri-'varOut'>


///
///

Parameters passed from the handler to i&& caller.


</1>

/// <paratB term-' handled' >


/// In forma the caller whether the command was handled,
/// </paraffl>
public void Exec(string coimandNane,
EnvDTE.vsCofflmanuExecOptioR executeOptlon, ref object varln ,

ref object varQut, ref bool handled)


{

handled = false;
if (execstteOption *
t)

if CcosraandNanie ** "HyAddin1.0oanect,HyAddin1")
{
hancfled = trte;
return;

private _DTE applicationObject;


private Addln addlnlnstarce;

using,
. ( Connect.cs , Add-in Wizard
using ,
, , .)
using: EnvDTE Extensibility;

107

, IDTExtensibility2, . ( Microsqft.Office.Core, IDE.)


, OnConnection,
. Visual Studio .NET , application. , Add-in Wizard, application
EnvDTE._DTE,
applicationObject. applicationObject.
Visual Studio .NET addlnlnst
Addin; addlnlnstance.
OnConnection Tools. (
, Add-in Wizard.)
if:
If (connectMode == Extensibility.ext_ConnectMode.ext_cm_UISetup)
connectMode , ,
. , , Visual Studio .NET Extensibility.ext_ConnectMode.ext_cmJJlSetup
. ,
IDE.
Add-in Wizard
IDTExtensibility2\ OnStartupComplete, OnAddinsUpdate, OnBeginSbutdown OnDisconnection. IDTCommandTarget, QueryStatus Exec,
,
.
Exec if.
if (commandName ==

"MyAddi.n1. Connect. MyAddinl")

Connect.cs ,
Add-in Wizard, ,


( ) MSI-, , Windows-
.NET Framework. ( ,NET Framework ; . 13-) , , MSI-
Windows Explorer, Visual Studio .NET. , Install
(. 5-2). .

II Visual Studio .NET

108

. 5-2.

Visual Studio NET

Visual Studio .NET


, Add-in Wizard. , Visual Studio .NET . .
Visual Studio .NET ,
Tools (. 5-3)-

10 Slcrosoft.OMicei

*- -...
Comment Web Pagei
Detected Dependencies
^ dotnetf(redist_>a6.,T5

fi .

ActiveX Control Test Conjenr

:
l dfeolb
^ EnvDIE.dH
i|3 ExtensMty.dl
MyAddr,1tl,
!3 tffee.di
$- stdcte

C-eate

i,

ATLJHFCIrace led

[GuIdlttrlBute [-41857

OLE/COM Obhct
Spyt*

Primary output hotn MvMUnl (.


f39") , PEOfl! J
Jxtenaibilit;

External Tools,.,

. - ic Connect (]; k^ iustonue..


j

'
i

id OnJiddlnsUcdat

UL_

. 5-3.

109

, ,
Tools | Add-in Manager,
(Add-in Manager) (. 5-4). Add-in Manager : , ,
.

Startup

Command Une

JC# add-in created by Add-in Wizard

. 5-4. Add-in Manager


DLL, Class Library. DLL ,
-; Visual Studio
.NET (devenv.exe) Macros IDE (vsaenv.exe). Add-in Wizard , Visual Studio .NET.
, Solution Explorer, Properties, Configuration Properties | Debugging Property Pages (. 5-5),
.
Visual Studio
.NET, , , Start Debug ( F5).
Visual Studio .NET .
Visual Studio .NET,
, , , Visual Studio .NET.
, . .
Macros IDE Visual Studio .NET.
, Macros IDE Visual Studio .NET Macros
IDE. , , Visual Studio

II Visual Studio .NET

110

.NET , . Macros IDE


Visual Studio .NET: Visual Studio .NET,
Visual Studio .NET. Macros IDE
Visual Studio .NET, Visual Studio .NET
Macros IDE, Macros IDE . ( !)

i Properties
|3 ilorfigurejior Properbe

Enable ASP Debugging

BuU

Enable ASP.NET Debuging

Debugging

Enable LNrianaged Debugging Fal

Advanced

Enable ::. Debugging

Fal

Fal

. 5-5.
: Visual Studio .NET,
. ,
DLL, . (, Microsoft CLR
Debugger, .NET Framework SDK, . 5- 6).

[360] devenv. - Thread [Z6i6]<No4WB>T

application

system. Object
-. xtensibihty.eit .ConnectMo*

eddlnlnst

System. Obct
System, Array

. 5-6. CLR Debugger

111


,
, Visual Studio .NET
. IDE: .


,
. Visual
Studio .NET . . ,

.
DTE.
DTE application OnConnection-,
DTE DTE.
DTE, .
,
Solution, Project Projectltem
.
Document TextDocument IDE.
TextSelection TextPoint ; EditPoint ~

FileCodeModel, CodeNamespace, Codelnterface, CodeVariable, CodeFunction


,
.
CommandWindow, TaskList, OutputWindow, ToolBox
fDE.
Command .
Debugger, Process, Program, Thread, StackFrame
Visual Studio .NET.


, , , . ( ,
, , Addlns(Q) COMException
Activate @#&%*!.)
.
DTE, DTE.

. , Documents Document

112

II Visual Studio .NET

, .
( ) Item .
Item , VARIANT.
Item .
1.
Count, SystemJnt32, long.
Collection, -;
Parent,
.
Add ; Remove Delete . (Delete ,
, ToolBoxTab;
Remove , Addln.)
DTEvents .
Object, .
;
, Visible True.
, , FullName.
Activate
; , Activate .


, Visual Studio .NET, a
. , Visual Studio .NET . Visual Studio .NET.


, , Visual Studio .NET, .
#, .
DTEEvents ~ . EnvDTE,vents,
(. 5-2). Events
, ,
, .

113

. 5-2. EnvDTE.Events

BuildEvents

QnBitildBegin
OnBuildDone
OnBuildProjConfigBegin
OnBuildProjConfigDone
AfterExecute
BeforeExecute
OnContextChanged
OnEnterBreakMode
OnEnterDesignMode
OnEnterRunMode
OnExceptionNolHandled
OnExceptionThroivn
DocumentClosing
DocumentOpened
DocumentOpening
DocumentSaved
ModeCbanged
OnBeginSbutdown
OnMacrosRuntimeReset
OnStartupComplete
FindDone
ItemAdded
ItemRemoved
ItemRenamed
PaneAdded
PaneClearing
PaneUpdated
OnChange
AfterClosing
BeforeClosing
Opened
ProjectAdded
ProjectRemoned
ProjectRenamed
QueryCloseSolution
Renamed
ItemAdded
ItemRemoved
ItemRenamed
TaskAdded
TasteModified
TaskNavigated
TaskRemoved
LineChanged
WindowActivated
WindowClosing
WindowCreated
WindowMoved

CommandEvents'
DebuggerEvents

DocumentEvents'

DTEEvents

FindEvents
MiscFilesEvents ( ProjectltemsEvents)
OutputWindowEvents'
SelectionEvents
SolutionEvents

SolutionltemsEvents (' ProjectltemsEvents)

TaskListEvents'

TextEdits-Events'
WindowEvems'

C# ,
, ' get .
get.
5 1116

114

II Visual Studio .NET

. 5-2,
, , . Visual Studio .NET ; , .
, .
.NET Framework - (. ), . , _$<
>_< co6btmun>Evenfficmdler. , , ,
, +=. , . .
, , ,
, ,
, , .
, ButidEvents.OnBuildBegin ( ) . :
void OnBuildBegin(vsBuildScope scope, vsBuildAction action);
Visual Studio ,NET
scope action-, scope , (, ), a action (, , ).
- , .
:
public class Connect : Object, Extensibility. IDTExtensibUity2
private void OnBuildBegin(vsBuildScope scope. vsBuildAction action)
{
//

, . . 5-2
, BuildEvents, OnBeginButid jMspBuiMEventsJ3nBeginBuildEi>entHandler. :
public class Connect : Object, Extensibility. IDTExtensibility2
I
public void OnConnection(object application,

115

Extensibility.ext_ConnectMode connectMode,
object addlnlnst,
ref System.Array custom)
applicationObject = (_DTE)application;
addlnlnstance = (Addln)addlnlnst;
buildEvents = applicationObject.Events.BuildEvents;
buildEvents.QnBuildBegin +=
new _dispBuildEvents_OnBuildBeginEventHandler(
this.OnBuildBegin):

!
public void OnDisconnection(
Extensibility. ext_DisconnectHode disconnectMode,
ref System. Array custom)
buildEvents. OnSuildBegin -=
new _OispBijildEvents_OnBuildBeginEvent Handle (
this.OnBuildBegin);
I

private void OnBuildBegin(vsBuildScope scope, vsBuildAction action )


I
// .

'
private _DTE applicationQbject;
private Addln addlnlnstance;
private EnvDTE. BuildEvents buildEvents;

: QnConnection OnBuildBegin
, a OnDisconnection
.
! , .
, Visual Studio
.NET . , , - . ,
, , *, ..

116

II Visual Studio .NET


, . EnvironmentEvents,
, . 5-2, Macros IDE. EnvironmentEvents , , Class Name, , , Method Name (. 5-7). Macros IDE .

Oyste

Content Static A t t r i b u t e 0 > P u b l i c M l t h E v e n t s PTEEventa EnvPTE.DTEEveBts

<s?ateB
<5ysten

C o n t e x t S t a l j c A t t r i b u t e ( J > P u b l i c SlthSvEHts S o l u c i o n E v e n t s Is EnvDTZ . Solntionlven

Ofaten
ContewtStacici-ttcibgtej! > P-jti:c V:^li-:vent3 tebuggerEventa A^ EnvDTC.DebuoaerEven

. 5-7.
, EnvironmentEvents. He , Automatically generated code, do not modify* ( ; ), .

EnvironmentEvents , (, EnvironmentEvents).
, : . ^ MyWindowEvents :
<System.ContextStaticAttribute()> Public WithEvents
MyWindowEvents As EnvDTE,WindowEvents

117

, , ,
, EnvironmentEvents,
MyWindowEvents Class Name
Method Name.
EnvironmentEvents . , Macros IDE EnvironmentEvents, ,
.
DTEv<mts\
MyWindowEvents = DTE.Events.WindowEvents

. ,
, .
, - . DTEEvents ,
: OnStartupComplete, , Visual Studio .NET, OnMacrosRuntimeReset, , . EnvironmentEvents , :
Public Module EnvironmentEvents
Public Sub DTEEvents_OnMacrosfiuntimeReset() _
Handles OTEEvents.OnMacrosRuntimeReset
MyModule.MyWindowEvents = DTE.Events,WindowEvents
End Sub
Public Sub DTEEvents_OnStartupComplete() _
Handles OTEEvents.OnStartupComplete
MyModule.MyWindowEvents = DTE,Events.WindowEvents
End Sub
End Module


- ,
Visual Studio .NET. . , , . , WindowClosing
, Task
List. DTEEvents (. 5-3) .

II

118

Visual Studio .NET

. 5-3.
DTE.Events

CommandEvents
DocumentEvents
OutputWindowEvents
TaskListEvents
TextEditorEvents
WindowEvents


Document


TextDocument
Window

, IDE.
. 5-3 , WindowEvents
Window. Window EnvDTEWindows, Item EnvDTE.Constants.vsWindowKindxxx.
Window WindowEvents, . , Macro Explorer:
.
<System.ContextStaticAttribute()> Public WithEvents _
KacroExplorerWindowEvents As EnvHTE.WindowEvents
Sub InitializeMacroExplorerFilter()
Dim macroExplorerWindow As EnvDTE:.Window
macroExplorerWindow =
DTE.Windows.Item(EnvDTE.Constants.vsWindowKindMacroExplorer)
MacroExplorerWindowEvents =
DTE.Events, WindowEvents(macrci Explore rWindow)
End Sub
Sub MacroExplorerWindowEvents_WindowActivated(
ByVal GotFocus As EnvDTE.Window,
ByVal LostFocus As EnvDTE.Window)
Handles MacroExplorerWindowEvents.WindowActivated
:
Macro Explorer.

End Sub

:
? Output ,
FflteredEv&nts.
1,

lnitializeUnfut&redEventst DocwnentEvents TextEditorEvents . FUteredEvrnts


, ? DGCUvi LineChanged .

119

2. ,
3. Enter.
Output LineChange< I
fired ( LineChanged).
4. , Output *DocumentSave<.i
fired* ( DocumentSaved )
' ' . . DocumentEvents TextMditorEm&ts &
,
. !
;:
,
1. InttializeJPtlteredEvents. New Fik- - '
DQcumentSaved\iLmeCb&nged'?%&,
,
2. New Fite Enter. Output
LineChanged fired*.
J. . : Output :'';
.
4. , Output.
5. New File. Output DocumentSaved fired*,

, Visual Studio .NET, ! ,
; .
. 5-4.
. 5-4.

Visual C

Visual Basic

Visual C++


CSharpBuildManagerEvents
CSbarpProjectsEuents
CSharpProjectltemsEvents
CSharpReferencesEvents
VBBuildManagerEvents
VBlmportsEi >ents
VBProjectsEvents
VBProjectltemsEvents
VBReferencesEvents
CodeModelEvents
VCProjectEngineEventsObject

120

Visual Studio .NET

,
, , : VBProjectsEvents, CSharpProjectltemsEvents . . ( Visual C++ ,
.) , DTEMvents.GetQbject. , , #-:
<System.ContextStaticAttribute()> Public WithEvents
CSharpProjectsEvents As EnvDTE.ProjectsEvents
Sub InitializeCSharpProjectsEvents()
CSharpProjectsEvents = DTE.Events,GetObject("CSharpProjectsEvents")
End Sub

, ,
CSharpProjectsEvents, ]! #-.


. Addin Wizard
. , . ' , .

D 5 , Add-in Wizard Microsoft Visual Studio .NET. ,


,
. ,
, ,
, , ,
. , , ,
, . ,
, Add-in Wizard
? IDE. Command Window ... .
.


6-1 Basic.
, . .
, : , ExtensibilitylDTExtensibility2. Basic.cs, #,
, Basic, IDTExtensibility2
5 : OnConnection, OnStartupComplete, OwAddInsUpdate, QnBeginShutdawn OnDisconnection. Main,
Basic, , DLL
OnConnection. Basic ,
.

122

II Visual Studio .NET

6-1. Basic
Basic.cs
using System;
using Systffl.Windows. Forms;
using Extensibility;
public class. Basic : I8TExtensibtUty2
t

public void OnConnection(objeot application,


ext_CormeetHode connectHode,
object addlnlnst,

ref Array custom)


Hessaee8ox.StiQw("Basie Add-in");
public void QnStartpeoraplete(ref Array custom)
I
public void Gr>AddInsUpefate(ref Array custom)

public void OnDisconnection(ext_DisconnectHode removeMode,


ref Array custom)

Basic
6-1
Basic.cs, Basic
:
esc /t: library /: "c:\program files\microsoft visual studio .net 2003\
common7\ide\publicassemblies\extensibility. dll" basic. cs

/(.-library #,
DLL (Basicdll), a tyii2.r/r;c:\programjiles\microsofl visual studio net 2003\common7\ide\publicassemblie$\extensibility.dH , Extensibility (Extensibility.dll). Extensibility
: IDTExtensibility2 , ext_ConnectMode ext_DisconnectMode, , OnConnection OnDisconnection .

123

, ,

.
, CSC.rsp, <WinDir>\Microsoft.NET\Framework\<Version>\CSC.rsp. , /r:*c;\programflles\microsoft visual studio .net 2003\common7\ide\publicassemblies\extensibility.dll->, Basic ;
esc / t : l i b r a r y basic.cs

Basic -
Basic.dll. , , , .
Visual Studio
.NET: Visual Studio .NET , , . , Visual
Studio . Visual Studio .NET
Visual Studio 6, . , Visual Studio 6
- , Visual Studio .NET .
, -. .NET Framework ,
,
, - .NET- . , .NET-,
, -. ,
.
HKEY_CLASSES_ROOT\<ProgID> , ProgID ,
IDTExtensibility2,
HKEY_CIASSES_ROOT\<ProgID>\CLSID ,
CLSID , IDTExtensibility2,
HKEY_CLASSES_ROOT\CLSID\<CLSID> , CLSID ,
IDTExten$ibility2.
HKEY_CLASSES_ROOT\CLSID\InprocServer32 , , IDTExtensibility2, , .
. 6-1 Basic.
Visual Studio .NET -.
, , , Visual Basic 6, , (,
.NET Framework ).

II Visual Studio .NET

124

E* SHV

i ^J BDATu
t Jj 1
I U

ATSCChannelTurHRwiilBt.l

Nora*

^9Klas^f^=-l]D^eCA-a9lB6^

Type
FEGJSJ

[
Baslc.VerMn-D.D.O.O^Cirturp-neutral.PublkteyTok..

v-

W^ Co"IBUtsrV*EY_CI.ASK.- RO

. 6-1.

-: Basic

, :
.NET Framework Assembly
Registry (RegAsm). Baste -
regasm /codebase basic.dll
, RegAsm
, , /codebase
, /codebase
CLSID\InprocServer32\CodeBase CLR .
RegAsm ProglD CLSID jciacca,
'. (. GL1D FUID CLSID.)
ProglE) , . , :
namespace Outer
i
namespace Inner

public class HyClass ()


I

:
ProglD Outer JnnerMyClass. Basic
, ProglD Basic,

125

CLSID (GUiD) 16- , .


CLSID, RegAsm, GUJD
. RegAsm CLSID,
- , . FITID
for-the-most-part unique identifier ( \ )
GUID.
, , :
,
Basic, FUID:992BOD1F- 395. 34F5-BFC9-EGA3E9385293.
, , , , FUID,
RegAsm.
SystemRuntimeXnteropServices-GuidAttribute, GuidAitribute FUID
GUID . ( GUID : Create GUID [GuidGen], * GUID,
.)

Basic Visual Studio .NET


Basic.dll , .
Visual Studio .NET .
(IDE) Visual Studio .NET
:

HKEY_LOCAL_MACHINE\SOFT^rARE\Microsoft\VisualStudio\7.1\AddIns\<ProgID>
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1\AddIns\<ProgID>

A Macros IDE VSA-.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VSA\7.1\AddIns\<Progro>
HKEY_CURRENT_USER\Software\Microsoft\VSA\7.1\AddIns\<ProgID>

IDE Visual
Studio .NET.
Macros IDE.
Add-in Manager ,
Mdlns. HKEY_LOCAL_MACHINE
, _CAL_MACHINE , , - >-

126

II Visual Studio .NET

, .
HKEY_CURRENT_USER , , HKEY_USERS; ,
. ProglD ,
ID TExtensibility2.
Basic (RegEdit)
(, ):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7,1\
AddIns\Basic

Visual Studio .NET Tools j Add-in Manager, Add-in Manager (. 6-2). : Add-in Manager
Basic Add-in Manager ProglD,
Addlns. (
ProglD, .)
Add-in Manager
Avaflable Add-ins

Startup: Command Line

Web Hosting Provider Upload Utility,

DJ
G

Description:

Cared

. 6-2.

HelD

Add-in Manager, Basic

Basic OK, Visual Studio .NET


. , Visual Studio
.NET OnConnection Basic, (. 6-3):

. 6-3-

, Basic

127

. , Visual Studio .NET, , .


. , ,
, Visual
Studio .NET IDTExtensibtiity2. , Visual Studio .NET IDTExten$ibility2.


IDTExten$ibility2, ,
. . 6-4

.

OnConneciion

1
OnAdatnsUpdate
QnStartupCoinptete

2

OnAddinsUpdate

Visual Studio ,NT

.

Visual Studio .

OnBegmStwWo
QnBisconnection
1

,
, ,
1

. 6-4.

Add-in Manager
QnAddliisUpdate,

128

II

Visual Studio .NET

, , .
: nection , , OnDisconnection
. .
: , , ,
. OnAddlnsUpdate. , OnAddlnsUpdate. ,
. , Visual Studio .NET
. , OnConnection,
, :
OnAddlnsUpdate.
Add-in Manager,
OnAddlnsUpdate pan ,
/. , , OnAddlnsUpdate. , , , , OnAddlnsUpdate,
, - .
: , ,
OnAddlnsUpdate, , / Connected. ( . 7.) . .


, -
LifeCycle. IDTExtensibility2, Output ( 6-2). LifeCycle Visual Studio .NET, Add-in Manager. , Basic, lDTExtensibility2. OnStartupComplete,
Add-in Manager Startup LifeCycle,
Visual Studio .NET. OnBeginShutdown
Visual Studio .NET LifeCycle .
6-2. LifeCycle

LifeCycle.cs
namespace InsideVSNET
{
namespace Addlns

Sing EnwDTE;

using Exteftsibility;
using InsicfeVSNET. Utilities;

129

usirrg Syste;
using System.fiuntine, InteropServices;
COoldAttribute("DOC34F40-6A93-4601-8458-5A972E9C8D24")]
public class Life-Cycle : IDTExtensibilltyS
{

private string title = TifeGycle";


private GutputWindowParraEx output;
public void ORGonnectiortCobjiect application,
ext_Conn.ectMode cormectMode,
object addlnlnst,
ref Array custom)
{
this.output = new OutputWindmfPaneEx((PTE)appiieatlQn,
this.title);
this.output.WriteLlneC'OnCofinection event fired");
' >
public void QnStartupCoBiplete<ref Array custom)
{
this, output, WriteLine("Q?iStartupCGmplete event fired");
}

public void OnAiklInsLlpdate{ref Array custom)


{

this,output.WriteLlne("QnAddInsiJpdate event fl red");


public void OnBegiflShutdowKref Array custom-)'
i

this. output. WriteLlne("OfiBeginShutdown event f ired");

public void OnCisconnectiofl(ext_01sconnectMode rem oveHode,


ref Array cystom)
(

tnis, output, Writetlne("OnDlsc<innectloR event f ired");

, ,
, Visual Studio .NET. (
, )
LifeCycle , File
New | Blank Solution. LifeCycle, File | Add Project
| New Project Visual C# Projects j Empty Project Add New Project.
, CS- LifeCycle.cs, File j Add New Item Code
File Add New Item.

130

II

Visual Studio .NET

: (output type) , ;
, DLL,
Properties.
Property Pages Common Properties | General , 1
Class Library Output Type.
-, Visual Studio .NET
, -.
- Configuration Properties | Build
LifeCycle Property Pages True
Register For COM Interop,
Apply ,
Register For (
Interop. Configuration Properties | Build,
, .-
,
Register For COM Interop.
6-2 CS-.
, , ,
EnvDTE, Extensibility, Utilities , . , References Solution Explorer Add Reference
. .NET Add References envdte, extensibility InsideVSNET.Utilities. LifeCycle.dll
.

IDTExtensibility2
, IDTExtensibility2. Visual Studio .NET ,
, /
Visual Studio .NET.
Visual Studio .NET , IDTExtensibility2
Visual Studio .NET.

EnvDTE
IDTExtensibility2, EnvDTE. EnvDTE
Environment Development Tools Extensibility ( ), : Visual Studio .NET. Visual
Studio .NET ,

131

140 , EnvDTE. , , , :
DTE ;
DTE.Addln , ;
DTEAddlns Addln, , IDE Visual Studio .NET;
DTE.Solution.Addlns Addln, .
DTE,
DTEAddln DTEAddlns, , . DTESolutionAddlns .
8.
IDTExtensibtiity2
, . ,
, , , IDTExtensibility2. , AddIn.Qbje< /.
IDispatch.
DisplayMessage MyAddln.Connect:
Dim dispObj As Object = DTE.Addlns.ItemC'MyAddln.Connect").Object
dispObj.DisplayMessage("IDispatch a message to you.")

OnConnection
, IDTExtensibility2 OnConnection. , IDE. OnConnection :
public void OnConnection(object application,
ext_ConnectMode connectMode,
object addlnlnst,
ref Array custom);
application EnvDTE&TE, . application
EnvDTEDTEClass, EnvDTEJDTE. EnvDTE._DTE. . _,
application DTE _DTE , (. , ,
EnvDTE.) , - , DTE,
OnConnection DTE .

132

II Visual Studio .NET


, , ,
nvDTE. , , , Visual Studio
.NET, . EnvDTE
.NET Framework; EnvDTE
- Framework Pascal- .
EnvDTE . (.
, .)

(Design Time Extensibility, DTE) Visual Studio. , Visual Studio
.NET -. EnvDTE, Add Reference,
Type Library Importer (Tlblrnp) (dte.oib).
, . Env&TE ,
.
, Visual Studio Visual Studio .NET,
, Shift-
connectMode , . Extensibility.,ext_ConnectMode (. 6-1).
. 6-1. Extensibility.ext ConnectMode

ext_cm_AfterStartup
extjzm_Startup
ext_cm_External
sxt_cm_CommandLine
ext_cm_Solution
ext_cm_UlSetup

(Int32)
0x00000000
Visual Studio .NET,
0x00000001
Visual Studio .NET.
0x00000002
. ( Visual Studio .NET.)
0x00000003
.
0x00000004
.
0x00000005

.

connectMode
. , ext_cm_UISetup, ,
IDE. ( ext_cm_UISetup Add-in Wizard.)

133

addlnlnst
Addln, . (
Addln - .) ,
IDTExtensibility2 custom, , . Visual Studio .NET custom .

OnStartupComplete
OnStartupComplete ,
Visual Studio .NET. OnStartupComplete:
public void OnStartupComplete(ref Array custom);
, | OnConnection, .,
Visual Studio .NET
. OnStartupComplete,
, Visual Studio .NET .

OnAddlnsUpdate
OnAddlnsUpdate , Visual Studio .NET. . OnAddlnsUpdate :
public void OnAddInsUpdate(ref Array custom);
-
OnAddlnsUpdate. . , ,
, , . , DTEAddlns,. Addln ( ) Addln
Connected, . Addlns , AddlnsJtem ProgID
( 1). , COMException, , Addln.
InsideVSNET.Addlns.LifeCycle:
public void QnAddInsUpdate(ref Array custom)
{
try

Addln addln =
this.dte.Addlns.Iten("InsideVSNET.Addlns.LifeCycle ");

134

II

Visual Studio .NET

if (addln. Connected == true)


I
// InsideVSNET.Addlns. LifeCycle .
I
else
{
// InsideVSNET.Addlns. LifeCycle .
}
I

catch (COMException)
{
// InsideVSNET.Addlns. LifeCycle
// .

, , InsideVSNET.Addlns.LifeCycle .
LoadUnload ( 6-3) , : , OnAddlnsUpdate.
6-3. LoadUnload

LoadUnload.cs
namespace insideVSNET

; i

arses pace Add Ins

; :(

":-.:

using EnvDTE;
using Extensibility;
ysiRg IfisideVSHET. Utilities;
asiog HIcrosoft. Office. Core;
using System;
" using Systeie. Collections;
using System. Runtime. IrmsropServiees;
Prog Id {"LoadUnload. Connect")]

public class Connect : Object, IDTExtensibillty2, lOTCominandTarget


{

private DTE dte;


private atfdlnlnstancs;
private SortetfList addlnsList - new SortediistO;
private Addlns addlnsCollection;
private QytpotWindowPaneEx output;
private string title *
public Connect ()

135

public void OnConnection(object application,


ext_ConnectHotie connectHode,
object addlnlnst,
ref Array custom)
this,dte * (DTE)applicatLon;
this.addlnlnstance = (Addln)addlnlnst;
this.addlnsCollection = this.dte.Addlns;
foreach (Addln adcfln In this.addlnsCollection)

this.addlnstist[addIn.ProgIO} = addln,Connected;
this, output * new QutputWin.dowPaneEx(tbis,dte, this. title);
J

public void QnBisconnectlon(ext_0isconnectHode disconnectMode,


ref Array custom)

{
1 ' .;:'=:

public void OnAddInsypdate( ref Array custom)


{
this . addlnsCollectiort. Update( ) ;
foreaeh (Addln addln in this.addlnsCollection)
<
if (this.addlnsList.Gontains(addrR.ProglD) >

if addln. Connected !=
Ct>ool)thls.addInsList[addIn.Progie 3)

{
string action = addln. Connected ?
"loaded" : "unloaded";
this, output. WriteLiRe(addIn.ProgID +
" was " + action, this. title):
else

I
string action = addln. Corrected ?
" and loaded" : String. Eftpty;
this. output, WriteLine(addIn.roglD *
" m$ added" + action, this. title);
. , ,

II Visual Studio .NET

1 36

this.addlnsListtaddln.ProglO] * addln,Connected;

public void OnBegiFiShutdown(ref Array custom)

LoadUnload
addlnslist Sortedl.ist. , QnAddlnsUpdate,
LoadUnload , DTEAddlns-.
, . 6-3:
this.addlnsCollection.UpdateO;
foreach (Addln addln in this.addlnsCollection)

if

(this.addlnsList.Contains(addln.ProglD)}

if {addln. Connected 1=
(bool)this.addInsList[addIn.ProgID])

{
string action = addln. Connected ?
"loaded" : "unloaded";
this. output. WriteLine{addIn.ProgID +
" was " + action, this. title);

addlnsCollection DTEAddlns,
Update ,
. (Add-in Manager ,
Update) Update,
addlnsCollection ,
. , Connected .
, ,
Connected , (true)
(false).

137

addlnsList, , OnAddlnsUpdate.
, :

else
I
string action = addln.Connected ?
" and loaded" : String.Empty;
this.output.WriteLine(addIn.ProgID +
" was added" + action, this.title);
!

this.addInsl_ist[addIn.ProgID3 = addln.Connected;
i

Connected
, .
LoadUnload, , (, , , ), ,

OnBeginShutdown
OnBeginShutdown-.
public void OnBeginShutdown(ref Array custom);
, IDE . JDE , OnBeginShutdown , , IDE
, . , IDE,
IDE.

OnDisconnection
OnBeginShutdown ,
; OnBeginShutdown
IDE. OnDisconnection
, OnBeginSbutdoum. OnDisconnection :
public void OnDisconnection(ext_DisconnectMode removeMode,
ref Array custom);
IDTExt&nsibility2.ext_DisconnectMode removeMode , . ext_DisconnectMode . 6-2.
ext_DisconnectMode , extjConnectMode-.
, . , , ext_dm_UISetupComplete,
, , .

138

II Visual Studio .NET

. 6-2. Extensibility.ext_DisconnectMode

ext_dm_HostSbutdown
ext_dm_Userlosed
ext_dm_UISetupComplete
ext_dm_SolutionClosed

(Int32)
0x00000000
Visual Studio .NET.
0x00000001
, Visual Studio .
0x00000002
.
0x00000003
, .


, Visual Studio .NET,
, ProgID, Addlns. , . .

CommandPreload PreloadAddinState

IDE: ,
. ,
IDE .
, ,
, ?
CommandPreload PreloadAddinState.
CommandPreload 0x1, Visual Studio
.NET, IDE IDE (, }. . 6-5 , Visual Studio .NET
.
, ;
, , , . .
Visual Studio .NET
, CommandPreload 0x1, ,
. , Visual Studio .NET ,
, ,
. CommandPreload , , Visual Studio
.NET 0x2

139

(. 6-5). CommandPreload , Visual


Studio .NET , , . PreloadAddinState:
. Visual Studio .NET , PreloadAddinState: , Oxl, Visual Studio .NET , .
Visual Studio .NET


/ns


1?

extern

* -;
exljcmJ

extjfmj

0xtj$m_UfSettipGofnplets

CommandPfeload 0x2

Visual Studio .NET



. 6-5-

Visual Studio .NET *, ext_cm_UISetup QnConnection,

1 40

II

Visual Studio .NET

OnConnection, ext_dm_UISetupComplete OnDisconnection.


Visual Studio .NET PreloadAddinState ( ) 0x0; Visual Studio .NET
CommandPreload 0x2.
, Visual Studio .NET , .
Visual Studio .NET ,
,
Addlns . Visual
Studio .NET .
PreloadAddinState HKEY_CURRENT_USER
Software\Microsoft\VisualStudio\7.1\AddIns\PrcloadAddinState.
Visual Studio .NET, , Visual Studio
.NET . , CommandPreload 0x1, , , .
, , PreloadAddinState 0x1,
, CommandPreload 0x1 ; Visual Studio .NET . , :

devenv /setup
IDE (
, IDE), CommandPreload 0x2 0.x 7 PreloadAddinState. Visual Studio .NET
. , .

LoadBehavior CommandLineSafe
LoadBehavior , ,
. . 6-3 LoadBehavior. ,
,
. :
.

141

. 6-3. LoadBehavior

ID UNLOADED

0x0

ID_STARTUP
IDJLOADED
ID_COMMANDJJNE

0x1
0x2
0x4

.
.

.

1DJJNLOADED IDJLOADED ,
Addln.Connected.
ID_STARTUP Visual Studio .NET
IDE. ,
, IDE, , . ,
, ,
.
ID_COMMAND_LINE , . : Visual Studio .NET 2002 , . 2002
, Add-in Manager (
, ID_STARTUP).
CommandLineSafe ID STARTUP ID_COMMAND_UNE,
, . CommandLineSafe, 0x1, , , , . CommandLineSafe
CommandLineSafe, 0x0, , . CommandLineSafe
.
?
, Visual Studio .NET - , , , .
, ,
,, , ,
, ,
. , Visual Studio .NET
2002 ,
:
, .
Visual Studio .MET 2003.
1. ,
2. Visual Studio .NET , IDjCOA 'MANDJJNE, extj:m_Commendline nection .
. , .

142

II

Visual Studio .NET

; 3. extjmjCommandLine .
Visual Studio .NET 2002
. IDjCOMMANDJUNB ; f; , iD_STAR*WP, Visual Studio ; |
.NET 2002 ext_cm_Comrnan4Line ,
; Visual Studio =
.NET 2003. Visual Studio .NET 2002,
, ID_STARTUP ,
, Syst&mnmronment,CommandLine ;
if (Regsx.IsMatcMSysteHi,Environment.CommandLine, "/build"
i
// .
System.Console.WriteLine("Command-line build- phooey on GUI!");

>
.else
<

// .
MessageB0x.Sftuw("6UI for yoyf");

}
QnConnectian,
, .

SatelliteDLLPath SatelliteDLLName
,
.
. ,
, DLL DLL , , .
,
DLL.
DLL SatelliteDLLPath SatelliteDLLName. SatelliteDLLName DLL ( , DLL
). SatelliteDLLPath DLL
DLL ,
, ,
DLL. , U.S. English 1033, DLL
U.S. English <SatdliteDLLPath>\].033\<SatelliteDLLName>. -

143

DLL AddlnSatettiteDllPath DTESatelliteDllPath.


:
; , Visual Studio .NET DLL
:
<SatelHteSU.ftatfc>\<Default systen locale>\<Sate!Ut^)LiMafne>
<SatelllteCLLPathX\<Default user 11>\<119.>
<Satellltt>LLPath>S<0S setup looale>\cS8teIIiteDtyiaBte>
<Sateillte0LLPath>\1033\<SatelliteHLf(ae>
<Sat el 1 iteBLLPath>\<Satell 1 teDUlfem>
, * . Visual
Studio .NET DLL? . SatelliteDLl Probing satellites, 133 1:
Afrikaans Zulu, DLL . DTESatet Output
/ DLL , ' DLL , Satellite--"-'
* DltPatfo .
Satelffie&LLProbing,
, ,
. -";!
=!'
, . ^
, $10&81 * ^
DLL <SatdliteDLOPath>, . , , , SateUiteDllPath
DLL - =
, , ; ! ;:
Sate&iteD&P&tb , >
. , : - ,'.;'
. ( ? .
!) SafelHteDUPatb , , ,
DUL, .
^ - 0LLB Visual Studio .NET . i
, , --:;;
, . To\i,:';'
;
Visual Studio .NET --!
, ,
, Visual Studio .NET.

II Visual Studio .NET

144

FriendlyName Description
FriendlyName Description
. , , Add-in Manager, FriendlyName Description Description .
FriendlyName Description ,
ID DLL ( ^resource ID>). DLL ; Add-in Manager Plus.

AboutBoxDetails AboutBoxIcon
AboutBoxDetails AboutBoxIcon About Visual Studio .NET (. 6-6). FriendlyName Installed Products;
, AboutBoxIcon Product
Details, AboutBoxDetails.
AboutBoxDetails, AboutBoxIcon
, About ; .
About Wicrssuft Development f nviroiimeni
0.96
iesewf

oltCperi*t.
ratrascft .NET FrsmeweV 1.0
Copyright j 998.B3I31 Mkroseft Corporation.

1.0.3705

OOfllft Vbuda* KET 55537-640-3720153-iei


Mnosofl Vfcud . 55537-640-3720153-16I4S
Wuosoll Vbud C++ XI 555:17-640-3720153-16141

6-6.

About Visual Studio '

AboutBoxDetails , FriendlyName
Description: ID,
DLL ( #<resource ID>).
AboutBoxIcon , ,
:

145

, ID DLL ( ^resource ID>);


, ;
, ID
( <path>,<resource ID>); , C:\Program FiIes\Wicrosoft Visual Studio .NET 2003\Common7\IDE\devenv.exe, 1200
Visual Studio .NET;
.

( FriendlyName, Description AboutBoxDetails) , .
, ,

:
Sub SetAboutBoxIconfByVal addlnKey As RegistryKey, _
ByVal iconPath As String)
Dim iconFile As FileStream = File.QpenRead(iconPath)
Dim iconData(iconFile.Length) As flyte
Dim i As Integer
For i = 0 To iconFile.Length - 1
iconData(i) = iconFile.ReadByte
Next
addlnKey.SetValueC"AboutBoxlcon", iconData)
End Sub


! ,
, Win32, , , . ( Add-in Manager
Plus ,)
Icon Browser, ,
Web-: http://www.kennyandkarin.com/kenny.

-1116

1 46

II Visual Studio .NET


,
: : ! : ? , , Visual Studio .NET
,
: , , . , ... !

(IDE). .

?
Microsoft Windows , , , . , , . Windows SDK,
, Visual C++, - ,
, .
, Microsoft Visual Basic .NET Microsoft Visual C# . (,
.
, , , - ,
Visual Studio .NET IDE ,
Win32. - IDE Visual Studio NET
, . .
, . ,
File | New File. (add-on) [ (add-in)], Visual
C++ .NET, Visual Basic .NET Visual C# .NET, Visual Studio .NET , .

II

148

Visual Studio .NET

Win32- ,
, Visual Studio .NET , .

(GUID) , GUID .
, GUID,
, GUID, .
. GUID, ,
, GUID, , , , New File
New Project. , GUID, ,
. , ID , , GUID . GUID ID
.
Visual Studio .NET
(, )
. , -

. .


Visual Studio .NET , , Command, Commands. , ,
Command ,
foreach (Visual C#) For Each (Visual Basic .NET),
, , Command.
Sub WalkCommandsO
Dim cmd As EnvDTE.Command
For Each cmd In DTE.Commands
'

EnvDTE.Command.

Next

End Sub

[tern Commands , Item . Commandsltem , . , ' -1.


, , , GUID ID.

149

GUID ID Commands, GUID


, a ID . i
GUID ID:
Sub FindFileOpenCommandO

Dim cmd As EnvOTE.Command


cmd = DTE.Commands.Item("{5EFC7975-14BC-11CF-9B2BEnd Sub

OOAA00573819}", 222)

, ,
GUID ID ( ) . CommandsJtem

.


GUID ID , Visual Sludio
.NET
. : ,
, , , , , , , . ,
( - ),
. Command , :
Sub FindFileOpenCommandByNameO
Dim command As EnvDTE.Command
command = DTE.Commands.Item("File.OpenFile")
End Sub

GUID ID , GUID
Command. GUID ID, ]
FindFileOpenCommand, . ,
:
Sub FindQuidlDPairt)
Dim guid As String

Dim id As Integer
Dim command As EnvOTE.Command
command = DTE.Commands.Item("File.OpenFile")
guid = command.Guid
id = command.ID
MsgBox(guid + ", " + id.ToStringO)

End Sub

Options
(. 7-1). Environment | Keyboard, .

II Visual Studio .NET

150

Environment

General
Document:!
Dynamic Help

Keyboard mapping scheme:


([DeradTsettings]
Show cjameiands containing:

Fonts and Colors


Help
International Setthg?
* Keyboafd
Projects and Solution '
Task List
Web Browser
Source Control

| F ile . AddExi st in g Project


j F ile . AddExi st in g P ro jectFro rn W eb
File.AddNewltem
|File.AddNewPro]ect
f File . AddPrc ject F rom 5 ou rce Cont rol
Shortcuts) far selected command;

Text Editor
Database Tools
J3 Debugging

.
ia HTML Designer

Use pjaw shortcut in:

ftsss shortcu

Global
Shortcut csitentfy used

Canes!

. 7-1. Options

. EnvDTE.Commands :
Sub CreateCommandListO
Dim command As EnvDTE.Command
Dim output As New OutputWindowPaneEx(DTE, "Create Command List")
For Each command In DTE.Commands
If (command.Name <> Nothing) Then
output.WriteLine(command.Name)
End If
Next
End Sub
Output .
, Nothing.
, , ,
Nothing Visual Basic .NET null #. .NET Framework SystetnString , ("").
, Nothing. Visual
Studio .NET, , , . , .


Visual Studio
,NET .
,
. . , -

151

, ( , ,
),
. Macro Explorer , . DTEExecuteCommand, , , ,
.
File.OpenFtte ExecuteCommand, :
Sub RunFileOpenCommandO
DTE.ExecuteCommand("File.OpenFile")
End Sub

ExecuteCommand , .
, , , 1, , , ; Enter, . ,
, , CommandName ExecuteCommand.


, , ,
, .
.Macros, , ,
, ; .
TurnOnLineNumbers Samples,
Visual Studio .NET, MacrosSamples.Utilities.TurnOnLineNumbers.
, , :
Sub RunCommandO
DTE.ExecuteCommandC"Macros.Samples.Utilities.TurnOnLineNumbers")
End Sub


. ,
, Visual Studio .NET, no GUID, ,
, . \ .
, . , ,

1 52

II Visual Studio .NET

Visual Studio .NET . AddNamedCommand, , - DTE.Commands, :


public EnvDTE.Command AddNamedCommandCEnvDTE.AdiJIn Addlnlnstance,
string Name, string ButtonText, string Tooltip, bool MSOButton,
int Bitmap = 0, ref object[] ContextUIGUIDs,
int vsCommandDisabledFlagsValue = 16)

.
Addlnlnstance Addln, .
Name . , . ,
ToolTip .
MSOButton True, ,
, , ; False, DLL, .
Bitmap MSOButton True, . HTML- CommandUIBmps,
, . /SOButton False,
DLL.
ContextUIGUIDs .
$ystem.Object.

vsCommandDisabledFlagsValue
, . , , , , ,
, . , StatusOption IDTCommandTarget.QueiyStatus, .
AddNamedCommand ,
Visual Studio .NET. , ExecuteCommand, ProgID ,
Name. , , AddNamedCommand, mand, a ProgID MyAddin.Connect,
MyAddin.ConnectMyCommand.
, ,
GUID ID. GUID, , AddNamedCommand, EnvDTE.Constants.vsAddlnCmdGroup;
ID AddNamedCommand 1, 1. , ID,

153

4 294 967 296 , .


, V i s u a l
Studio .NET , . , , ,
. ; . , , , , , ,
OnConnection IDTExtensibility2, (Add-in Manager)
.
( ),
.
IDTCommandTarget
lOleCommandTarget Win32 SDK, , IDispatch :
public interface IDTCommandTarget
{
public void ExecCstring CmdName,
EnvDTE.vsCommandExecOption ExecuteOption, ref object Variantln,
ref object VariantOut, ref bool Handled);

public void QueryStatusfstring CmdName,


EnvDTE.vsCommandStatusTextWanted NeededText,
ref EnvDTE.vsCommandStatus StatusOption,
ref object CommandText);

, ,
Exec. Exec .
CmdName . , , ( ), H.I , .
vsCommandExecOption
vsCommandExecOptionDoDefau.lt, ,
, , .
Variantln , , .
( ), null Nothing ( , ).

154

Visual Studio .NET

VariantOut . Visual Studio .NET , .


Handled Visual Studio .NET , , . true, , false Visual
Studio .NET . , ,
GUID ID, , .


. , ,
.
: , (latched) (
,
).
QueryStatus IDTCommandTarget. ,
, AddNamedCommand. ( Add-in Manager),
QueryStatus.
.
CmdName , CmdName Exec IDTCommandTarget.
NeededText vsCommandStatusTextWantedNone. ,
Visual Studio .NET.
StatusOption , Visual Studio .NET ,
(vsCommandStatusSupported) (vsCommandStatusUnsupported);
(vsCommandStatusEnablecf); (vsCommandStatusInnisible);
(vsCommandStatusLatcbed).
, * .
CommandText Visual Studio
,NET, .
, , , , Visual Studio
.NET QueryStatus, , .
, QueryStatus, ,
. ,

155

,
. QueryStatus . , ,
, .
. , , , .


/ , , DTExecuteComtnand. ,
, , Visual Studio .NET,
QueryStatus, DTEExecuteCommand
( QueryStatus , , ), ( , .NET Framework).
CommandJsAvatlable. , ,
BuildBuildSolution , :

Sub CheckAvailabilityC)
If (DTE.Commands.Iteoi("Build.BuildSolution").IsAvailable = True) Then
DTE.ExecuteCommancK "Build. BuildSolution")
End If
End Sub


, Visual Studio .NET ,
,
IDTCommandTarget. ; , ProglD
, , AddNamedCommand
Name. Visual Studio .NET
ProglD , ,
ProglD, , . Visual Studio .NET IDTCommandTarget ( , tensibility2~) Exec,
.
, (. 7-2).
Yes, mandJDelete, .
,
IDTCommandTarget, , QueryStatus
vsCommandStatusUnsupported.

156

II

Visual Studio .NET

Microsoft Oei/elupinnnt Environment


f

The Add-in supporting this rowi^nd could not be loadod. Do you wisli Co remove the comnand?

. 7-2. , Visual Studio NET,



Visual Studio Microsoft Office.
, Office,
Visual Studio ,NET.
, .
DTE.CommandBars. Microsofl.Ojfice.Core.CommandBars, Office.dll.
:
Sub GetCommandBarsO
Dim coromandBars As Microsoft.Office.Core.CommandBars
commandBars = DTE.CommandBars
End Sub


,
Visual Studio .NET.
Microsoft.Office.Core.CommandBar, , .
, Microsoft.Office.Core.CommandBarControl,
- CommandBarControl
. CommandBarButton , ; Visual Studio .NET. CommandBarButton,
CommandBarControl-.
Sub GetCommandBarButtonO
Dim commandBarBtn As Microsoft.Office.Core.CommandBarButton
Dim commandBarCtl As Microsoft.Office.Core.CommandBarControl
Dim commandBarCtls As Microsoft.Office.Core.CommandBarControls
' View.
commandBarCtls = DTE.CommandBars.Item("View").Controls
' .

157

commandBarCtl = commandBarCtls.Item(l)
' CommandBarControl ComtnandBarButton.
commandBarBtn = CType(commandBarCtl,
Microsoft.Office.Core.CommandBarButton)
MsgBox(commandBarBtn.Caption)
End Sub

, Controls,
CommandBarPopup, .
New File; , . CommandBarPopup, , , New Project I INfew
Blank Solution Standard:
Sub GetCommandBarPopupQ
Dim commandBar As Microsoft.Office.Core.CommandBar
Dim cmdBarControl As Microsoft.Office.Core.CommandBarControl
Dim cmdBarPopup As Microsoft.Office.Core.CommandBarPopup
' "Standard"
commandBar = DTE.CommandBars.ItemC'Standard")
'
cmdBarControl = commandBar.Controls.Item(1)
' CommandBarControl CommandBarPopup
cmdBarPopup = CType(cmdBarControl,
Microsoft.Office.Co re.CommandBarPopup)
HsgBox(cmdBarPopup.Controls.Item(1).Caption)
End Sub

.
CommandBar, CommandBar, CommandBar, ( ).


DTE.CommandBars CommandBar,
Visual Studio .NET,
, File, Edit, View ;
CommandBar DTE.CommandBars. ,
, . , CommandBar View, View , .
View SQL.
View:
Sub GetViewO
Dim cmdbars As Microsoft.Office.Core.CommandBars
Dim commandBar As Microsoft.Office.Core.CommandBar

1 58

II Visual Studio .NET

cmdbars = DTE.CommandBars
commandBar = cmdbars. Item("View")
End Sub

, CommandBar ,
, View:
Sub GetMenuCommandBarO
Dim commandBar As Microsoft.Office.Core.CommandBar
Dim cmdBarControl As Microsoft.Office.Core.CommandBarControl
Dim cmdBarPopupView As Microsoft.Office.Core.CommandBarPopup
Dim cmdBarView As Hicrosoft.Office,Core.CommandBar
' .
commandBar = DTE.CommandBars.Item("MenuBar")
' View.
cmdBarControl = commandBar.Controls.Item("View")
' CommandBarPopup
cmdBarPopupView = CType(cmdBarControl, _
Microsoft.Office.Core.CommandBarPopup)
' CommandBar View
cmdBarView = cmdBarPopupView.CommandBar
MsgBox(cmdBarView.Name)
End Sub

, , Tools,
Tools .
, Tools ;
.
, ,
, , .


Command ( Commands )
,
, .
Command AddControl. Visual Studio .NET
. ,
AddControl, ,
Visual Studio .NET .
AddControl CommandBar, .

( 1, , 2 . .).
,
, , . ,

159

(, -
),
. , . , , , QueryStatus
vsCommandStatusInvisible.
,
Controls.Count:
Sub AddControK)
Dim command As EnvDTE.Command
Dim commandBar As Microsoft.Office.Core.CommandBar
' File.OpenFile,
command = DTE.Commands.Item("File.OpenFile")
' Tools.
commandBar = DTE.CommandBars.Item("Tools")
' Tools ,
' File.OpenFile,
command.AddControl(commandBar, commandBar.Controls.Count + 1)
End Sub

:
. 1,
1,
.
, ,
. , .
, . ., Visual Studio .NET , .
, , .
Visual Studio .NET CommandsAddCommandBar,
public object AddCommandBarCstring Name, EnvDTE.vsCommandBarType Type, _
Microsoft.Office.Core.CommandBar CommandBarParent = null, int Position = 1)

.
Name , .
vsCommandBarType. vsCommandBarTypeToolbar,
, , Visual Studio .NET. Ecn
vsCommandBarTypeMenu, . vsCommandBaflypePopup,
.

1 60

II

Visual Studio .NET

CommandBarParent , ,
vsCommandBaftypeToolbar vsCommandBarTypePopup, null Nothing ( ).
, , vsCommandBarTypeMenu,
.
Position ,
vsCommandBarTypeMenu.
. ,
Position AddControl.
.
, ,
.
, Visible CommandBar True. ,
CommandBarSbowPopup, :
^, .


Visual Studio .NET
, .
, DLL, {
DLL . 6), CommandsAddNamedCommand, Visual Studio .NET . -
MSOButton AddNarnedComtnand false, . . ,
,
DLL. -, Bitmap (ID) DLL.
Visual Studio .NET
: 16x16 16 . Visual Studio .NET . ,
0,254,0 RGB (red, green, blue). ( - , Visual Studio .NET
Paint Windows.)
, , . CustomBitmap , . , DLL,
, ,
DLL.
, , ,
Tools, . , (CustomBicmap\ CustomBitmapUI\untitled.bmp) , ;
. , AddNamedCommand, .

161

, MSOButton true HZ false, Bitmap 59 1 (1 ):


Command command = commands.AddNamedCommancKaddlnlnstance, "Customflitmap",
"CustomBitmap", "Executes the command for CustomBitmap", false, 1,
ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported +
(int)vsCommandStatiis.vsCommandStatusEnabled);



( ) - . - ,
. Visual Studio .NET , Visual
Studio .NET. , , .
- Visual Studio .NET ,
.
,
. Visual Studio .NET,
File Exit ( ),
. V isual
Studio .NET, , , ,
,
, . ,
, *! .
. ,
,
, F5. ,
Visual Studio .NET ( File | Exit ),
. Visual Studio .NET
, . .
.

devenv /setup
. -,
Visual Studio .NET ( MS DOS)
devenv /setup. Visual Studio .NET , CommanciBar,
. devenv /setup
, Visual Studio .NET .

162

II Visual Studio .NET

! devenv/setup : : , , (,
) .
ResetCmdBarlnfo,
. ResetCmdBarlnfo Tools.
Visual Studio .NET.
/setup. Visual Studio .NET
, .
, devenv /setup .

CommandPreload
(. 6), . Visual C++,
, .rgs, . NET-
, - Visual C++.
-
.NET. . NET Framework ,
SystemJtuntimeJnteropSeruices: ComRegisterFunctionAttribute
ComUnregisterFunctionAttribute. (#) (Visual Basic .NET) ,
System.Type, RegAsm- .NET - (
). , :
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type t)
;
string progID = String.Empty;
foreach (System.Attribute attrib in t.GetCustomAttributes(false))
{
if (attrib.GetTypeO.FullNaroe ==
"System.Runtime.InteropServices.ProgldAttribute")
I
ProgldAttribute progldAttrlb = (ProgldAttribute)attrlb;
progID = progldAttrib.Value;
!
if (progID != String.Empty)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(
@"Software\Microsoft\VisualStudio\7.1\AddIns\" + progID,
true);

if (key != null)
I
if (((int)key.GetValue("CommandPreload", -1)) == 2)
:
key.SetValue("CommandPreload", 1);

key = Registry. CurrentUser.OpenSubKey(


@"Software\Microsoft\VSA\7.1\AddIns\" + progID, true);
if (key != null)
{

if (((int)key.GetValue("CommandPreload", -1)) == 2)
key. SetValue( "CommandPreload" , 1 ) ;

key = Registry. CurrentUser.OpenSubKey(


@"Software\Microsoft\VisualStudio\7.1\PreloadAddinState
true);
if (key != null)
{
key. DeleteValue(progID, false);
}
key = Registry. CurrentUser.OpenSubKey(
e"Software\Nlcrosoft\VSA\7. 1\PreloadAddinState", true);
if (key != null)
{
key. DeleteValue(progID, false);

[ComUnregisterFunctionAttribute]
public static void UnregisterFunctlon(Type t)
{

string progID = String. Empty;


foreach (System. Attribute attrib in t.GetCustomAttributes(false))
{
if (attrib. GetTypeO.FullNaire ==
"System. Runtime. InteropServices.ProgldAttribute")
{
ProgldAttribute progldAttrib = (ProgldAttribute)attrib;
progID = progldAttrib. Value;

163

If Visual Studio .NET

1 64

if (progID != String.Empty)
.

RegistryKey key = Registry.CurrentUser.OpenSubKey(


@"Software\Microsoft\VisualStudio\7.1\PreloadAddinState",
true);
if (key l= null)
key.DeleteValue(progID, false);
key = Registry.CurrentUser.OpenSubKey(
9"Software\Microsoft\VSA\7.1\PreloadAddinState", true);
if (key != null)
key.DeleteValue(progID, false);

}
? , , , . , ,
ProgID - ProgldAffiibute. , ProgID
.
; 2. 1.
Visual Studio .NET Visual
Studio .NET ( ).
, .
. , Visual Studio .NET
, ,
. ReRegisterCS
.

, . ,
.
,
: . , ,
Tools. , ,
, View.

165

CommandPreload,
.


, ,
, , , Visual Studio .NET, AddN&~
medCommand , Delete, . . - ,
Visual Studio .NET , -::
.
, 10 , ,
10 ,
, .
, Visuiii
Studio .NET . , Visual Studio .NET , , .
Microsoft : Visual
Studio .NET . Microsoft
, : ,;1; , ,
. ,
.


, ; , Visual Studio .NET, ,
. CommandJDelete;
, , , , .
Sub DeleteMyCommandO
DTE.Commands.Item("MyAddin.Connect.MyCommand").DeleteO
End Sub

,
. , ,
- , . . , ( ) / . - , SystemCon-

166

II Visual Studio .NET

ftgurationJnstallJnstaller Runlnstaller(true).
, Install Uninstatt,
. .
Add New Item Installer Class (. 7-3)Add New Hem - MyAddin
gortes;
| local Project Itarns

i Web Custom Inherited User


Control
Control

Text Rle

Frameset

Stylesheet

Windows
5ervice

XSLT Rle

Bitmap Fife

: A das to be invoked at setup time


:

firisfalierl.es

Open

. 7-3.

caned

Help

OKWO /ld# ,Yew Item Installer Class

Uninstatt Install Installer.


devenv.exe ( Visual Studio .NET). -
, , Visual Studio .NET . Uninstatt, ,
Delete . , .
Install, CommandPreload, Visual Studio .NET
. , , Visual Studio .NET
,
. , Visual Studio .NET . Visual Studio .NET ,
.
bool IsVSRunningO
'

System.Diagnostics.Process []processes =
System. Diagnostics. Process. Get ProcessesO;
foreach(System.Diagnostics.Process process in processes)

7
// try/catch.
// ,
//ProcessModule ,
try
{
if((process != null) && (process. MainModule != null))
(
//
// 'devenv.exe'.
string fileName = process. MainModule. FileName;
fileName = System. 10. Path. GetFileName(fileName);
if(System. String. Compare(fileName, "devenv.exe") -= 0)
return true;
>
;
catch (System. Exception ex)
i
return false;
public override void Uninstall(System. Collections. IDictionary savedState)
(
base, Uninstall( savedState);
System. Windows , Forms. MessageBox, Show( "Uninstall" ) ;
while(IsVSRunningO)
I
System. Windows. Forms. MessageBox. Snow( "A running instance of Visual " +
Studio .NET was found. \n\nPlease close all copies of Visual " +
"Studio .NET, then press OK.", "Uninstall...",
System. Windows. Forms.MessageBoxButtons.OK);
}
EnvDTE.DTE dte = new EnvDTE, DTEClassQ;
//
// .
//
// .
dte. Commands. It em( "MyAddinI . Connect . MyAddinI " , -1 ) . Delete( ) ;
.
public override void Install{System, Collections. IDictionary stateSaver)
I
base. Install(stateSaver);
System. Windows. Forms. MessageBox. Show( "Install");
while(IsVSRunningO)
I
System. Windows. Forms. MessageBox. Show("A running instance of Visual " +
"Studio .NET was found. \n\nPlease close all copies of Visual " +
"Studio .NET, then press OK.", "Install...",

167

1 68

II

Visual Studio .NET

System.Windows.Forms.MessageBoxButtons.OK);

I
EnvDTE.DTE dte = new EnvDTE.DTEClassC);
}


, .
, (Custom Actions
editor) :
View | Custom Actions. (primary
output) Uninstall Install ,
Custom Actions, Add Custom Action,
Application Folder Select Item In Project
Primary Output From Addin Project Name.
,
.
, .
. , , (. 7-2), Yes,
.


, , .
, DTEMxecuteCommand. , MyAddin.Connect.Command.
:
MyAddin.Connect.Command
MyAddin.Connect.Command My Parameters

IDTCommandTargetExec ,
Varln . Varln
My Parameters. , ( ),
Varln.
. ExecuteCommand;
ExecuteCommand .
, , , , .
, , . , .
Windows

169

/? .
Visual Studio .NET .
/? IDTCommandTargetJExec ExecuteOption,
vsCommandExecOption.vsCommandExecOptionShoivHelp. ,
, ,
Web- . CommandHelp
1
/' .
. , , :
Sub OptionalArguments(Optional ByVal optArg As String = "I am optional")
MsgBox(optArg)
End Sub
ExecuteCornmand,
, . , I am optional,
, .
, ,
, :
/?, .
:
Sub OptionalArguments2(Qptional ByVal optArg As String = "I am optional")
If (optArg = "/?"> Then
Dim helpString As String
helpString = "Usage: OptionalArguments [optArg]"
helpString = helpString + vbLf
helpString = helpString + "This macro will display in " + _
"a message box the passed argument."
HsgBox(helpString)
Else
HsgBox(optArg)
End If
End Sub


,
, . . ,
File, Open File, Ctrl+O, Open File ,
. CommandBindings . -

1 70

II

Visual Studio .NET

, , . ; , .
:
Sub GetFileOpenBindingsO
Dim bindings As Object()
Dim binding As Object

bindings = DTE.Commands.Item("File.QpenFile").Bindings
For Each binding In bindings
MsgBox(CStr(binding))

Next
End Sub

, .
:

::+,

|2 +2

.
, . , Ctrl+B HTML-
; (
), .
HTML-, , Ctrl+B
. ,
Global.
, . Ctrl+B , Global,
HTML Editor Design View , , HTML-, .
,
, . Alt, Shift Ctrl. ;
, +.
102- ( Windows-, Windows, , Fn ). , , Fl, F2 . . Esc,
. -, .
Shift Alt, Ctrl, , (, Shift+A ). ,

171

, - , , Shift ( ), Bkspce,
Del, Ins. , F1 F24, Enter. Break, -, -, -, -, Tab. Home, End, PgUp, PgDn, Esc, NUM
*, NUM -, NUM + NUM /, Caps Lock, Print Screen, Num Lock Pause
, .
2 2
. ,
. , , Ctrl+Shil't+D,
Ctrl+Shil't+D.
S . 2 , , 2 .
, Ctrl+Shift+D,O
Global, , :
Sub SetKeyBindingO
Dim command As Command
command = DTE.Commands.ItemC'File.OpenFile")
command.Bindings = "Global:;Ctrl+Shift+D,0"
End Sub

Bindings
, ,
System.Object,
SystemStting:
Sub SetKeyBindingsO
Dim command As Command
Dim bindings(l) As Object
bindings(O) = "Global::Ctrl+Shift+D, 0"
Dindings(l) = "Global::Ctrl+Shift+D, F"

command = DTE.Commands.Item("File.OpenFile")
command,Bindings = bindings
End Sub
,
, , , - , .
, Ctri+O
, , , :
Sub SetKeyBindingsPreserveO
Dim command As Command
Dim bindings() As Object
Dim preserveLength As Integer
command = DTE.Commands.ItemC'File.OpenFile")
' ,
bindings = command.Bindings

172

Visual Studio .NET

'
preserveLength = bindings.Length
' 2 (, preserveLength
' 1 , , ,
' 1, 2 ).
ReDim Preserve bindings(preserveLength + 1)
' .
bindings(preserveLength) = "Global::Ctrl+Shift+D,0"
bindingsCpreserveLength + 1) = "Global::Ctrl+Shift+D,F"
command.Bindings = bindings
End Sub


: Setting key bindings valid only when using a
non-built-in key binding scheme ( , , ).
, , Visual Studio
.NET, . , , .
Options Environment | Keyboard, Save As, Scheme Environment | Keyboard .
.vsk ( .vsk) , .
Visual Studio .NET
:
Sub ChangeKeyboardSchemeC)
Dim props As EnvDTE.Properties
Dim prop As EnvDTE.Property
Dim path As String
Dim folder As System.Environment.SpecialFolder
' Scheme Environment, Keyboard,
props = DTE. Properties("Environnient", "Keyboard")
prop = props,Itemf"Scheme")
' , ,
folder = System.Environment.SpecialFolder.ApplicationOata
path = System.Environment.GetFolderPath(folder)
path = path + "\Microsoft\VisualStudio\7.1\scheme.vsk"
' ,
prop.Value = path
End Sub

:

Visual Studio .NET
. .
- , -

173

, .
,
. ,
;
Sub GenerateCofflaandCheatSlisetO
Dim cmd As Command
Dim selection As TextSelection
Dim binding AS String
Dim newDocument As Document
' , .
newDocument ~ DTE.Ite0perations.NewFile(
"ral\Text File").Document
selection = fiewBeciment. Selection
' ;
For Each end In DTE.Commands
If {cmd.Name <> Nothing) Then
Diai str As String
'
' :
str = cmd.Hame
str 9 str.PadHi8ht(7G)
' .
If (cntd.Bindings, Length > 6) Then
For Each binding In cmd.Bindings
str = str + binding
selection.Insert(str + vbtf)
. -str ""
str = str.PadRight(70)
Next
Else
selection.Insert(str + vbLf)
End If
End If
Next
End Stjfc


Visual Studio .NET . , .

JVlicrosoft Visual Studio .NET . . , .


, , .


Visual Studio .NET (solution)
, , .
, ,

, . Solution Explorer, , . Solution Explorer, , , .
Visual Studio .NET EnvDTESolution, Solution DTE:
Sub GetSolution()
Dim solution As EnvDTE.Solution
solution = DTE.Solution
End Sub

175

,
Solution , . Solution
Solution Explorer . Visual Studio .NET
, ,
. ,
. (, ),
.
, SolutionSai -eAs,
( .sin), .
. , , SolutionSaveAs , .
Create. , . Create SaveAs, TI , :
Sub CreateAndSaveSolution()
DTE.Solution.Create{":\", "Solution")
DTE.Solution.SaveAs("C:\Solution.sin")

End Sub
,
, Solution.Open. CreateAndSaveSoIution, :
DTE.Solution.Open(":\Solution.sin")
, . , ,
. , . ItemOperationsPromptToSave, . ItemQperations, DTE,ItemOperations, .
PromptToSave ,
, , .
, . ,
, , .
PromptToSave Open:
Sub OpenSolution()
Dim promptResult As vsPromptResult
' :
promptResult = DTE.ItemOperations.PromptToSave

1 76

Visual Studio .NET

' Cancel,
' :
If promptResult <> vsPromptResult.vsPromptResultCancelled Then
DTE.Solution.Open("C:\Solution. sin")
End If
End Sub

, . . Solution
Close, . Boolean,
Visual Studio .NET .
true, ; false .


Solution Project , ,
, . Item , , . Solutionltem
Item. SolutionJtem
, . , , .
, Visual Studio .NET
, . (Visual Studio
.NET 2003 , ,)
Visual Studio .NET 7.1 ,
Item, .
Projecl.UniqueName.
, :
Sub EnumProjectsO
Dim project As EnvDTE.Project
For Each project In DTE.Solution
MsgBox(project.UniqueName)
Next
End Sub

Solution .
Solution Projects,
, ,
Solution.
, , Visual Studio .NET, ,
Solution . , , Projects. EnumProjects Projects:

177

Sub EnumProjects2()
Dim project As EnvDTE.Project
For Each project In DTE.Solution.Projects
MsgBox(project.UniqueName)
Next
End Sub

Solution Projects ,
, Solution
Explorer. DTEActiveSoiutionProjects.
Visual Studio .NET Solution Explorer .
,
Project . , , .
, . , :
Sub FindSelectedProjectsQ
Dim selectedProjects As Object()
Dim project As EnvDTE.Project

selectedProjects = DTE.ActiveSolutionProjects
For Each project In selectedProjects
MsgBox(project.UniqueName)
Next
End Sub


Visual Studio .NET ,
.
SolutionEvents,
EventsSolutionEvents. , , EnvironmentEvents , SolutionEvents
, .
.
void OpenedQ .
void Renamed (string OldName) . ,
,
.
void ProjectAdded(EnvDTE.Project Project)
. , ,
EnvDTEProject .
void ProjectRenamed(EnvDTE.Project Project, string OldName) .
. EnvDTEProject

7-1116

1 78

II Visual Studio .NET

. , .
void ProjectRemoved(EnvDTE.Project Project)
.
EnvDTE Project . BeforeClosmg, ,
( , ) .
void QueryCloseSolution(ref 1 fCancel) , Visual Studio .NET .
Boolean. , true, , false. He

,
.
voidBeforeClosingO , , , ( ,
).
,
, .
voidAfterClosingQ .

SolutionEvents ( 8-1)
.
. QueryCloseSolution .
8-1.
Sol ution Events, s
RSiiespace SolutlonEvents
{

using
using
yslng
using

System;
Microsoft,Office,Gore;
Extensibility;
System.Runtime.InteropServices;

using EnvBTE;
(QuidAttribute(''1FFOC2Q3-SG36-4A54-A71A-BOF82BA6GBOC")f
ProgItf("SolutlonEvflfits. Connect")]

public class Connect : Object, Extensibility.IDTExtensibility2

179

public CorweetO

void QnGoiMiectioiK abject application,


Extensibility. ext_ConneetHode conneetHode,
object addlnlnst, ref System. Array custom)
{
applieationQbjeet = _DTE)ap plication;
;:: addlnlristance = (Addln)addlnlnst;
// solutionEvents,
// . Events. Solution Events:
solution Events = (EnvDTE.SolutionEvents)
appl ieationQb J act . Events . Solution Events ;
// ,
// :
solutionEvents.AfterClosiRB t= new
dispSQlutionEvents_AfterCloslngEventHandler(Aft0rClDSirig);
solutionEvents.SeforeGlosing += new
_dispSoIutionEvents_8eforeCloslngEveritHa^ler(BeforeClosing)..
solutionEvents. Opened += new
_dispSolutionEvent3_Openeo'EventHandler(0-penect);
solutionEvents.ProjectAdded +* new
_dispSolutionEvents_ProjectA{j<ledEvent3Handl.er(ProjectAd<fed);
solutionEvents.ProjectReiBoved += new
, {ProjectReiRQvea1);
solutionEvents. ProjectRenased += new
_dispSolutionEvents_ProjectRenatnedEventHandler
(ProjectRenanted);
solutionEvents.QueryCloseSolution +- new
_dispSolutlonEvents_QoeryCloseSolutionEventHandler
(QueryCloseSolijtion);
solutionEvents.Benaffied += new
_di spSol u t ion Even t s_Renamed Eve ntHan tile ( Ren an ed > ;

public void QnD3sconnection(


Extensibility. ext_DisconnectHode dlsconnectHode,
ref System. Array custom)
I
// . :

solutioriEvents.AfterClosing -- new
_dispSolutionEvent3_AfterGlosingEventHandler(AfterClosing);
solutionEvents.BeforeClosiR^ -= new
dispSoltitionEvents_8eforeClosingEventHandler(8eforeClostng;;
solutionEvents. Opened ~~ new

. . .

1 80

II

Visual Studio .NET

SQlutionEvents.ProjectAdded -= new
_dispSalutionEvents_Pro3eetAddedEventHaficller{ProjectAdded);
solutionevents.ProjectRemovetf -= new
.dlspSolutlonEvents^ProjectRemovedEvHntHaftdler
{Projectfletnoved);
solutioflEvsflts.ProjectRenamed -= new

_dispSalutionEvents_ProjectRenamedEventHandler
<ProjectflenaBied);
SGlutionEvents.QueryClQseSolution -= new
_dispSolutionEvents_QueryCloseSolutiofiEventKandler<
QueryCloseSolution) ;
solutionEvents. Renamed -= new
_dispSalutiGnEvenl:s_RenamedEventHandler(Renamed};

public void OnAddInsUf)dat{ref Systeie. Array custom)

public void GnStartupCompleteCref System. Array custom)

public void Qn8eginShutdown(ref System. Array custom)

//- SolutiorvEvents.AfterClosing:

public void AfterClosingC)


I

System. Windows. Forms. MessageBox. Show(


"SolutionEvents.AfterClosing",
"Solution Events");

//- SolutionEvents.BeforeClosing:
public void BeforeClosingO
{
System. Windows. Forms. MessageBox. Sho(
"SolutionEvents.BeforeClosing",
"Solution Events");

//- SolutionEvents . Opened:


public void OpenedO
{

System. Windows. Forms. Message&ox. Show( "SolutionEvents. Opened


1
"Solution Events' );

181

//- SolutlonEvents.ProJectMded.
// UniqueName .
public void Project Added (F-nvDTE. Project project)
{
System, Windows, Forms. MessageBox, Show{
"SolutionEvents.ProjectAddedXnProject: " + project. Uniqueflaroe,
"Solution Events"};

//- SolutionEvents.ProjectReBioved.
// MniqueName .
void ProjeetRemovad{nvDTE. Project project)

System. Windows. Forms. MessageBox. Snow(


"SoUitior)vents.Projectfiemoved\nPrQjeet; " +
project. UniqueName, "Solution Events");
I

//- SolutionEvents. ProjectRemoveo1.


// UniqueName
// .
public void ProjectRenameeKEnvQTE. Project project, string oldName)
{
System. Windows. Forms. Hessage8ox.Show(
"SolutioRvents.Projectfiename6\nProject: " +
project. UniqueNasie
+ "\n01d project name: " * oldHame, "Solution Events")

//- SolutionEveflts. QueryCloseSolutiont


// .
public void QueryCloseSolution(ref bool cancel)
i
if (System. Windows. Forms. essageSox , Show<
"Solutionvents.QueryCloseSolution\nContinue with close?",
"Solution Events",
System. Windows . Foras . Message Box But tons. YesNo)aa
System. Windows. Foras.OialogResijlt.Yes)
cancel = false;
else
cancel = true;

I
//- SolutionEvents.QueryGloseSoluttOfl..
//
// .
public void Renamed(string oldName)
{
System . Windows . Fo rres . HassageBox . Show(
. .

182

II Visual Studio .NET

"SGlutionEvervts.RenaffiedViHew solution name: " *


applicationSbject. Solution. Fullfteme + "\n01d solution name
+ oldNaiae, "Solution Events");
private _DTE appllcationOaject;
private Addln addlnlnstance;
// - :
private EnvDTE.SoluttonEvsnts solution Events;

: ?
, ,
, . , .NET Framework. , :
public void Connect Sol tit ion Event sQ
{
EnvOTE.SoJutlonEvents solutionEvents;
solution Events = (ErwQTE. SolutionEvents)
applicationQbjeet.Events.SolutionEvents;
solutionEvents.Renaaed + new
dlspSoltiQREvent$_Renafli9dEventHandler(Renaieed);

Renamed s&tutionEvents So&ttiotiEv&nts. sotuficmEvents ; ConnectSolutionEvents,


ConnectSolutionEv&nU . - , , ,
, . , st^utionEvents . . ,
, 1, novio .NET Framework, Solution Renamed,


6 , Visual Studio .NET
. ,
Visual Studio .NET.

183

, Visual Studio .NET. Visual Studio .NET


. , IDTExtensibility2 (QnConnection,
OnDisconnection . .), , .
,
. , ,
. , ,
, , ,
.
Add-in Wizard ,
,
. ,
Visual Studio .NET .
,
(.sin). , . Add-in Wizard ,
, . , , !
, , .
, , ,
.
, .
Add-in Manager
,
.
.
SolutionAddlns Addlns ,
DTEAddlns, , . AddlnsAdd.
:
public EnvDTE.Addln Add(string ProgID, string Description, string Name ,
bool Connected)

.
ProgID - ProgID , .
Description . i Visual Studio .NET

1 84

II Visual Studio .NET

Name . , Visual Studio .NET.


Connected true,
; false, ,
.
( ),
. , ( Microsoft Visual SourceSafe),
,
; ,
.
, AddlnsAdd
. - Add-in Manager.
Visual Studio .NET , , (, ). SolutionAddinManager Solution
Explorer. ,
, , .


, ,
.


. , . . Projectltems ,
, Projectltem .
Projectltems Projectltem.
Projectltems Projectltem,
Projectltems ProjectProjectltems;
Sub EnumTopLevelProjectltemsO
Dim projltem As EnvDTE.ProjectItem
Dim projectProjectltems As EnvDTE.Projectltems
Dim project As EnvDTE.Project
' :
project = DTE.Solution.Projects.]tem(1)
' :
ProjectProjectltems = project.Prcjectltems
' :
For Each projltem In projectProjectltems

185

MsgBox(projItem.Name)
Next
End Sub

, , .
, , Projectltem, Project!'terns.
, Projectltem
Projectltem, ProjectltemProjectitems,
Projectltems, .
Projectltem Projectltems
:
Sub EnumProjectItems(ByVal projltems As EnvDTE.Projectltems)
Dim projltem As EnvDTE.Projectltem
' Projectltem ;
For Each projltem In projltems
MsgBox(projltem.Name)
' :
EnumProjectltemsCprojltem.Projectltems)
Next
End Sub
Sub EnumProject()
Dim project As EnvDTE.Project
' :
project = DTE.Solution.Projects.Item(1)
EnumProjectItems(project.ProjectItems)
End Sub

EnumProject Projectltems , .
EnumProjectltems, Projectltem,
. Projectltem ,
EnumProjectltems .
Projectltem , .
, Windows Forms Web Forms,
.
(.resx-), Web Forms, ,
. Solution Explorer ,
, , .
Solution Explorer ,
Project Show All Files. EnumProject (. ), ProjectltemProjectitems ,
Projectltem . ^Project ,
Show All Files.
Solution Explorer.

1 86

II

Visual Studio .NET


. , Windows Forms (. 8-1):

| References

. 8-1.

Windows Forms

Projectltem Projectltems, , , Bitmapl.bmp:


Sub FindBitmapC)
Dim project As EnvDTE.Project
Dim projectProjectltems As EnvDTE.Projectltems
Dim resourcesProjectltem As EnvDTE.Projectltem
Dim resourcesProjectltems As EnvDTE.Projectltems
Dim bitmapsProjectltem As EnvDTE.Projectltem
Dim bitmapsProjectltems As EnvDTE.Projectltems
Dim bitmapProjectltem As EnvDTE.Projectltem
' :
project = DTE.Solution.Item(1)
' :
projectProjectltems = project.Projectltems
' Resources:
resourcesProjectltem = projectProjectltems.Item{"Resources")
' Resources:
resourcesProjectltems = resourcesProjectltem.Projectltems
' Bitmaps:
bitmapsProjectltem = resourcesProjectltems.Item("Bitmaps")
' Bitmaps:
bitmapsProjectltems = bitmapsProjectltem.Projectltems
' Bitmap1.bmp;
bitmapProjectltem = bitmapsProjectltems.Item("Bitmap1.bmp")
MsgBoxfbitmapProjectltem.Name)
End Sub
Projectltem Projectltems,
Projectltem , . , ,
FindProjectltem Solution. , Addins

187

( Add-in
Wizard). MyAddinl MyAddin2
Connect.cs. Connect.cs :
Sub FindltemO
Dim projectltem As EnvDTE.Projectltem
projectltero = DTE.Solution.FindProjectItem("Connect.cs")
End Sub
, FindProjecffiem , , Projectltem : Projectltem
Connect.cs MyAddinl Projectltem Connect.cs MyAddin2. ,
, , ! >
, Connect.cs MyAddinl:
Sub FindltemWithFolderO
Dim projectltem As EnvDTE.Projectltem
projectltem = DTE.Solution.FindProjectItem("MyAddinl\Cormect.cs")
End Sub
, Projectltem ,
, :
Sub FindltemWithFullPathO
Dim projectltem As EnvDTE.Projectltem
projectltem =
DTE.Solution.FindProjectltemC"C:\Addins\MyAddin1\Connect.cs")
End Sub


. AddFromDirectory, AddFromFile, AddFromFtteCopy AddFromTemplate
Projectltems ( . 9).
ItemQperations, , .
Projectltems ItemOperations , Projectltems
, . ItemOperations ; , Solution Explorer, , ,
, . . Solution Explorer,
ItemOperations.
, ,
ItemOperations AddExistingltem . ,
. Visual Basic .NET # -

188

II Visual Studio .NET

. , Solution Explorer ,
. Visual C++ : , , , . , , file.txt \. :
Sub AddExistingltemO
DTE. ItemOperations. AddExistingItein( ": \file.txt")
End Sub
Solution Explorer # Visual Basic .NET , file.txt ,
, .
Visual C++, , .
AddExistingltem , AddNewItem
.
:
public EnvDTE.Projectltem AddNewItem(string Item = "General\Text File" ,
string Name = "")
,
Add | Add New
Item, Add New Item (. 8-2).

Custom
Control

Indented *orn\ Castors


Central

Inhered Use*

. 8-2. Add New Item


AddNewItem ,
AddNewItem
.
, -

189

. ,
Windows Forms
(Local Project Items) .
>, ,
Windows Forms,
. , , , Windows Form*, ,
AddNeu'Item-. Local Project Items\Uf\Windows Form.
.
, .
, .
Projectltem : Remove
Delete, , Delete , ' , .

,

Visual Studio .NET ,
. , . , #
(references node), Setup .
,
.
Visual Studio .NET, , Project.
Object
Project. System.Objecl, , . VSProject, Visual Basic .NET *.

VSProject
VSLangProj.VSProject EnvDTEProject
Visual Basic .NET #. EnvDTEProject
, VSLangProj.VSProject
Project.Object. , ,
Projects Visual Basic #, VSProject
:
Sub

GetVSProject()

Dim project As EnvOTE.Project

Dim vsproject As VSLangProj.VSProject


project = DTE. Solution. Projects. Itemd)
vsproject = CType(project.Object, VSLangProj.VSProject}
End Sub

1 90

II

Visual Studio .NET

,
, ,
IntelHSense. ,
. ,
. -,
- . .
References Visual Basic
#, Add Reference .
VSLangPrqjJleferences, ,
. References VSProjectReferences. , References , :
Sub EnumReferencesO
Dim proj As EnvDTE.Project
Dim vsproj As VSLangProj.VSProject
Dim references As VSLangProj.References
Dim reference As VSLangProj.Reference
proj = DTE.Solution.Projects.Item(1)
vsproj = proj.Object
references = vsproj.References
For Each reference In references
MsgBox(reference.Name)
Next
End Sub

1 , ReferencesAdd
.
(global assembly cache, GAC), Add
. ,
/ . :
Sub AddReferenceToAssemblyO
Dim vsproj As VSLangProj.VSProject
Dim proj As EnvDTE.Project
proj = DTE.Solution.Projects.Item(1)
vsproj = CType(proj.Object, VSLangProj.VSProject)
vsproj.References.Add{"C:\Program Friles\Microsoft Visual Studio .NET "
& "2003\Common7\IDE\PublicAssemblies\extensibility.dll")
End Sub

VSProject Extensibility.dll (, Visual Studio .NET -'


) , -

191

tensibility2, .
, GAC, Visual Basic #
,
.
.
ReferencesAddProject. Project -:
Sub AddProjectReference()
Dim vsproj As VSLangProj.VSProject
Dim proj As EnvDTE.Project
' , :
proj = DTE.Solution.Projects.Item(1)
vsproj = CTypeCproj.Object, VSLangProj.VSProject)
' , :
proj = DTE.Solution.Projects.Item(2)
' :
vsproj.References.AddProject(proj)
End Sub

-
, , COM: GUID
(LIBIU), -,
. , -, a Visual Studio .NET .
Windows Media Player:
Sub AddCOMReferenceO
Dim vsproj As VSLangProj.VSProject
Dim proj As EnvDTE.Project

proj = DTE.Solution.Projects.Item(1)
vsproj = CType(proj.Object, VSLangProj.VSProject)
vsproj.References.AddActiveX(
"{22D6F304~BOF6-11DO-94AB-0080C74C7E95}", 1, 0)
End Sub

Web-
.NET Framework , .
Web- XML. Web- ,
,
. Visual Studio .NET Web- XML Web-.
Web- XML ,
Web Services Description Language (WSDL) WSDL-
- (,

1 92

II

Visual Studio .NET

). - Web- XML.
Web-. VSProject
AddWebReference, URL Web-.
Web- TerraServer, Microsoft, . Web- bt(p://terra$erver.bomeadvisor.msn.com/TerraSenice.asmx
Sub AddTerraServerWebRefC)
Dim vsProj As VSLangProj.VSProject
Dim serviceURL As String
' URL Web- TerraServer.
serviceURL = "http://terraserver.microsoft.net/rraService.asmx"
' VSProject .
vsProj = DTE.Solution.Projects.Item{1).Object
' Web-.
vsProj.AddWebReference(serviceURL)
End Sub

Web- WSDL-, Web- XML, - . , , . , Web- ivwtv.microsoft.com,


com.microsqft.www. TerraServer
terraserver.homeadvisor.msn.com,
com.msn.homeadvisor.terraserver. Web-
, -.

: Web- XML
!

, ,
. , , , . . ? , , , Web- ;
TerraServer., Web- GPS-.
# Web-
TerraServer, ,
. , Place,
, , TerraSen'ice.(jefPlaceFacfs.
PlaceJFacts, . ,
, ;
,' ,- , .

193

static void Main(string[] args)


I
// :
com.msn.homeadvisor. terraserver. PlaceFacts placeFacts;
com.msn.homeadvisor.terraserver.TerraServi.ee terraService;
corn.msn. homeadvisor.terraserver. Place place;
// :
terraService = new com.msn.homeadvisor.terraserver.TerraService();
place = new com.msn.homeadvisor.terraserver.Place();
// , . :
place.City = "Redmond";
place.State = "Washington";
place.Country = "USA";
// Web- :
placeFacts = terraService.GetPlaceFacts(place);
// :
System.Console.Write(place.City + " Latitude and Longitude: ");
System. Console.Write(placeFacts. Center. Lat.ToStringO);
System.Console.Write{" ");
System. Console. WriteLine(placeFacts. Center. Lon.ToStringO);

Imports
,
Visual Basic .NET # Imports using, , , .
, , :
System.Windows.Forms.HessageBox.ShowC"Hello World")
,
, . , Visual Basic Imports-.
Imports System,Windows.Forms
:
MessageBox.Show("Hello World")
Visual Basic
Property Pages (. 8-3) Imports .
, , , Imports.

194

II Visual Studio .NET

. 8-3-
Property Pages
VSProjectJmports, , . Visual Basic .NET SystemXML:
Sub AddSystemXMLImportO
Dim vsProj As VSLangProj.VSProject
Dim vslmports As VSLangProj.Imports
vsProj = DTE.Solution.Projects.Item(1).Object
vsProj.Imports.AdcK"System.Xml")
End Sub

Imports Visual Basic


.NET. # null, a Visual Basic .NET Nothing,
Project.Properties
, . Common Properties Property Pages . , , (. .dll)
(layout options) HTML-. , Properties Project.
Properties, Visual Studio .NET . ,
:
Sub WalkVSProjectPropertiesO
Dim project As EnvDTE.Project
Dim properties As EnvDTE.Properties
Dim [property] As EnvDTE.Property
Dim owp As InsideVSNET.Utilities.OutputWindowPaneEx
owp = New InsideVSNET.Utilities.OutputWindowPaneExfDTE,

195

"Project properties")
project = DTE.Solution.Projects.Item(1)
properties = project.Properties
For Each [property] In properties
owp.WriteLineC'Name; " + [property].Name)
owp.WriteLineC'Value: " + [property].Value.ToStringO)
owp.Writel_ine("Type: " + [property]. Value.GetTypeO. FullName)
owp.WriteLineO
Next
End Sub

Property
, . . ,
, Icon.ico
.
Sub SetProjectlconO
Dim project As EnvDTE.Project
Dim [property] As EnvDTE.Property
Dim projectPath As String
project = DTE.Solution.Projects.Item(1)
' Property :
[property] = project.Properties.Item("ApplicationIcon")
' :
projectPath = project.FullName
projectPath = System.10.Path.GetDirectoryName(projectPath)
projectPath = projectPath + "\Icon.ico"
' :
[property].Value = projectPath
End Sub


Visual Studio .NET
Visual Studio .NET . ,
, .
, Microsoft Word, . , Visual Studio .NET , Visual Studio .NET Visual Basic .NET, C# Visual C++.

Miscellaneous Files
,
. Miscellaneous Files,
, -

1 96

II Visual Studio .NET

, , . Miscellaneous Files
, . Miscellaneous Files
Solution Explorer,
, Tools Options, Environment |
Documents Show Miscellaneous Files In Solution Explorer.
Miscellaneous Files ,
. <MiscFiles>
vsMiscFilesProjectUniqueName. Project Miscellaneous Files:
Sub FindMiscFilesProject()
Dim project As EnvDTE.Project
Dim projects As EnvDTE.Projects
projects = DTE.Solution.Projects
project = projects.Item(EnvDTE.Constants.vsMiscFilesProjectUniqueName)
End Sub

Miscellaneous Files
SolutionProjects, Project , Project, , Visual Basic
.NET #, , null
Nothing SystemNotlmplementedException.
Project,
Miscellaneous Files, Projectltem Projectltems. (. 8-1):
. 8-1. Project, Projectltems Projectltem
Project

Projectltems

DTE

DTE

Projectltem
DTE

Projectltems
Name ()
UniqueName
Kind
FullName

Parent
Item
GetEnumerator / _Neivlinum
Kind
Count
ContamingProject

Collection
Name ()
FtieCount
Kind
Filenames
SaveAs
Save
FsOpen
Open
Delete
Remove
ExpandView
ContainingProject
IsDirty

197

Miscellaneous Files ItemOperationsNewFile-.


public EnvDTE.Window NewFile(string Item = "General\Text File",
string Name = "", string ViewKind =
"{00000000-0000-0000-0000-000000000000}")

ItemOperationsAddNewItem, , NewFUe, ,
JtemOperationsAddNeivltem, ( ) ,
, .
, .
EnvDTE.Constants-. vsViewKind.

Solution Items
Miscellaneous Files . , Miscellaneous Files,
; , Solution Items,
. ,
, ,
, ,
. Miscellaneous Files,
Solution Items ,
EnvDTEJProject (, ). ' Solution Items , . 8-1, Miscellaneous
Files, Solution Items
SolutionProjects, Solution
Items. vsSolutionltemsProjectUniqueName:
Sub FindSolutionltemsProjectO
Dim project As EnvDTE.Project
Dim projects As EnvDTE.Projects
projects = DTE.Solution.Projects
project = projects, Iten(
EnvDTE.Constants.vsSolutionltemsProjectUniqueName)
End Sub

Solution Items AddNewltem Addllxistingltem ItemOperations. , Solution


Items Solution Explorer. Solution Items ,
, , , .


, , Project,
. , ,

198

II Visual Studio .NET

Project | Unload Project, Project, , Visual Studio -NET (unmodeled project type). Project,
: DTE, Kind Name.
Project , , ,
. ProjectKind, EnvDTE.Constants.vsProjectKindUnmodeled,
. , :
Sub FindUnmodeledProjectsO
Dim i As Integer
For i = 1 To DTE.Solution.Projects.Count
Dim project As EnvDTE.Project
project = DTE.Solution.Projects.Item(i)
If (project.Kind = EnvDTE.Constants.vsProjectKindllnmodeled) Then
MsgBox(project.Name + " is unmodeled")
End If
Next
End Sub
, , ,
FindUnmodeledProjects
. Visual Studio .NET, Project . ;
.


, ,
,
, . , ,
-,
. : , , , ,
, :
void ItemAdded(ByVal Project As EnvDTE.Project)
void ItemRemoved(Byval Project As EnvDTE.Project)
void IternRenanted(ByVal Project As EnvDTE.Project,
ByVal OldName As String)
:

199

void ItemAdded(ByVal Projectltem As EnvDTE.Projectltem)


void ItemRemovecKByVal Projectltem As EnvDTE.Projectltem)
void ItemRenamed(ByVal Projectltem As EnvDTE.Projectltem,
ByVal OldName As String)
: ItemAdded,
ItemRemoved, Item-Renamed. , , .

, Visual Studio .NET. , ,
EnvironmentEvents. Class Name
SolutionEvents, a
Method Name .
: . EnvironmentEvents ( #):
<System.ContextStaticAttribute()> _
Public WithEvents csharpProjectltemsEvents As EnvDTE, ProjectltetnsEvents
EnvironmentEvents. ,
, , .
# ,
csharpProjectltemsEvents
ProjectltemsEvents. ,
DTEEventsDnStartupComplete
, :
Private Sub DTEEvents_OnStartupComplete()
Handles DTEEvents.QnStartupComplete
csharpProjectltemsEvents =
DTE.Events.GetObject("CsharpProjectltemsEvents"}
End Sub

Visual Studio .NET OnStartttpComplete,


. , ; Visual
Studio .NET .
:
Sub ConnectCSharpProjectltemsEventsO
csharpProjectltemsEvents =
DTE.Events.GetObjectC"CsharpProjectltemsEvents")
End Sub

200

II Visual Studio .NET

Miscellaneous Files
Solution Items, . , Events.GetObject. ,
Visual Basic .NET , VBProjectsEvents
VBProjecffiemsEvents. VJSbarpProjectsEvents VJSbarpProjectitemsEvents Microsoft Visual J#, a eCSbarpProjectsEvents
eCSbarpProjectltemsEvents # Smart Device Application.
eVBProjectsEvents eVBProjectltemsEvents Visual Basic .NET smart device application. ProjectEvents
. , ,
.


,
, . Visual Studio .NET . SolutionBuUd;
SolutionSolutionBuild. ConfigurationManager .
Project.ConfigurationManager,


Visual Studio .NET (solution configurations). , .
,
. ,
,
.
(debug) (release),

. ,
Windows Forms, Visual Studio .NET ,
Windows Forms,
, Windows
Forms. ,
, , .
SolutionConfiguration SolutionContext
SolutionConfigurations, SolutionConfiguration. -
SolutionConfigurations ,
Item

201

SolutionConfiguration . SolutionConfigurationsAdd, :
public ErwDTE.SolutionConfiguration Add(string NewName,
string ExistingName, bool Propagate)
, .
NewName ,

. ( \, /,:, *, ?, , <
>.)
ExistingName ,
, <Default>*.
<Default>, .
Propagate true, ,
, , , . false, , ,
.
SolutionConfiguration , . Activate; ,
SolutionBuildBuild, SolutionConfiguration . , - .
SolutionContexts. , SolutionConfiguration
, . SolutionConfigurationSolutionContexts , .
, , ConfigurationName SolutionContext
, . , :
Sub ChangeProjectConfigurationO
Dim solutionBuild As EnvDTE.SolutionBuild
Dim solutionCfgs As EnvDTE.SolutionConfigurations
Dim solutionCfg As ErwDTE.SolutionConftguration
Dim solutionContext As EnvDTE.SolutionContext
' :
solutionBuild = DTE.Solution.SolutionBuild

II

202

Visual Studio .NET

solutionCfgs = solution8uild.Sol.utionConfigurations
solutionCfg = solutionCfgs.Item("Debug")
' :
solutionContext = solutionCfg.SolutionContexts.Item(l)
'
' :
solutionContext.ConfigurationName = "Release"
' :
solutionContext.ShouldBuild = True
End Sub

SolutionContext , ,
, , ,
. , ShouldBuild true.
, , .
,
.


( , F5),
, , , , , .
,
Solution Explorer Set StartUp Projects.
Solution Property Pages (. 8-4),
, Windows Forms.

. 8-4. ,

203

SolutionBuildStartupProjects.
System.Qbject, ,
. , StartupProjects,
: , ( ,
), System.Qbject (
, ).
, ,
. :
Sub SetStartupProjects()
Dim startupProjects(l) As Object
startupProjects(O) = DTE.Solution.Projects.Item(1).UniqueName
startupProjectsd) = DTE.Solution.Projects.Item(2).UniqueName
DTE.Solution.SolutionBuild.StartupProjects = StartupProjects
End Sub
, :
Sub SetStartupProjectO
Dint startupProject As String
startupProject = DTE.Solution.Projects.Item(1).UniqueName
DTE.Solution.SolutionBuild.StartupProjects = startupProject
End Sub
, , , . , SolutionButidStartupProjects, , , Miscellaneous Files
Solution Items, .
Visual Studio .NET ,
SolutionButidStartupProjects .
. Multiple
Startup Projects ; . SolutionBuild StartupProjects .

, , ,
. UserControl,
Windows Forms WinForm.
UserControl Windows Forms, UserControl WinForm. ,
(project dependency).
; 8-5

204

II

Visual Studio .NET

WinForm UserControl.
, .
WinFarm

UserControl

. 8-5. ,
WinPonn UserControl
, :
ClassLib, , WinForm.
UserControl. , 8-6.
WinForm

UserControl
ClassUb

. 8-6.

, WinForm ,
UserControl ClassLib. UserControl
ClassLib.
UserControl, ClassLib.
ClassLib, , . UserControl ClassLib ,
. , , WinForm.
.
,
, .
, WinForm UserControl, UserControl ClassLib, a ClassLib WinForm. ,
. 8-7.

ClassLib
. 8-7.

WinForm UserControl. ClassLib, WinForm. Visual Studio


.NET ,
. Visual Studio .NET
, .
Project} Project Dependencies.

205

Project Dependencies (. 8-8). ,


UserControl. WinForm ,
WinForm UserControl, Visual Studio .NET WinForm UserControl.

. 8-8.

. SolutionBuildBuildDependencies BuildDependencies, BuildDependency. , EnvDTEProject . EnvDTEBuildDependency, RequiredProjects ,


. Output
, ,
Sub DependsO
Dim projectDep As EnvDTE.BuildDependency
Dim project As EnvDTE.Project
Dim owp As New InsideVSNET.Utilities.OutputWindowPaneEx(DTE,
"Build dependencies")
For Each projectDep In DTE.Solution.SolutionBuild.BuildDependencies
Dim reqProjects As Object()
owp.WriteC'The project ")
owp.WriteCprojectDep.Project.Name)

owp.WriteLine(" relies on:")


reqProjects = projectDep.HequiredProjects
If (reqProjects.Length = 0} Then
owp.WriteLine(vbTab + "<None>")
Else
For Each project In reqProjects
owp.WriteLine(vbTab + project.Name)

206

II

Visual Studio .NET

Next
End If
owp.WriteLine()
Next
End Sub
BuildDependency , . , , WinForm, UserContro!
ClassLib, . BuildDependency
, : AddProject, RemoveProject RemoveAttProjects. AddProject RemoveProject ,
. RemoveAUProjects . SetDependencies
, -

. 8-6:
Sub SetDependenciesf)
Dim buildDependencies As EnvDTE,BuildDependencies
Dim buildDependency As EnvDTE.BuildDependency
Dim project As EnvDTE.Project
Dim winFormUniqueName As String
Dim userControlUniqueName As String
Dim classLibllniqueName As String
' .
For Each project In DTE,Solution.Projects
If (project.Name = "WinForm") Then
winFormUniqueName = project.UniqueName
Elself (project.Name = "UserControl") Then
LiserControlUniqueName = project.UniqueName
Elself (project.Name = "ClassLib") Then
classLibUniqueName = project.UniqueName
End If
Next
buildDependencies = DTE,Solution.SolutionBuild.BuildDependencies
For Each buildDependency In buildDependencies
If (buildDependency,Project.Name = "WinForm") Then
buildDependency.RemoveAllProjects()
' , WinForm.
' :
buildDependency.AddProject(userControlUniqueName)
buildDependency.AddProjct(classLibUniqueName)
Elself (buildDependency.Project,Name = "UserControl") Then
buildDependency.RemoveAilProjectsO
' ClassLib:
buildDependency.AddProject(classLibUniqueName)

207

End If
Next

End Sub


.
, ,
. , .
ConfigurationManager
ConfigurationManager,
Configuration . ,
(, ),
, .
Visual Studio .NET Win32 32-
Windows 8, .NET,
Microsoft .NET, Pocket PC Windows ,
Windows .
, .
.
Item, -.
Item ConfigurationManagerJtem . . ,
Item Configuration ,
. , Solution Explorer Visual C++. Configuration
Win32 :
Sub RetrieveDebugWin32Configuration()

Dim conflg As Configuration


Dim project As EnvDTE.Project

project = DTE.Solution.Projects.Item(1)
config = project.ConfigurationManager.ItemC'Debug", "Win32")
End Sub
ConfigurationManager.ConfigurationRow ConfigumtionManagerPlatform,
. Configuration, , . ConfigurationRow
; Platform
. , , , ,
Win32 Visual C++ .

208

II

Visual Studio .NET

.NET Framework C++. . Win32, , Properties


ManagedExtension true, ,
.NET Framework.
Sub SetManagedExtensionsPropertyf)
Dim configManager As ConfigurationManager
Dim configs As Configurations
Dim config As Configuration
Dim project As EnvDTE.Project
project = DTE.Solution.Projects.Item(1)
configManager = project.ConfigurationManager
configs = configManager. Platform("Win32")
For Each config In configs
Dim prop As EnvDTE.Property
prop = config.Properties.ItemC'ManagedExtensions")
prop.Value = True
Next
End Sub

, , . ConfigurationManagerAddConflgurationRow.
,
, AddConfigurationRow
Boolean. Propagate
, Propagate SolutionConflgurationsAdd, . SolutionConfigurationsAdd
Propagate, true,
, . AddConfigurationRow Propagate, true, , ,
.
ConfigurationManager AddPlatform, , AddConfigurationRow, . Microsoft ,
. ,

Microsoft.
,
, ,
-

209

. , Win32 .NET; ,
, . , <N/A>,


.
, ,
, ,
, .
, ConfigurationProperties. SetManagedExtensionsProperty, EnvDTEProperties , Visual Studio
.NET .
, Optimize ( Boolean), . , Optimize
.
Sub SwapOptimizationSettings()
Dim project As EnvDTE.Project
Dim configManager As EnvDTE.ConfigurationManager
Dim configs As EnvDTE.Configurations
Dim config As EnvDTE,Configuration
Dim props As EnvOTE.Properties
' ConfigurationManager :
project = DTE.Solution.Projects.Item(1)
configManager = project.ConfigurationHanager
' ,
configs = configManager.ConfigurationRow("Debug")
' .
For Each config In configs
Dim optimize As Boolean
' Optimize .
props = config.Properties
optimize = props.Item("0ptimize").Value
' .
props.Item("Optimize").Value = Not optimize
Next
' .
configs = configManager.ConfigurationRow("Release")
For Each config In configs
Dim optimize As Boolean
' Optimize .

21 0

II Visual Studio .NET


props = config.Properties
optimize = props.Item("0ptimize").Value
' .
props.Item("Optimize").Value = Not optimize
Next

End Sub


Visual Studio .NET ,
,
. . :
void OnBuildBegin(EnvDTE.vsBuildScope Scope, EnvDTE.vsBuildAction Action);
void OnBuildPro]ConfigBegin(string Project, string ProjectConfig,
string Platform, string SolutionConfig);
void OnBuildProjConfigDone(string Project, string ProjectConfig,
string Platform, string SolutionConfig, bool Success);
void OnBuildDoneCEnvOTE.vsBuildScope Scope, EnvDTE.vsBuildAction Action);
.

OnBuildBegin . .
EnvDTE.vsBuildScope. vsBuildScopeBatch (
> ), vsBuildScopeProject ( ,
Build) vsBuildScopeSolution ( ).
EnvDTE.vsBuildAction vsBuildActionBuild (
), vsBuildActionClean (
), vsBuildActionDeploy ( ) vsBuildActionRebuildAtt (
,
).
OnBuildProjConfigBegin
. string:
, , , .
OnBuildProjConfigDone . , OnBuildProjConfigBegin, Boolean, , : (true) (false).
OnBuildDone
.

211

BuildEvents,
. , , )-. , ,
(ClassLibraryl ClassLibrary2),
, Build | Build Solution, :

OnBuildBegin
Scope: vsBuildScopeSolution
Action: vsBuildActionBuild
OnBuildProjConfigBegin
Project: ClassLibraryl.csproj
Platform: .NET
Solution Configuration: Debug
OnBuildProjConfigOone
Project: ClassLibraryl.csproj
Platform: .NET
Solution Configuration: Debug
Success: True
OnBuildProjConfigBegin
Project: .,\ClassLibrary2\ClassLibrary2.csproj
Platform: .NET
Solution Configuration: Debug
OnBuildProjConfigDone
Project: ..\ClassLibrary2\ClassLibrary2.csproj
Platform: .NET
Solution Configuration: Debug
Success: True

OnBuildDone
Scope: vsBuildScopeSolution
Action: vsBuildActionBuild
.
OnBuildBegin,
OnBuildDone, . Visual Studio .NET 2003 OnBuildProjConfigBegin OnBuildProjConfigEnd
.
,
Visual Studio .NET, , , .
, .

212

II

Visual Studio .NET


IDE

.
EnvDTE.Globals. Globals
:
Sub SolutionGlobalsO
Dim globals As EnvDTE.Globals
globals = DTE.Solution.Globals
End Sub

Sub ProjectGlobalsO
Dim globals As EnvDTE.Globals
globals = DTE.Solution.Projects.Item(1).Globals
End Sub

Globals Solution Project ,


Globals DTE. , -,
,
VariablePersists, . ,

(modified state). , . -, EnvDTE.Globals DTE, , , ,
.
, . , Globals .

. , . , '
,
Globals ,
.
.
,
, .
Solution.Globals ,
BuildCounter. OrtBuildDone.
OnBuildDone BuildCounter Globals
, , Globals. 1. OnBuildDone :

213

void OnBuildDoneCEnvDTE.vsBuildScope Scope, EnvDTE.vsBuildAction Action)


(
// ,
// Globals:
Qlobals globals;
globals = applicationObject. Solution. Globals;
if (globals. get_VariableExists( "BuildCounter" ) )

// . :
System. Int32 int32;
int32 = System, Int32.Parse(Cstring)globals["BuilijCounter"]);
int32++;

globals["BuildCounter"] = int32.ToString();
else
// . :
globals["BuildCounter"] = I .ToStringO;
globals. set_VariablePersists( "BuildCounter", true);



,
. ,
.

Visual Studio .NET.

9
Visual Studio .NET

Microsoft Visual Studio .NET.



. Windows , , , . Visual Studio .NET .


Visual Studio .NET . ,
(New Project wizard),
. New Project,
File | New | Project.
(Add New Item
wizard). , , , Web-.
Solution Explorer Add | Add New Item. Add New Item .
(Custom wizard). Visual Studio .NET ,
.
,
. Visual Studio .NET.

9 Visual Studio .NET

215

: -, , .vsz- ( Visual Studio .NET


) , , .


-, EnvDTEJDTWizard. Execute ,
, Visual Studio .NET . :
public interface IDTWizard
{
public void Execute(object Application, int hwndOwner,
ref object[] ContextParams,
ref object[] OustParams,

ref EnvDTE.wizardResult retval)


Execute .
Application DTE Visual Studio .NET, .
hwndOwner , ,
.
ContextParams object, Visual
Studio .NET .
CustomParams object, , ' .
Execute . Visual Studio .NET
, - IDTWizard. , , Execute. Execute - Main Visual Basic Visual C#: , , .
ContextParams, Execute. , , Add
New Item New Project. , Visual Studio .NET , . ,
: , .
, ,
, (. 9-1 9-2).

216

II Visual Studio .NET

. 9-1. ContextParams,

EnvDTE.Constants.vsWizardNewProject,
.
.
, .
, Visual Studio .NET.
true,
, false

.
, , . , New
Project Create Directory For Solution.
, , . true,
.

. 9-2. ContextParams,

EnvDTE.Constants.i>sWizardAddItem.
, .
EnvDTEProjectltems, .
, .
. Name
Add New Item.
,
.
, , , true,
.

,
Visual Studio .NET, , . CustomParams .
, . EnvDTE.Constants.v$WizardNewProject ( ) EnvDTE.Constants.vsWizardAddltem (
). GUID ,
, ivizardResult.ivizardResultFailure retval ID'lWizardMxecute.

9 Visual Studio .NET

217

GUID, ,
, vsWizardNewProject vsWizardAddltem , ,
Visual Studio .NET ContextParams.
,
ContextParams ( 9-1).
9-1. ,
Wizard.cs
using System;
using System.ftuntime-InteropServiees;
namespace BasicWizard
{

[QuitiAttfibLtteC'E5DOA8B2-A449-4d3b-B478-99494D23A58B"),
ProgldAttribute("HyWizard.Wizard")]
public class Wizard : EnvDTE.IDTWizard
{

public void Exeoute(object Application, Int hwndQwner,


ret object ContextParants,
ref objectH CustomParaats,
ref EnvDTE.wizardResult retval)
"; <
EnvBTE.DTE application = EnvDTE.DTE)Application;

string wixardType = (strlfig)ContextParamsIOl;


if(System.String.Compare{wizardType,
EnvDTE.Constants.vsWizardNewProjeet, true) == S)
(

string newProjeetName (string)ContextParams[l];


string newProjectLocation = (string)ContextPararas[2];
string visualStudioInstallDirectory *
Cstrlng)GontextParaeis[33;
bool exclusiveProject = (dool)ContextParamst4];
string newSolution^ame = (atringJContextParadistS];.
bool run-Silent = (bool)CorvtextParamsC&l;

}
else if(Systen.String.ComparedwizardType,
EnvDTE.Constants.^WizardAddltem, true) ~ 0)
{
string projectNaae = -(strlrujJContextParantsfn;
EnvDTE,Projectltems projectlteis =
(EnvDTE.P roj ectltems)ContextPa rams[2];
string newltentlocation = (string)ContextParaiBsl33:
string newItemNaiae = (string)GontextParaBsI43i
productlnstallDlrectory = (string}GontextParamsC5];

. :), .

218

Visual Studio .NET

tool runSllent (tKJOl}ContextParat8s(6];


}
else

//01 .

.vsz-
6, , Visual
Studio .NET , , . , , ProgID -"
, .
,
.
.vsz-.
.VS2 .
VSWIZARD 7.0, Visual Studio .NET, Visual Studio .NET 7
. ,
Wizard=, ProgID (ClassID) COM, . ProgID Wizard.cs 9-1) .vsz- :
Wizard=MyWizard.Wizard
ClassID:
imard={E5DOA8B2-A449-4d3b-B47B-99494D23A58B}

ProgID ClassID , . ,
( .vsz- ) . <<=*,
( 0).
:
Param=Hello World
Param=Second line of data

CustomParams
Execute , #:
for(int i = 0 ; i < CustomParams.Length ;
<
string data = (string)CustomParams[i];

9 Visual Studio .NET

219

System.Windows.Forms.MessageBox.Show(data);

Visual Studio .NET 2003 ( 7,1)


.vsz- VSWIZARD 7.0', VSWIZARD 7.1'.

.vsz-
, .vsz- , New Project Add New Item.
.
,
.
, , , .
, . 9-1 New Project , Extensibility Projects ( ,
.vsz- ) A Sub Folder. Extensibility Projects A Sub Folder,
, .
A Sub Folder C:\Program Files\Microsoft Visual Studio
.NET 2003\Common7\IDE\Extensibility Projects ( , ).

. 9-1. New Project


.vsz- ,
TemplatePatb Solution. , , .vsz-

220

II Visual Studio .NET

, Visual Basic Visual C#


New Project:
Sub VSZLocationQ
1
.vsz- Visual Basic.
MsgBox(DTE.Solution.TempiatePath(
VSLangProj.PrfKind.prjKindVBProject))
' .vsz- .
MsgBox(DTE.Solution.TemplatePath(
VSLangProj.PrjKind.prjKindCSharpProject))
End Sub

TemplatePatb
VSZFilePath, He Template () ( ).
prjKindVBProject prjKindCSharpProject, VSLangProj.dll, GUID, . , , Visual Basic #,
, TemplatePath , . GUID
. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.1 \Projects GUID, , Visual Studio .NET.
Solution.TemplatePath GUID, , .vsz-, New Project
, . vcproj ( Visual C++),
, GUID Visual C++ - {898-84-11DO-8D1191942}. GUID ,
.vsz-, New Project
Visual C++ Projects:
Sub VSZLocation2()
1
.vsz- Visual C++:
HsgBox(OTE.Solution.TempiatePath
"{07CD18B1-3BA1-11d2-890A-0060083196C6}"))
End Sub
.vsz- (. 9-1).
.vsz-, (.ico)
, .vsz-, . .vsz Visual Studio .NET Add-in, vsz. , Visual Studio .NET Add-in.ico,
; .vsz- , , Windows .
Add New Item ,
New Project. , -

9 Visual Studio .NET

221

.vsz- . Add New Item New Project . ,


.vsz- ( ), .
, ;) Add
New Item (. 9-2):

. 9-2. Add New Item


.vsz-
Newr Project,
. SolutionJemplatePath, GUID
SoluttonProjectltemsTemplatePatb. .vsz-, # Add New Item, :
Sub ProjectltemVSZLocationO
1
.vsz- #:
HsgBoxCDTE. Solution. Project ItemsTemplatePatti(
VSLangProj.PrjKind.prjKindCStiarpProject))
End Sub



? :
. ,
,
, . , , , ( ) , , .

, -

222

Visual Studio .NET

,
. ,
, . Visual Basic ,
, .
, , ,


, Visual Studio
.NET . 8 , ^ Solution-. AddFromFile
wAddFromTemplate. . AddFromFile
,
, . ,
Solution Explorer , Add |
Add Existing Project . , ,
, , , , ,

. MtTORAddFromTemplate,
. AddFromTemplate:
public EnvDTE.Project

AddFromTemplate(string FileName, string Destination,


string ProjectName, bool Exclusive = false)
.
FileName .
Destination , ,
. ,
AddFromTetnplate.
ProjectName , , Solution Explorer,
.
.
Exclusive true, . false, ,
.
Exclusive true, AddFromFile
AddFromTemplate
.
,
ItemOperationsPromptToSave.

Visual Studio .NET

223

AddFromTemplate AddFromFile , . , -
, .
Templates, ,
-, . , .NET Framework, , :
string templatePath =
System.Reflection.Assembly.GetExecutingAssembly().Location;
templatePath = System.10.Path.GetDirectoryName(templatePath) +
"\\Templates\\";
Me?iQRAddPromTemplate , ProjectItems :
AddFromDirectory, AddFromFileCopy, AddFromFile AddFromTemplate. AddFromDirectory
;
, . AddFromFileCopy AddFromFile
, . AddFromFileCopy
.
AddFromFileCopy AddFromTemplate Projectltems
( AddFromTemplate Solution} , AddFromTemplate
, .
:
public EnvDTE.Projectltem AddFromDirectory(string Directory)
public EnvDTE.Projectltem AddFromFileCopy(string FilePath)
public EnvDTE.Projectltem AddFromFile(string FileName)
public EnvDTE.Projectltem AddFromTemplate(string FileName, string Name)
Directory .
FilePath/FileName ,
.
Name . .
Projectltem, , (,
).


, , ContextParams , Create Directory For Solution,
, More New Project.
, New Solution Name,
.
, SolutionAddFromTemplate

224

II

Visual Studio .NET

, ContextParams
, ( ContextParams true )
, . . ,
, .
Solution.Create (.
8), .
, ,
, ContextParams.

.
, . , # (#
Class Library Wizard), Class 1, ,
, , (, Wizard,
). ,
,
. ,
. , ,
, . , ,
%CIASSNAME%, :
public class XCLASSNAMES!
(

public XCLASSNAHEXO
//
// TODO: Add constructor logic here

MakeReplacements . , , EnvDTE.TextPoint, 1 1.
Sub MakeReplacements(ByVal projectltem As EnvDTE.Projectltem,
ByVal token As String,

ByVal replaceWith As String)


Dim window As EnvDTE. Window
Dim textDocument As EnvDTE. TextDocument
Dim textRanges As EnvDTE. TextRanges

Visual Studio .NET

225

Dim findOptions As Integer


findOptions = EnvDTE.vsFindOptions.vsFindOptionsFromStart +
EnvDTE.vsFlndOptions.vsFindOptionsMatcnCase +
EnvDTE.vsFindOptions.vsFindOptionsMatchWholeWord
' .
, :
window = projectItem.Open(EnvOTE.Constants.vsViewKindTextView)
1

TextDocument :
textDocument = window.Document.Object("TextDocument")
' replaceWith:
textDocument.ReplacePatternftoken, replaceWith,
findOptions, textRanges)
End Sub

( Projectltem, Add'
Projectltems), %CIASSNAME% MyClass
:
Sub MakeReplacementsf)
MakeReplacements(DTE.ActiveWindow.ProjectItem,
"KCLASSNAMEV, "MyClass"}
End Sub

,
. , , , Choose Add-in Options Yes, Create A Tools'
Menu Item ( Tools). '
:
Sub DeleteBetweenTokens(ByVal projectltem As EnvDTE.Projectltem,
ByVal token! As String,
ByVal token2 As String)
Dim window As EnvDTE.Window
Dim textDocument As EnvDTE.TextDocument
Dim tokenEndPoint As EditPoint
Dim tokenStartPoint As EditPoint
Dim findOptions As Integer
findOptions = EnvDTE.vsFindOptions.vsFindOptionsMatchCase + _
EnvDTE.vsFindOptions.vsFindOptionsMatchWholeWord
' .
1
, :
window = projectltem.Open(EnvDTE.Constants.vsViewKindTextView)
' TextDocument :
textDocument = window.Document.ObjectC'TextDocument")
' :

226

II Visual Studio .NET


tokenEndPoint = textDocument.StartPoint.CreateEditPointO
tokenStartPoint = textDocument.StartPoint.CreateEditPoint()
' , / :
While (tokenStartPoint. FindPattern(token1. findOptions
If (tokenEndPoint. FindPattern(token2, findOptions, tokenEndPoint))
Then
'
' / :
textOocuirent. Select ion. MoveToPointC tokenStartPoint, False)
text Document. Selection. HoveToPoint ( tokenEndPoint, True)
:
text Document , Selection. l]elete( )
Else

Exit While
End If
End While
End Sub
, :
public class XCLASSIJAMEX
(

public XCLASSNAHEXO
!
//

// TODO: Add constructor logic here

XBEGINOPTIONALCODEX
void SomeOptionalCodeO
XENDOPTIONALCODEX
:
Sub MakeReplacements2()
MakeReplacements(DTE.ActiveWindow. Projectltem,
"XCLASSNAHEST, "MyClass")
DeleteBetweenTokens(DTE.ActiveWindow. Projectltem,
"XBEGINOPTIQNALCODEX",

End Sub

:
public class MyClass
I
public MyClassO

"JfENDOPTIONALCOOEX")

9 Visual Studio .NET

227

// TODO: Add constructor logic here




.
. .
, .
, ,
( DLL ) .
, Visual Studio .NET .
Add New Item, Visual Studio .NET
.vsz- ,
, , ,vsz. Add New Item, AddFromFtieCopy: , , .
, ,
, ProjectltemsTemplatePatb, a
.


Visual Studio .NET :
.
. Visual Studio .NET
, , , , , , , ,
, -, IDTWizard, .vsz- ,
.
, , ,
, . , , ,
.
, Visual Studio .NET IDTWizardExecute. -

228

II Visual Studio .NET

( ,
), .
,
,
GUID, .
, GUID
.
.

?
, Visual Studio .NET, .
" . Visual
C++ * (Class View), , .
. , DTEJLauncbWOzard


. , C++ Class
View Add \ Add Function Add [ Add Variable,
.


- , lDT&!izard Execute,
Visual Studio .NET. , DTELaunchWizard, .vsz- . .vsz-,
- , .
LaunchWizard - , , vsz-,
, .vsz-.
LaunchWizard Execute .
CustomWizard LaunchWizard.
, ContextParams GUID ,
,
. , :

Visual Studio .NET

229

Sub CallCustomWizardO
Dim contextParams(t) As Object
contextParams(O) = "{9A4B2CFF-7A69-4671-BFA5-AEODOC44AEFB}"

contextParams(l) = "Hello worldl"


DTE.LaunchWizard("C:\samples\CustomWizard.vsz", contextParams)
End Sub

C:\samples,
Hello world! LauncbWizard.
GUID {9A4B2CFF-7A69-4671-BFA5-AEODOC44AEFB}, ContextParams,
, .


LauncbWizard ,
. ,
, Web- XML, Windows
Forms Web- XML . Windows Forms : Windows Form
Windows Form, , . Web- XML
, . Web- XML Web-. Web- XML, ,
, .
Web- , Front Page server
extensions, Web- XML,
Web- (Web Service Wizard) .
ChainWizard, , , . Execute :
const string serviceName = "ChainWizardWebService";
object [JcontextParamsChain = new object[7];
EnvDTE.wizardResult wizardResultChain;
EnvDTE.DTE dte = (EnvDTE.DTE)Applicatlon;
// Web-
// Web-.
contextParamsChain[0] = EnvDTE.Constants.vsWizardNewPreject;
contextParamsChain[1] = serviceName;
contextParamsChain[2] = "http://localhost/" + serviceName;
contextParamsChain[3] = System.10.Path.GetDirectoryName(dte.FullName);
contextParamsChain[4] = (bool)ContextParams[4];
contextParamsChain[5] = "";

contextParamsChain[6] = false;
string webSvcTemplatePath = dte.Solution.get_TemplatePath(
VSLangProj.PrjKind.prjKindCSharpProject);
webSvcTemplatePath += "CSharpWebService.vsz";

230

II Visual Studio .NET

wizardResultChain = cite.LaunchWizard{webSvcTemplatePath,
ref contextParamsChain);

,
, LaunchWizard. TemplatePath .vsz- Web- XML
#. ;
Web- XML. , Web- XML,
, serviceName
.
ChainWizard , Web XML Windows Forms, Web XML

:
, ?
, Visual Studio .NET: ,,
, , - =
. -;
* Web- ASP.NET
(ASP-NET Web Service Wizard) ChainWizard.
# ( Visual Basic .NET)
Mew Project. , IBTWizard CGM1, GUID PragID
- , , .-,
;
Web- #, .vsz-
, . Visual Studio .NET 20Q3\VC#\CsharpProiects
CShaipWefoService.vsz ,
1 ,
.
.vsz-, , ProglD VsWizardVsWizardEngine.7.1 ProglD , .
Visual Studio .NET, . Execute F5 (
Visual Studio .NET devertv.exe ). Visual Studio .NET - /
New Project # ASP .NET Web Service W&ard. - : :
ASP.NET Web Seivice Wizard /
, !* Execute, ' ,
..

9 Visual Studio .NET

231

He .vsz-, , Web- .
XML


, . -,
IDTWizard .vsz- , , New Project
Add New Item.
, - .
,
Windows Form . Windows Form , Next, Back. Finish Cancel
,

. , . WizardLibrary IDTWizard, Context? arams
, .
}', , , , , , , , .
, , . # WizardBuilder,
WizardLibrary ( , < >
,
),
InsideVSNet.WizardLibraryWizardLibrary ( , ).
-, :
[GuidAttribute("1EF6B85C-FD5C-4fb4-BA4D-5ED221195DBF"),

ProgIdAttribute( "WizardBuilder. Wizard")]


public class Wizard : InsideVSNet.WizardLibrary.WizardLibrary
\
public WizardO

, ,
.
, :

232

II

Visual Studio .NET

, , . .vsz- WizardBuilder .
. .NET,
Add New Item Pagel Page2,
.
, , ,
, .
InsideVSNet.WizardLibraryJWizardPage,
. :
public interface IWizardPage
I
void PerformWork1(WizardLibrary WizardLibrary);
void PerformWork2(WizardLibrary WizardLibrary);
string HeadingLabel

f
get;
!
string DescriptionLabel
{

get;

i
System.Drawing.Image Icon

{
get;
)
void ShowHelpO;
void Initialize (WizardLibrary WizardLibrary);

.
PerformWorkl ,
Finish, . ,
.
PerformWork2 PerformWorkl, .
. PerformWorkl, PerformWork2.
PerformWorkl , PerformWork2 , .

9 Visual Studio .NET

233

HeadingLabel , ,
,
. , ,
: , , .
DescriptionLabel ,
.
Icon SystemDrawingJmage, .
ShowHelp Help
, ,
Initialize ,
, .
, , .
IDTWizard Execute, , WizardLibrary (
),
Execute. , WizardLibrary, , :
public override void Execute(EnvDTE.DTE applicationObject);
Execute , , . ,
WizardLibrary AddPage,
, IWizardPage,
, . Execute
, (Pagel
public override void Execute(EnvDTE.DTE applicationObject)
{
Title = "Wizard Builder";
AddPage(new Page1(;
AddPage(new Page2());

, Wizard Builder. WizardLibrary Title, .


Execute
.

. wizardResult IDTWizardExecute, wizardResult-

II Visual Studio .NET

234

Success Finish, ivizardResultCancel Cancel, wizardResultFailure wzardResultBackOut,


Back,
, ,
(. 9-3)Wizsrd Builder IPage 1 of 21
Cfcoost a wiza I type
Cheese a razartf tye* and a (dace to store the XSL file.
a type of wizard to create:
Create a oewr project 4
G*ate isasv mseet iterts <*&
( eincattentaslorethi? .vszfite:
I'I VSua! Sasic Projects
VJsua! C* Projects

CawS

. 9-3-

WizardBuilder


IDTWizardExecute ContextParams CustotnParams. Execute,
, , ContextParams . CustomParams , ContextParams,
. . 9-3 9-4
, , , . 9-1 9-2, , .
. 9-3.
ContextAttribute

WizardType
NewProjectName
NewProjectLocation
VisualStudioInstallDirectory
exclusiveProject
NewSolutionName
RunSilent

9 Visual Studio .NET

235

. 9-4.
ContextAttribute

WizanfType
ProjectName
Projectltems
NewItemLocation
NewIt&mName
ProductlnstallDirectory
RunSilent

, . 9-3 9-4, . ,
, ,
.
application DTE Visual Studio .NET,
.
CustomArguments , CustomParam, IDTWizardExec.
,
. , IWizardPagePerformWorkl IWizardPagePerformWork2.
, . System.CollecttonsSpecializedListDictionary. . ,
, customData , EnvDTEProject, Create Project PerformWorkl .


,
.
CreateProject , ;
public EnvDTE.Project CreatePro]ect(string templatePath)
, , ,
. . ,
, ,
,
, .
DeleteBetweenTokens MakeReplacements #-

236

II

Visual Studio .NET

, . .

WizardBuilder
WizardBuilder. , WizardUbrary, Execute,

IWizardPage. .
. # WizardTemptate, :
namespace NAMESPACE*

{
/// <summary>
/// Summary description for Classl.
/// </summary>
[GuidAtt ribute( "SQUIDS") , ProgldAtt ribute( "XNAMESPACEX . Wizard" ) ]
public class Wizard : InsideVSNet.WizardLibrary.WizardLibrary

public Wizard ()
{

I!

TODO: Add constructor logic here

public override void Execute(EnvDTE, DTE application)

{
Title = "My Wizard";
XWIZARDPAGESX

%NAMESPACE% , New Project, a %GUID% GUID. %WIZARDPAGES%


,
. .
, # Windows Control Library Wizard, IWizardPage 96NAMESPACE%
%PAGENAME% . .
PerforniWorkl PerformWork2 . PerformWorkl . PerformWork2 .vsz-, WizardLibrary.dll.

9 Visual Studio .NET

237

PerformWorkl . PerformWork2
,
.
. , , PerformWork2 wizard.cs ,
%WIZARDPAGES%.


.
Visual Studio .NET.

10

Microsoft Visual Studio .NET Task List, Solution Explorer, Windows Forms . . , , . , Visual Studio .NET.


Visual Studio .NET ,
. .

Windows
Visual Studio .NET ,
.
Window Windows, DTE.Windows.
Window Windows -, ,
:
Sub EnumWindows()
Dim window As EnvDTE.Window
For Each window In DTE.Windows

10

239

MsgBox(window.Caption)
Next

End Sub
:
Sub EnumWindows2()
Dim window As EnvDTE.Window

Dim i As Integer
For i = 1 To DTE.Windows.Count

MsgBox(DTE.Windows.Item(1).Caption)
Next

End Sub
,
, . ,
Visual Studio.NET. , Item
EnvDTEWindow, . ,
. , . , Visual Studio .NET , ,
,
.
, , . Server Explorer Visual Studio .NET. ,
. Visual Studio .NET
, , . EnumWindows2 Window, ,
.
Windows
. , Window Task List :
Sub FindTaskListWindowO
Dim objWindow As EnvDTE.Window
objWindow = DTE.Windows.Item("Task List")
End Sub

Window.
, WindowsJtem, , . Task List
Show Tasks | Comment, ,
Task List - X Comment tasks shown (filtered), X .
Task List, Item,

240

II

Visual Studio .NET

Task List, Windows Jtem(Task List*) Window. ,


. ,
Properties Object Browser, (
), , ,
, ,
.
Window ,
Windows, , GUID, Item . GUID ,
, Visual Studio .NET, ,
. vsWindowKind
( , Visual Basic .NET) EnvDTE.Constants. Task List:
Sub FindTaskListWindow2<)
Dim objWindow As EnvDTE.Window
objWindow = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindTaskList)

End Sub
GUID
, EnvDTE Windows, GUID
, Visual Studio .NET ,
.
, , GUID, . Favorites. GUID
, , . , Window Favorites:
Sub FindTheFavoritesWindow()
Dim window As EnvDTE.Window
window = DTE.Windows.Item("{E8BQ6F43-6D01-11D2-AA7DEnd Sub

OOC04F990343}")

GUID, , ObjectKind.
, GUID Favorites:
Sub FindTheFavoritesWindow2()
Dim window As EnvDTE.Window
' ,
1
Favorites!
window = DTE,Windows.Item("Favorites")
HsgBox(window.ObjectKind)
End Sub

GUID Favorites .
, GUID,
, , FindTheFavoritesWindow
GUID .

10

241

Object
Visual Studio .NET ,
, . ,
, Object Window. , Object Window Task List
TaskList, , Task List. TaskList:
Sub GetTaskListObJectf)
Dim window As EnvDTE.Window
Dim taskList As EnvDTE.TaskList
window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindTaskList)
taskList = CType(window.Object, EnvDTE.TaskList)
End Sub

,
TaskList, . . 10-1 ,
GUID, Item
Window, , .
. 10-1.

GUID

Command Window

vsWindowKindCommandWindow

EnvD TE.CommandWindow

Macro Explorer

vsWindowKindAlacroExplorer

EnvDTE.UIHierarcby

Oucput window

vsWindowKindOutput

EnvD TE.OutputWindow

Server Explorer

vsWindowKindServerExplorer

EnvD TE.UlHierarchy

Solution Explorer

vsWindowKindSolutionExplorer

EnvD TE.UlHierarchy

Task List

vsWindowKindTaskList

EnvDTE.TaskList

Toolbox

vsWindotvKindToolbox

EnvDTEToolBox

Web-

vsWindowKindWebBrowser

SHDocVwWebBrowser

<>

EnvDTE.TextWindow

< >

System.ComponentModel.
DesignJDesignerHost

HTML

< >

EnvDTEHTML Window

Visual Studio .NET,


, Window.Qbject , HTML
-.
, HTML -
11.


Visual Studio .NET
Window. Visual Studio .NET ,
Window. , EnvDTE.Winf.iows,
MainWindow DTE-.

9-16

242

II

Visual Studio .NET

Sub FindTheMainWindowO
Dim mainWindow As EnvDTE.Window
mainWindow = DTE,MainWindow
End Sub

Window Visual Studio .NET


, Window :

Document, Selection, Object, Projectltem Project null


# Nothing Visual Basic .NET;
se^- Caption Linkable ;
IsFloating wAutollides get- setf-
;
Close .
Window ,
, .
, , .
Visual Studio .NET WindowHWnd, HWND. Windows SDK. ;
, . .NET
Framework HWND , , , .NET
. SystemWindowsformsJWin3 2 Window . IWin32Wmdow
Handle SystemlntPtr, , ,
WmdowHWnd. FormShowDialog, , IWin32Window.
IWin32Windoiv ,
:
public class Connect : Object, Extensibility.IDTExtensibility2,
System.Windows.Forms,IWin32Window
Handle-.
// IWin32Window.Handle;
public System.IntPtr Handle

get
'

return new System.IntPtr (apolicationObject.MainWindow.HWnd);

I
(,
):

10

243

Form"! forml = new Form1();


forml.ShowDialog(this);
; ,
Visual Studio .NET, ,
. WmWrapper, Utilities
Samples,
, , , <
Open File:
Sub ShowFileOpenDialogO
Dim openFile As New OpenFileDialog
openFile.ShowDialog(New WinWrapper)
End Sub

WmWrapper ,
.

- UIHierarchy
(UI-) , - Solution Explorer, Server Explorer Macro Explorer,
UIHierarchy UIHierarchyltems UIHierarchy
, ,
. UIHierarchy
,
UI-. .

UIHierarchy
UIHierarchy, UIHierarchyltems UIHierarchyltem .
UIHierarchy UIHierarchyltems, UI-.
UIHierarchyltem UIHierarchyltems,
, UlHierarchyltemUIHierarchyItems UIHierarchyltems. ,
, ,
, UIHierarchy
Macro Explorer:
Sub GetTopLevelUIHierltemsO
Dim macroExplWin As Window
Dim uiHierarchy As EnvDTE.UIHierarchy
Dim uiHierarchyltems As EnvDTE.UIHierarchyltems
1
-
' UIHierarchy :
macroExplWin = DTE.Windows.Item(Constants.vsWindowKinrfMacroExplorer)
uiHierarchy = macroExplWin.Object
' :

244

II

Visual Studio .NET

uiHierarchyltems = uiHierarchy.UIHterarchyltems
1
:
MsgBox(uiHierarchyItems, Item(1). Name)
End Sub

UIHierarchy Macro Explorer


UiHierarchyltems. ; Macro Explorer Macros.
: Macros Macro Explorer . ' , UIHierarchyltem UIHierarchyltem.UIHierarcbyltems -. UiHierarchyltems
, , :
Sub WalkMacroProjects()
Dim macroExplWin As Window
Dim uiHierarchy As EnvDTE.UIHierarchy
Dim uiHierarchyltems As EnvDTE.UiHierarchyltems
Dim uiHierarchyltem As EnvDTE.UIHierarchyltem
Dim uiHierarchy!tem2 As EnvDTE.UIHierarchyltem
' -
' UIHierarchy :
macroExplWin = DTE.Windows.Item(Constants.vsWindowKindMacroExplorer)
uiHierarchy = macroExplWin.Object
' - Macros:
uiHierarchyltem = uiHierarchy.UiHierarchyltems.Item(1)
' ,
' :
For Each uiHierarchy!tem2 In uiHierarchyltem.UiHierarchyltems
MsgBox(uiHierarchyItem2.Name>
Next
End Sub

Solution Explorer Server Explorer,


, Windowsltem, Constants.vsWindowKindSolutionExplorer Constants.vsWindowKindServerExplorer.
UIHierarchy? UIHierarchy, UiHierarchyltems UIHierarchyltem UI- Projectltems Projectltem
. , UIHierarchy ,
Projectltem Projectltems.

UIHierarchy
- , . UIHiemrcby.Getltem UIHierarchyltem , -

10

245

. , UlHierarchyltem tnsertDate,
VSEditor Samples, :
Sub FindUIHierltemForlnsertDateHacroO
Dim macroExplWin As Window
Dim uiHierarchy As EnvDTE.UIHierarchy
Dim uiHierarchyltem As EnvDTE.UlHierarchyltem
Dim uiHierarchyltems As EnvDTE.UIHierarchyltems
macroExplWin = DTE.Windows,Item(Constants.vsWindowKindHacroExplorer)
uiHierarchy = macroExplWin.Object
uiHierarchyltems = uiHierarchy.UIHierarchyltems
uiHierarchyltem = uiHierarchyltems.ItemC'Macros")
uiHierarchyltems = uiHierarchyltem.UIHierarchyltems
uiHierarchyltem = uiHierarchyltems.Item("Samples")
uiHierarchyltems = uiHierarchyltem.UIHierarchyltems
uiHierarchyltem = uiHierarchyltems.Item("VSEditor")
uiHierarchyltems = uiHierarchyltem.UiHierarchyltems
uiHierarchyltem = uiHierarchyltems.Item("InsertDate")
MsgBox(uiHierarchyltem.Name)
End Sub
, , UfHierarchy.Getltem-.
Sub FindUIHierItemForInsertDateMacro2()
Dim macroExplWin As Window
Dim uiHierarchy As EnvDTE.UIHierarchy
Dim uiHierarchyltem As EnvDTE.UlHierarchyltem
macroExplWin = DTE.Windows.Item(Constants.vsWindowKindMacroExplorer)
uiHierarchy = macroExplWin.Object
uiHierarchyltem =
jiHierarchy.GetItem("Macros\Samples\VSEditor\InsertDate")

MsgBox(uiHierarchyltem.Name)
End Sub
UIHierarchy.Getltem , , . ,
. UIHierarcby.Getltem
Macro Explorer Solution Explorer, Visual Studio .NET
UlHierarchyltem Server Explorer.
UIHierarchySelectedltems UlHierarchyltem
, . , , .NET,
System.Object.
Sub GetUIHierSelectedltemsO
Dim macroExplWin As Window
Dim uiHierarchy As EnvDTE.UIHierarchy
Dim selectedltems As ObjectO
Dim uiHierarchyltem As EnvDTE.UlHierarchyltem
macroExplWin = DTE.Windows.ItemfConstants.vsWindowKindHacroExplorer)
uiHierarchy = macroExplWin.Object

246

II

Visual Studio .NET

selectedltems = uiHierarchy.Selectedltems
For Each uiHierarchyltem In selectedltems
4sgBox(uiHierarchyItem.Name)
Next
End Sub

,
UIHierarchy , SelectUp SelectDown, . .
EnvDTE.vsUISelectionType ,
. EnvDTE.vsUISelectiorifypeSelect
, . EnvDTE.vsUlSelectioritypeExtend ,
Shift. EnvDTE.vsllISelectionTypeSetCaret ,
. , , EnvDTE.vsUlSelectionType1bggle . SelectUp
SelectDown . , .
UIHierarchy DoDefaultAction, Enter . , Macro Explorer UIHierarchyDoDefaultAction, .

UIHierarchyltems
EnvDTE,UIHiemrchyItems EnvDTEJUIHierarcbyltem
, - Visual Studio.
,
-, Expanded. Boolean
,
UIHierarchyltems. True ,
* , a False *.

UiHierarchyltem
EnvDTE.UiHierarchyltem, ,
, Collection Name. Select, UIHierarchySelectUp UIHierarchySelectDoivn,
,
UiHierarchyltem, Select. Select
UiHierarchyltem, .
UIHierarchyltem.Object ,
. , Solution Explorer,
EnvDTEProject EnvDTEProjectltem .
UiHierarchyltem ( , .NET

10

247

References), EnvDTEProject EnvDTEProjectltem


:
Sub GetUIHierltenObJectO
Dim uihier As EnvDTE.UIHierarchy
Dim uihierProj As EnvDTE.UIHierarchyltem
Dim uihierProjItem As EnvDTE.UIHierarchyltem

Dim project As EnvDTE.Project


Dim projltem As EnvDTE.Projectltem
uihier = DTE.Windows.Item(
Constants.vsWindowKindSolutionExplorer).Object
uihierProj = uihier.UIHierarchyltems.Item(1).UIHierarchyItetns.Item(1)
project = uihierProj.Object
uihierProjItem = uihierProj.UIHierarchyltems.Item(2)
projltem = uihierProjItem.Object
End Sub

Toolbox
Toolbox , , , . Toolbox , . ,
, Clipboard Ring, , .


Toolbox, vsWindowKindToolbox
WindowsJtem, Window, ToolBox Window.Object :
Sub FindTheToolBoxC)
Dim toolBoxWindow As EnvDTE.Window
Dim toolBox As EnvDTE.ToolBox
toolBoxWindow = DTE.Windows.Item(Constants.vsWindowKindToolbox)
toolBox = toolBoxWindow.Object
End Sub

Toolbox , , , ToolBoxTabs,
ToolBox.TbolBoxTabs.
ToolBoxTab Toolbox
. ToolBoxTabsAdd, ToolBoxTab. Toolbox :
Sub AddNewToolBoxTabO
Dim toolBoxWindow As EnvDTE.Window
Dim toolBox As EnvDTE.ToolBox

248

II

Visual Studio .NET

toolBoxWindow = DTE.Windows.Item(Constants.vsWindowKindToolbox)
toolBox = toolBoxWindow.Object
toolBox.ToolBoxTabs.Add("My commonly used items").ActivateO
End Sub

My Commonly Used Items, Activate ToolBoxTab.


, Toolbox , .
ToolBoxItem ToolBoxItems, ToolBoxTab.ToolBoxlterns. Toolbox
EnutnerateToolBoxContents:
Sub EnumerateToolBoxContentsO
Dim toolBoxWindow As EnvDTE.Window
Dim toolBox As EnvOTE.ToolBox
Dim toolBoxTab As ToolBoxTab
Dim outputWindow As New _
InsideVSNET.Utilities.OutputWindowPaneEx(DTE, "Toolbox contents")
toolBoxWindow = DTE.Windows,Item(Constants.vsWindowKindToolbox)
toolBox = toolBoxWindow.Object
For Each toolBoxTab In toolBox.ToolBoxTabs
Dim toolBoxI1:em As ToolBoxItem
outputWindow,WriteLineCtoolBoxTab.Name)
For Each toolBoxItem In toolBoxTab.ToolBoxItems
outputWindow.WriteLine(vbTab + toolBoxItem.Name)
Next
Next
End Sub

ToolBoxItem . Select,
Toolbox, Delete, , ,
Name. ToolBoxItem , Toolbox
.

Toolbox
Toolbox , , HTML, COM-
.NET-. Tool-Box TabAdd, : Name ( ,
Toolbox), Data ( , Toolbox) Format ( vsToolBoxItemFormat
).
. ,
Data, Toolbox , ,
, text
(, ), . :

10

249

Sub AddTextToTheToolB6x()
Dim toolBoxWindow As EnvDTE.Window
Dim toolBox As EnvDTE.ToolBox
Dim toolBoxTab As EnvDTE.ToolBoxTab
Dim toolBoxItems As EnvDTE.ToolBoxItems
toolBoxWindow = DTE.Windows.Item(Constants.vsWindowKindToolbox)
toolBox = toolBoxWindow.Object
toolBoxTab = toolBox.ToolBoxTabs.Item{"General")
toolBoxItems = toolBoxTab.ToolBoxItems
toolBoxItems.Add("My Text", "This is some text", _
vsToolBoxItemFormat.vsToolBoxItemFormatText)
End Sub


General Toolbox. ToolBoxItemsAdd,
My Text This is some text, text.
HTML
, , HTML-, vsToolBoxltemFormatHTML
Sub AddHTMLToTheToolBoxO
Dim toolBoxWindow As EnvDTE.Window
Dim toolBox As EnvDTE.ToolBox
Dim toolBoxTab As EnvDTE.ToolBoxTab
Dim toolBoxItems As EnvDTE.ToolBoxItems
toolBoxWindow = DTE.Windows.Item(Constants.vsWindowKindToolbox)
toolBox = toolBoxWindow.Object
toolBoxTab = toolBox.ToolBoxTabs.Item("General")
toolBoxItems = toolBoxTab.ToolBoxItems
toolBoxItems.Add("My HTML", "<b>This is bold HTML</b>",
vsToolBoxItemFormat.vsToolBoxltemFormatHTML)
End Sub

HTML Toolbox,
Toolbox HTML, ,
.
HTML XML,
. HTML XML,
Toolbox XML HTML. Visual Studio .NET HTML/XML HTML-, XML-.
, Toolbox } ActiveX, HTML- %'132- ( MFC), ActiveX. ActiveX, vsToolBoxJtemFormatGUID.
Data CLSID GUID ActiveX ( ) ProgID .

250

II

Visual Studio .NET

Toolbox Windows Media Player. CLSID, ProgID:


Sub AddCOMObjectToTheToolBoxO
Dim toolBoxWindow As EnvOTE.Window
Dim toolBox As EnvDTE.ToolBox
Dim toolBoxTab As EnvDTE.ToolBoxTab
Dim toolBoxItems As EnvDTE.ToolBoxItems
toolBoxWindow = DTE.Windows.Item(Constants.vsWindowKindToolbox)
toolBox = toolBoxWindow.Object
toolBoxTab = toolBox.ToolBoxTabs.Item("General")
toolBoxItems = toolBoxTab.ToolBoxItems

toolBoxItems.AddrName", "{22D6F312-BOF6-11DO-94AB- 0080C74C7E95}", ..


vsToolBoxItemFormat.vsToolBoxItemFormatGUID)
toolBoxItems.Add("Name", "MediaPlayer.MediaPlayer.l", _
vsToolBoxItemFormat.vsToolBoxItemFormatGUID)

End Sub
, , Name . .
Toolbox .
Toolbox .NET Framework.
vsToolBoxItemFormatDotNETComponent
.NET. , ,
, Toolbox. ,
WindowsControILibrary.dll :. Toolbox:
Sub AddDotNetComponentToTheToolBox{)
Dim toolBoxWindow As EnvDTE.Window
Dim toolBox As EnvDTE.ToolBox
Dim toolBoxTab As EnvDTE.ToolBoxTab
Dim toolBoxItems As EnvDTE.ToolBoxItems
toolBoxWindow = DTE.Windows.Item(Constants.vsWindowKindToolbox)
toolBox = toolBoxWindow.Object

toolBoxTab = toolBox.ToolBoxTabs.Item("General")
toolBoxItems = toolBoxTab.ToolBoxItems
toolBoxItems.Add("Control", "C:\WindowsControlLibrary.dll",
vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent)
End Sub

, , (GAC), , .NET Framework. GAG , ,


Toolbox. , -
WindowsConti-olLibrary, 1.0.795.38182
6fc7037576l725cO.
SystemReflectionAssemblyLoad, ,
. SystemReflection Assembly, CodeBase, file:///.

10

251

Sub AddDotNetComponentToTheToolBox2()
Dim toolBoxWindow As EnvDTE,Window
Dim toolBox As EnvDTE.ToolBox
Dim toolBoxTab As EnvDTE.ToolBoxTab
Dim toolBoxItems As EnvDTE,ToolBoxItems
Dim asm As System.Reflection.Assembly
toolBoxWindow = DTE,Windows.Item(Constants.vsWincfowKlndToolbox)
toolBox = toolBoxWindow.Object
toolBoxTab = toolBox.ToolBoxTabs.Item("General")
toolBoxItems = toolBoxTab.ToolBoxItems
asm = System.Reflection,Assembly.Load("WindowsControlLibrary1,
Version=1.0.795.38162, Culture=neutral, PublicKeyloken=6fc70375761725cO")
toolBoxItems.AddC'Control", asm.CodeBase,
vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent)
End Sub

, ActiveX, Toolbox .NET, Name ,


. Visual Studio .NET, Toolbox .
, HTML ActiveX, EnvDTE.ToolBoxItem
. , null Nothing ( ). ,
, .
, null Nothing
, ToolBoxItem, . ,
EnvDTE.ToolBoxltem, .
, EnvDTE.ToolBoxltem,
, null Nothing.

Task List
, Task List EnvDTETaskList. TaskList ,
, ,
, .


EnvDTE.TaskList TaskItems, Taskltems,
Task List. Task
List, , , , ,
EnvDTE.Taskltems.
, EnvDTE.Taskltems , EnvDTE.Taskltem. ,

252

Visual Studio .NET


Task List . , Task List.
, .
Task List.
, ,
Microsoft Project, ,
. ,
, Project ,
,
. , #
- ? ?
, Microsoft Outlook Visual Studio .NET. , .
TaskltemsAdd, .
Visual Studio .NET:
public EnvDTE.Taskltem Add(string Category,
string SubCategory,
string Description,
EnvDTE.vsTaskPriority Priority = vsTaskPriorityMedium,
object Icon,
bool Checkable = false,
string File = "",
int Line = -1,
bool CanUserDelete = true,
bool Flushltem = true)
- AddTaskListltems. .
Category SubCategory
, Visual
Studio .NET, .
.
: , .
Task List Show Tasks,
, , . Category Add.
, . ,
, .
, .

10

253

Visual Studio .NET SubCategory1 Add-, .


Description
Description , Description Add,
: Description, Category SubCategory.
, Task List:
Sub TLAddltemsQ
Dim taskList As EnvDTE.TaskList
taskList = DTE.Windows.Item(Constants.vsWindowKindTaskList).Object
taskList.Taskltems.AdcK"Category", "", "Description2")
taskList.TaskItems.Add("Category", "", "Description!")
End Sub

Sort By | Category Task


List, (. 10-1),
task List - 2 Category I aibs shown {filtered}.
- 11' i

Description?

Sort By
Show Description Tooltip

i. ',
Next TasV
Previous Task

. 10-1.

Task List,

Priority
, ^rfrf, Priority,
, , Task List
,
.
, , . Task List . Task List
, . 10-2.
Sub TLAddltemsPriorityO
Dim taskList As EnvDTE.TaskList
taskList = DTE.Windows.Item{Constants.vsWindowKindTaskList).Object

254

II Visual Studio .NET

taskList.Taskltems.Add("Category", "", _
Descriptionl", vsTaskPriority.vsTaskPriorityHigh)
taskList.Taskltems.Add("Category", "", _
"Descriptions", vsTaskPriority.vsTaskPriorityLow)
taskList.Taskltems.Add("Category", "", _
"Descriptions", vsTaskPriority.vsTaskPriorityMedium)
End Sub

. 10-2.

Task List

Icon
Icon . . . 10-2.
. 10-2. Task List

vsTasklconvsTaskiconComment

qfSjift

vsTaskIcon.vsTaskIconUser
vsTasklcon.vsTasklconSquiggie

vsTasklconvsTasklconSbortcut

j;|i

vsTaskIcon.vsTaskIconComptte

, vsTasklconNone
, .
TaskltemsAdd vsTasklconSbortcut, .
. : vsTasklcon , vsTasklconComment
. .
. 16x16 1 . RGB- 0,255,0 , . . Task List. ,
IPictureDisp
Icon. IPictureDisp
. IPictureDisp .NET-.
P/Invoke- .
(P/Invoke .NET Framework, -

10

255

.NET.) DLL oleaut32.dll


OleLoadPictureFile,
IPictureDisp. OleLoadPictureFile, , >
, :
["oleaut32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto,
SetLastError=true)]
internal extern static int 01eLoadPictureFile(object filename,
[MarshalAsAttribute(UnmanagedType.IDispatch)] ref object ipictrueDisp);
, - OleAut32.dll. P/Invoke-,
OleLoadPictureFile :
object objIPictureDisp = null;
string filename = "C:\SomeImage.eps";
int nret = OleLoadPictureFile(fileName, ref objIPictureDisp);
objIPictureDisp
IPictureDisp, Icon TaskJtemsAdd.
Add Icon
IPictureDisp, . ,
Visual Studio .NET . Visual Studio .NET, Visual Studio .NET . ,
IPicture IpictureDisp, ,
, IPicture IPictureDisp Taskltems.Add , . ,
, Visual Studio .NET
Checkable
Checkable , .
true, , false .
File Line
File Line
File Line Task List. .
( Enter), ,
, Line. , ; ,
- .
,
TaskNavigate (. ),
.

256

II

Visual Studio .NET

CanUserDelete
, , , Delete. false, ,
, TaskltemDelete.

Flushltem
TaskListltemsAdd Flusbltem,
Task List , . , Task List
. Flushltem
false, Task List TaskltemsForceltemsToTaskList.

Task/ten?
Task List Visual Studio .NET Taskltems,
, ?
Taskltem. Category, SubCategory, Checked, Description, FileName, Line Priority Task List. ,
. , Visual
Studio .NET, , . , , IsSettable, (
vsTaskListColumn) true, , false . , , , :
Sub ModifyTaskDescriptionQ

Dim taskList As EnvDTE.TaskList


Dim task As EnvDTE.Taskltem
taskList = DTE.Windows.Item(Constants.vsWindowKindTaskUst).Object
task = taskList.Taskltems.Item(l)
If (task.IsSettable(vsTaskListColumn.vsTaskListColumnOescription)) Then
task.Description = "A new description"

End If
End Sub
Delete , . ,
, , ,
CanUserDelete true false TaskltemsAdd. , , . , , Click
Here To Add A New Task Item Task List, . IntelliSense , Delete , -

10

257

,
.
Navigate Enter,
. Visual Studio .NET , , . , ,
TaskNavigated.

Task List
Task List ,
. , , , TaskNavigate.
, Task List, Enter,
Next Task Previous Task
Task List. ,
TaskListEvents.TaskNavigated. Taskltem , , NavigateHandled, Visual Studio .NET,
. NaingateHandled false , Visual Studio .NET
.
EnvironmentEvents , TaskListEvents
TaskNavigated . ,
- NavigateHandled,
( ), , , .
:
Private Sub TaskListEvents_ TaskNavigated(ByVal Taskltem As EnvDTE.Taskltem, _
ByRef NavigateHandled As Boolean) Handles TaskListEvents.TaskNavigated
1
file...
If (Taskltem. FileName <> "") Then
Dim fileWindow As EnvDTE.Window
Dim textWlndow As EnvDTE.TextWindow
Dim textPane As EnvDTE.TextPane
' , TextWindow TextPane objects...
fileWindow = DTE.IteraOperations.OpenFile(TaskItem.FileName, _
EnvDTE.Constants.vsViewKindTextView)
textWindow = CType(fileWindow.Object, EnvDTE.TextWindow)
textPane = CType(textWindow.ActivePane, EnvDTE.TextPane)
' :
textPane.Selection.MoveTo(TaskItem.Line, 1, False)
textPane.Selection.SelectLine()

II Visual Studio .NET

258

NavigateHandled = True
End If
End Sub
,
. . Task List,
EnvDTE.TaskListEvents-.
private EnvDTE.TaskLlstEvents taskListEvents;
,
, Object Browser. , , # :
public void TaskNavigated(EnvDTE.TaskItem taskltem,
ref bool navigateHandled)
I

// file...
if(taskltem.FileName != "")
I

EnvDTE.Window fileWindow;
EnvDTE.TextWindow textWindow;
EnvDTE.TextPane textPane;
// , TextWindow TextPane objects...
fileWindow = applicationOb]ect.ItemOperations.OpenFile(
taskltem.FileName, EnvDTE.Constants.vsViewKinrfTextView);
textWindow = (EnvDTE.TextWindow)fileWindow.Object;
textPane = {EnvDTE.TextPane)textWindow.ActivePane;
// :
textPane.Selection.MoveTo(taskltem,Line, 1, false);
textPane.Selection.SelectLine();
navigateHandled = true;

}
\

taskListEvents
TaskListEvents, Events.TaskListEvents. , .
,
Visual Studio .NET. ,
TaskltemsAdd, . , . ,
Events.TaskListEvents :
EnvDTE.Events events = applicationObject.Events;
taskListEvents = (EnvDTE.Ta$kListEvents)events.get_TaskListEvents{"");

10

259


. EnvDTE._dispTaskListEvents_TaskNavigatedEventHandler taskListEvents,TaskNavigated :
taskListEvents.TaskNavigated += new

_dispTaskListEvents_TaskNavigatedEventHandler(this,TaskNavigated);
TaskNavigated Task List, .
TaskAdded TaskRemoved
. , TaskModified, Task List. , /
, . TaskModified , Taskltem
.


,
, ,
,
- . , (
Visual Studio .NET),
. , , Task List . , ,
, . , , ,
Task List. , //TODO: Fix this later Task List Visual C++ # Fix this later, a
'TODO: Fix this later Visual Basic .NET.
, Task List,
Options, . . 10-3 HACK, TODO, UNDONE UnresolvedMergeConflict.
, Name, Add. ,
. Properties.
Properties , ,
. CommentTokens :
Sub GetTokensArrayO
Dim tokens As ObjectO
Dim prop As EnvDTE.Property
Dim props As EnvDTE.Properties

props = DTE.Properties("Environment", "TaskList")

260

II Visual Studio .NET

prop = props.ItemC'CommentTokens")
tokens = prop.Value
End Sub

General

Environment
General
Documents

S* Qjnflrtn deletion of tasks

Dynamic Help
Font! and Cabrs
Help
International Setting
Keyboard
Projects and Solution
Web Browser

Comment Tokens
token List:

Prtorlty:

HACK
JNoTnvJT
TODO
UNDONE
! UnresolvedMergeConf

^j Options Add-in
|j Source Control
9) Text Edtor
l2i Database Tods
23 Debugging
Qj Device Tools

. 10-3-

The TODO tdosnearmol he renamed or removed, but Che ptionty fat the
token Can be mgdtf d.

Task List

CommentTokens TokenName: Priority, TokenName ,


, a Priority FMVDTE.vsTaskPriority. TODO <-TODO:2,
. . TODO*, Task List vsTaskPriorityMedium ( 2).
.
( ), .
Task List, , , . SECURITY :
Sub AddSecurityTokenQ
Dim tokens As Object()

Dim token As String


Dim prop As EnvOTE.Property
Dim props As EnvDTE.Properties
' , .
props = DTE.Properties("Environment", "TaskList")
prop = props.Item("CommentTokens")
tokens = prop.Value

.
HeDim Preserve tokens(tokens.Length)
.

10

261

tokensftokens.Length - 1) = "SECURITY: 3"


1
,
prop.Value = tokens
End Sub

:
Sub RemoveSecurityTokenO
Dim tokens As Objectf)
Dim newTokens As Object()
Dim token As String
Dim i As Integer = 0
Dim found As Boolean = False
Dim prop As EnvDTE.Property
Dim props As EnvDTE.Properties
props = DTE.Properties("Environment", "TaskList")
prop = props.ItemC'CommentTokens")
tokens = prop.Value
' , .
For Each token In tokens
If token = "SECURITY:3" Then
found = True
Exit For
End If
Next
1

SECURITY ,
.
If found = False Then
Exit Sub
End If
' newTokens.
ReDim newTokens(tokens.Length - 2)
' newTokens,
1
SECURITY.
For Each token In tokens
If token <> "SECURITY:3" Then
newTokens(i) = token
i =i + 1
End If
Next
1

' ,
prop.Value = newTokens
End Sub

, ,
, ,
, TaskListDefaultCommentToken. ,
, , :
Sub InsertTLTokenCodeO
Dim classString As String

262

II

Visual Studio .NET

Dim taskList As EnvDTE.TaskLlst


taskList = DTE.Windows.Item(Constants.vsWindowKlndTaskLlst).Object
classString = "Public Class AClass" + Chr(13)
classString = classStrtng + Chr(9) + " " + taskList.DefaultCommentToken
classString = classString + ": Insert your code here" + Chr(13)
classString = classString + "End Class"
End Sub

Output
Output Visual Studio .NET , . Output . OutputWindowPaneEx
Output.
Output OutputWindow, ;
Sub FindOutputWindowO
Dim window As EnvDTE.Window
Dim outputWindow As EnvDTE.OutputWindow
window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
outputWindow = CType(window.Object, EnvDTE.OutputWindow)
End Sub

Output
Output (panes),
.
Output. OutputWindowPanes:
Sub EnumOutputWindowPanesO
Dim window As EnvDTE.Window
Dim outputWindow As EnvDTE.OutputWindow
Dim outputWindowPanes As EnvDTE.OutputWindowPanes
Dim outputWindowPane As EnvDTE.OutputWindowPane
1
OutputWindow,
window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
outputWindow = CType(window.Object, EnvDTE.OutputWindow)
' OutputWindowPanes.
outputWindowPanes = outputWindow.OutputWindowPanes
' OutputWindowPane.
For Each outputWindowPane In outputWindowPanes
HsgBox(t)utputWindowPane. Name)
Next
End Sub

OutputWindowPanes . Add :

10

263

Sub CreateOutputWindowPaneO
Dim window As EnvDTE.Window
Dim outputWindow As EnvDTE.OutputWindow
Dim outputWindowPanes As EnvDTE.OutputWindowPanes
Dim outputWindowPane As EnvDTE.OutputWindowPane
' OutputWindow.
window = DTE.Windows.Item(EnvDTE,Constants.vsWindowKindOutput)
outputWindow = CType(window.Object, EnvDTE,OutputWindow)
' OutputWindowPanes.
outputWindowPanes = outputWindow.OutputWindowPanes
' :
outputWindowPane = outputWindowPanes.Add(" New Pane")
End Sub
My New Pane,
. OutputWindowPane.OutputString, , . , Output, , , ] .
. ,
; (ASCII- 13):
Sub DisplaySolutionDirectoryO
Dim files As StringQ
Dim file As String
Dim directoryOutputWindowPane As OutputWindowPane
Dim fullName As String
Dim outputWindow As OutputWindow
outputWindow = DTE.Windows.Item(Constants.vsWindowKindOutput).Object
' :
fullName = System.10.Path.GetDirectoryName(DTE.Solution.FullName}
files = System.10.Directory.GetFiles(fullName)
1

"Solution Directory"; , :
With outputWindow.OutputWindowPanes
Try
directoryOutputWindowPane = .Item("Solution Directory")
' :
directoryOutputWindowPane.ActivateO
Catch
directoryOutputWindowPane = .Add{"Solution Directory")
End Try
End With
' :
directoryOutputWindowPane.Clear()
For Each file In files
' .
directoryOutputWindowPane.OutputStringffile + Chr(13))
Next
End Sub

264

II

Visual Studio .NET


QutputWindowPane. . Activate
; Output.
OutputString , a Clear .
, TextDocument, ,
. Eni'DTE.TextDocument , ( .
11).


.NET Framework
Visual Studio .NET. Toolbox Properties. .NET
System.Windowsforms.
, .

IDesignerHost
, , . , Window.Object , System.ComponentModeWesignlDesignerHost.
, SystemWindows.Forms.Control. , IDesignerHostJtootComponent
Forms.Control,
System.Windows.Forms.Control control:
System.ComponentModel.Design.IDesignerHost designerHost;
designerHost =(System.ComponentModel.Design.IDesignerHost)
applicationObject.ActiveWindow.Object;
control = {System.Windows.Forms.Control)deslgnerHost.RootComponent;
SystemWindows.FormsForm System.Windowsforms.Control , Windows Form.
System.Windowsforms.Control ,
, ,
, .

IDesignerHost , SystemJRuntimeRemotmgRemotingException. , ,

10

265

System.Windows.Control, . ,
Macros IDE Visual Studio .NET . , .


IDesignerHost ,
. System.Type,
. Type.Get, . , :
System.Type type;
type = System.Type.GetType("System.Windows.Forms. ListView"};

IDesignerHost.CreateComponent .
, : ,
, , .
, ,
. ,
.
.
listViewControl:
System.ComponentModel.IComponent component;
component = designerHost.CreateComponent(type,

"listViewControl");

,
, , * Controls . Controls , Parent
, . Parent (
)
System.ComponentModelPropertyDescriptorCollection.
, , ,
, .
Parent :
System.ComponentModel.PropertyDescriptorCollection props;
System.ComponentModel.PropsrtyDescriptor propParent;
// listViewControl:
props = System.ComponentModel.TypeDescriptor.SetProperties(component);
// Parent.
propParent = propst"Parent"];
// Parent ;
propParent.SetValue(newControl, designerHost.RootComponent);

266

II

Visual Studio .NET


, .
? ,
IDesignerHostRootComponent , SystemWindowsForms.Control. , , . , , SystemWindowsForms.Control.
System.ComponentModel.Design.IDesignerHost designer;
System.Windows.Forms,Control rootControl;
// Window.Object.
rootControl = (System.Windows.Forms.Control)designer.RootComponent
foreach (System.Windows.Forms.Control control in rootControl.Controls)
I
// .
I
PropertyDescriptorCollection
, PropertyDescriptor.GetValue-.
System.ComponentModel.Design.IDesignerHost designer;
System.ComponentModel.PropertyDescriptor propControls;
System.ComponentModel.PropertyDescriptorCollection props;
System.ComponentModel.IComponent component;
System.Windows.Forms.Form form;
System.Drawing.Size size;
designer = (System.ComponentModel.Design.IDesignerHost)
applicationObject.ActiveWindow.Object;
component = designer.RootComponent;
// Size, :
props = System.ComponentModel.TypeDescriptor.GetProperties(component);
propControls = props["Size"];
size = (System.Drawing.Size)propControls.GetValue(component);
// Size :
form = (System.Windows.Forms.Form)component;
size = form.Size;


Visual Basic 6 Form Layout, ,
. Visual Studio .NET , ,
. ,
FormView, .

10

267

, . < > . ( , .)
WindowActivated ,
,
. , (. 10-4),
, . 10-5.

in Mon Tu? Wed Thu

Fri

Sat

'"

,:

:--

':;

3
10

4
11

5
12

6
13

?
14

3
15

16

17
24

18
25

19
26

20
27

21
28

22 <SJg
23

11/23/2002
button!

. 10-4.

Windows Form

. 10-5.

Form Layout , , 10-4


, Visual Studio .NET , . ,
. , Visual Studio .NET .
, , ActiveX , Wmdows.CreateToolWindow.

268

Visual Studio .NET

public EnvDTE.Window CreateToolWindow(EnvDTE.Addln Addlnlnst,


string ProgID,
string Caption,
string GuidPositlon,
ref object DocObj)

Window,
, Visual Studio .NET. .
Addlnlnst , , . ,
, a ActiveX .
ProgID ActiveX, .
Caption , .
GuidPosition GUID . , WindowsJtem
GUID, . GUID GUID,
WindowsJtem,
GUID; CreateToolWindow ,
GUID.
DocObject ActiveX - IDispatch,
.NET Framework System.Object. ActiveX ,
, . ActiveX Object Window , CreateToolWindow.
VSMediaPlayer
CreateToolWindow. Windows Media Player ActiveX,
. :
void CreateHediaPlayerToolWindowC)
{
EnvDTE.Windows windows;
EnvDTE.Window mediaPlayerWindow;
object controlObject = null;
string mediaPlayerProgID = "MediaPlayer.MediaPlayer";
string toolWindowCaption = "Windows Media Player";
string toolWindowGuld = "{AB5E549E-F823-44BB-8161-BE2BD5D698D8}";
// ,
// Windows Media Player:
windows = applicationObject.Windows;

10

269

mediaPlayerWindow = windows.CreateToolWindow(addInInstance,
mediaPlayerProgID,
toolWindowCaption,
toolWindowGuid,
ref controlObject);
mediaPlayerWindow.Visible = true;
// "Tada":
string mediaFile = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.System);
mediaFile += "\\-.\\media\\taba.wav";
MediaPlayer.IHediaPlayer2 mediaPlayer =
(MediaPlayer.IHediaPlayer2)controlObject;
mediaPlayer.Autostart = true;
mediaPlayer.FileName = mediaFile;
}

- CreateMediaPlayerToolWindow
: OnConnection OnStartupComplete.
Visual Studio .NET. ,
, Visual Studio
.NET. OnConnection. OnConnection Visual Studio
.NET CreateToolWindow OnConnection
, , Act iveX
, . ,
, connectMode, OnConnection.
ext_cm_AfterStartup,
, Visual Studio .NET. , , OnConnection
:

public void OnConnection(ob]ect application,


Extensibility.ext_ConnectMode connectMode, object addlnlnst,
ref System.Array custom)
{
applicationObject = (_DTE)application;
addlnlnstance = (Addln)addlnlnst;
// Add-in Manager,
// :
if(connectMode == Extensibility.ext_ConnectMode.ext_cm_AfterStartup)
{
CreateMediaPlayerToolWindowf);
>
I

, , OnStartupComplete. Visual Studio .,


:

270

II

Visual Studio .NET

public void OnStartupComplete(ref System.Array custom)

// ,
// :
CreateMediaPlayerToolWindow();

I
CreateToolWindow , . ,
ActiveX,
; ActiveX .NET
Framework. .NET
, .


.NET Framework,
ActiveX (shim control). ActiveX,
(, Visual C++),
CLR .NET. CLR , .
, Project | Add User Control,
Windows Control Library,
.
(VSUserControlHost), a
(CSHostedControl). . , CreateTboIWindow, ProgID ,
, CSHostedControl:
toolWindow = applicationObject.Windows.CreateToolWindow(addInInstance,
"VSUserControlHost.VSUserControlHostCtl", "C Hosted Control",
"{C4E8F504-E3FB-4828-82F4-DDD1CAE13D39}", ref ObJ);

,
. VSUserControlHostLibJVSUserControlHostCtl,
:
shimControl =
(VSUserControlHostLib.IVSUserControlHostCtl)toolWindow.Object;

IVSUserControlHostCtl , ,
, :
System.Object HostUserControl(System.String Assembly, System.String Class);
System.Object HostUserControl2(System.Int32 HWnd);

10

271

.NET-, . .
Assembly , ,
. ,
C:\Assemblydll. URL , Web-, http://localhost/Assembly.dll. , GAC, System.WindowsForms, Version=l.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c56l934e089, Custom=nutt
SystemWindowsforms,
Class , .
SystemWindowsForm,
SystemWindowsformsButton, Button Windows Forms
.
HWnd .NET, . ,
, ,
CreatelbolWindow,
, .

,
. -,
,
HostUserControl:
VSUserControlHostLib.IVSUserControlHostCtl shimControl;
string assemblyPath;
EnvOTE.Window toolWindow;
object obj = null;
toolWindow = applicationObject.Windows.reateToolWindow(addInInstance,
"VSUserControlHost.VSUserControlHostCtl", "Hosted Control",
"{A71654EC-A72E-40cf-9CD6-63FA3C52C307}", ref obj);
toolWindow.Visible = true;
shimControl =
(VSUserControlHostLib.IVSUserControlHostCtl)toolWindow.Object;
assemblyPath = System.Reflection.Assembly.GetExecutingAssemblyC).Location;
shimControl.HostUserControl(assemblyPath, "MyAddinl.UserControll");

-,
HostUserControl2:
VSUserControlHostLib.IVSUserControlHostCtl shimControl;
string assemblyPath;
EnvDTE.Window toolWindow;
object obj = null;
toolWindow = applicationObject.Windows,reateToolWindow(addIn!nstance,
"VSUserControlHost.VSUserControlHostCtl", "Hosted Control",
"{A71654EC-A72E-40cf-9CD6-63FA3C52C307}", ref O bj);
toolWindow.Visible = true;

272

II

Visual Studio .NET

shimControl =
(VSUserControlHostLib.IVSUserControlHostCtl)toolWindow.Object;
assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
UserControll uc = new UserControllQ;
shimControl.HostUserControl3(uc.Handle.Tolnt32());

: Web-

. HostUserControt .NET Framework , GAC URL . Web-. Web*
, ,
, , . Web- ,
, .
Microsoft Internet
Information Services (HS) . Web-oep, , ,
Properties, Property Pages .
Configuration Properties | Build,
Configuration Ail Configurations,
Web- ( C:\Inetpub\wwwroot) Output Path.
Web-cepaepa, http://ioc&\host/assemhlyname.(j,U.
Web-cepsepa , -, , (
GAC , ), Web-, , .NET Framework . -, TypeJnt'ok&Member. , .NET Framework . -,
, , , URL, HastUserControl,
.

10

273



,
, (. 10-6).
I '^ [ ^.:!;'^-^1-"-'' i dP '' epw?'-

. 10-6. Macro Explorer,


Solution Explorer u Properties
, , Window.SetTabPicture. -
IPictureDisp, .NET Framework System.Object. IPictureDisp : OleLoadPictureFile IPictureDisp
SetTabPicture.
, , 16x16 16.
RGB- 0,254,0. ,
(. 7); , .
WindotvSetTabPicture ,
Windows.CreateToolWindoiv. , Visual Studio
.NET, , , ,
.
Visible true,
. , V i s u a l
Studio .

Selection
Visual Studio .NET , Properties, , . ,
Solution Explorer,
, , . . Properties. ,
Properties, WindowSetSelectionContainer, System-Object. , , ,
Properties. VSMediaPlayerAdv ( VSMcdiaPlayer) Properties, SetSelectionContainer Windows Media Player, DocObj CreateToolWindow, :
object []propertiesWindowObjects = {mediaPlayer};
mediaPlayerWindow.SetSelectionContainer(ref propertiesWindowObjects);

SetSelectionContainer . , , Window Solution


Explorer .
10-1116

274

Visual Studio .NET

Options
. , Visual Studio .NET
; , . Options : , Tab,
Visual Studio .NET.


Options Properties Property, Properties,
.
,
. , Environment, Source Control
Text Editor, , .
Options, , .
Options:
, Options , , . , Properties, , Options, .
. Options, . Visual Basic .NET;
Text Editor Basic.
Text Editor Options
, ( ).
General Tabs , .
regedit.exe, _ LOCAL_MACHINE\SOFTWARE \Micro$oft\VisualStudio\7.1 \butomationProperties, ,
. Text Editor. ,
, TextEdit or ( ). , . , Basic, ,
Tools Options dialog box, - .
(TextEditor
Basic), DTEProperties Properties-.
Sub GetVBTextEditorPropertieaO
Dim properties As Properties
properties = DTE. PropertiesC'TextEditor", "Basic")
End Sub

10

275

Property Item
Properties. ,
. Properties ,
. ,
PropertiesJtem, . , ,
Properties Property,
. ,
, :
Sub WalkPropertyNames()
Dim categoryName As String
Dim key As Microsoft.Win32.RegistryKey

Dim newDocument As Document


Dim selection As TextSelection
' .
newDocument = DTE.ItemOperations.NewFile("General\Text File").Document

selection = newDocument.Selection
' , :

key = Microsoft.Win32.Registry.LocalMachine
key = key.OpenSubKey(
"SOFTWARE\Hicrosoft\VisualStudio\7.1\AutomationProperties")
' :
For Each categoryName In key.GetSubKeyNamesO
Dim subcategoryName As String
selection. Insert(categoryName + vbLf)
1
:
For Each subcategoryName In
key.OpenSubKey(categoryName).GetSubKeyNames()
Dim properties As Properties

Dim prop As [Property]


selection.Insert(" " + subcategoryName + vbLf)
Try
' :
properties = DTE.Properties(categoryName, subcategoryName)
For Each prop In properties
selection.InsertC"
" + prop.Name + vbLf)
Next
Catch
End Try
Next
Next
End Sub

, Text'Editor Basic, - Tab Size. TabSize. , Property Tab Size Visual Basic .NET
Sub GetVBTabSizePropertyC)

Dim properties As Properties

276

II

Visual Studio .NET

Dim prop As [Property]


properties = DTE.Properties("TextEditor", "Basic")
prop = properties.ItemC'TabSize")
End Sub

Property.Value:
Sub GetVBTabSize()
Dim properties As Properties
properties = DTE.PropertiesC'TextEditor", "Basic")
MsgBox(properties.ItemC'TabSize").Value)
End Sub

4 , Tools Options
Tab Size Basic Text Editor. :
Sub SetVBTabSizeO
Dim properties As Properties
properties = DTE.PropertiesC'TextEditor", "Basic")
properties.Item("TabSize").Value = 4
End Sub

, DTE.Properties,
, WalkPropertyNames, ,
Tools Options.

/s?
Visual Studio .NET Is Visual Basic .NET
QbjectJKquats .NET Framework. Is JEquals , . :
Sub CompareWindowsObjectsO

Dim wintfowl As Window


Dim window2 As Window
windowl = DTE.Windows.Iteiff(Constants.vsWindowKl5dTaskList)
window2 = DTE.Windows.IteafConstants.vsWindowKindTaskList)
MsgBox(window1 Is window2)
End SUE
True, Window, ,
Window ; , Window, . Window , .
, ( ) ( ).
:
Sui CoBipar0?r0perty9&jeetsC)
Din props"! ~ As Properties

10

Ola props2 As Properties


props"! = DTE.Praperties("EnvironBent",
proj)s2 = DTE.ProprtlesC"Environent"i
MsgBox(propsl Is props2)
End Sub

"General")
"General")

False, Properties DTEJProperties, ,


DTEProperties
. , DTEProperties ;
Properties,
.
-, Visual Studio .NET, , .NET Framework, - .NET, . vsmsvr.exe (
.NET Framework )
Windows :
Sub RepeatedConstructO
Dim i As Long
Dim props As Properties
For i * 1 To Long.MaxValue
props = DTE,Properties("Environment", "General")
Next
End Sub

, ,
, .NET Framework ,
. < > , ,
, , /5
QbjectJEquals . , RepeatetfComtntci: DTEProperties:
Sub OptiraizedRepeatedConstructO
Dim i As loog

Dim props As Properties


Dim showStatusbar As Boolean
props * DTE.Properties("Envir0nHent", "Seneral")
For i 1 To Long.MaxValue
3l3QwStatusbar = props.ItemC'StiowStatusfiar"),Value
Next
End Sub

(
) , :;
35 .

277

278

II

Visual Studio .NET


,
. Options, ActiveX
. Visual Studio .NET , Options
, , . Options,
, ,
, ActiveX,
Options.
Options, , Add-in
Wizard. , Solution Explorer View
| Registry, .
ProgID .
OptionsAddin, , , Yes, Create A
Tools Menu Item, ( 10-7):
Registry on Target Machine
__ HKEY_O.ASSES_ROOT
] IM HKEY_OJRRENTJJSER
, ' Software
.- Microsoft
-; ] ViiudStudto
-, iSi Addtns
-1 OptionsAddin. Connect
iil hV_LOCAL_MACHINE
: C3 HKEYJJ5ER5
j^ User/Machine Hive

. 10-7.

OptionsAddin

Options
, .
Options. Visual Studio .NET Options, , , Options, Options ,
Options. Options ProgID , New | Key Options. Options. ,
Options, Options,
. , Options, Options Add-in, General,
(. 10-8):

10

279

Registry on Target Machine


HKEY_CLA555_ROOT
uil HKEY_CURRENT_USER
i5l Software
-fi ] Microsoft
ri <l3 VisualStudto
E *ddlr,5
H iLO QpbonsAddin, Connect
F. Gil Option?
- Ilj Options Add-in

> u HKEY_LOCAL_MACHINE
UJ HKEV_U5ER5
^ User/Machine Hive

. 10-8.
Options
Options ProgID
ActiveX, Options. , , New | String Value Control. , Control Properties
ProgID ActiveX Value.
ActiveX, , ProgID
QptionsAddinPage.QptionsAddinPageCtl.
ActiveX
AciiveX.
,
Windows.CreateTootWindow
.NET Framework,
ActiveX-, .NET-
ActiveX. Tools
Options, -, , ActiveX, -, , ,
, .
Tools Options Visual Studio .NET, , , .

Options.
ActiveX , , Visual C++.
ATL ;
OptionsAddinPage.
ActiveX,
. Options, OptionsPageWizard,
, Tools Options.
.vsz Extensibility Projects,
9 WizardBuilder, Solution Explorer, OptionsAildin
. , -

280

II Visual Studio .NET

, ProgID , Options,

IDTToolsOptionsPage
Options : ,
. , ActiveX
IDTToolsOptionsPage. :
public Interface IDTToolsOptionsPage
I
public
public
public
public
public

void
void
void
void
void

GetPropertiesfref object PropertiesObject);


OnAfterCreated(EnvDTE.DTE DTEObject);
OnCancel();
OnHeloO;
OnOKO;

Options, Visual Studio .NET


, , ActiveX.
IDTToolsOptionsPage,
OnAfterCreated DTE, Visual Studio
.NET, ,
, ,
. , OptionsPageWizard,
: , , .
Options : OK, Cancel Help. IDTTbolsOptionsPage.OnOK,
, . , , . ,
Options . Cancel
OnCancel. , , ,
, , . Help '-,
. Help , .
IDTToolsOptionsPage ~ GetProperties Properties .
Property
, Options
Properties.
Properties GetProperties. IDispatcb, Properties. OptionsPageWizard , CbeckBoxOption,
IDispatch. ' .

10

281

OptionsAddinPage,
:
Sub GetSetCustomOptionsO
Dim properties As EnvDTE.Properties
Dim prop As EnvDTE.Property
' Properties :
properties = DTE.Properties("Options Add-in",
prop = properties. ItemfCheckBoxOption")
1
:
MsgBox(prop.Value)
1
:
prop.Value = True
MsgBox(prop.Value)

"General")

End Sub

,
, GetSetCustomOptions. , Tools
Options VSMediaPlayer,
, . :
DTE.Properties{"VSMediaPlayer",

"General").Item("MediaFile"),Value

, Property, , ; .


, Visual Studio .NET.
, .

11

, ( ), . Notepad ()! . 3,
Visual Studio .NET , , , Microsoft .


IDE, ; , . Visual Studio .NET
: ,
.'
(, , .) ,

, , .
11-1 , .

, . . .

11
Window
DTE.ActiveWindow
DTE.Windows.Item("Connect.cs")

283

Window
DTE.Windows.Item("HTMLPage1.htm")

TextWindow
DTE.ActiveWindow.Object
DTE.Windows,Item
("Connect.cs").Object

HTMLWindow
DTE.Windows.Item
("HTHLPage1.htm").Object

L- TextPane
DTE.ActiveWindow.Object.ActivePane
DTE.ActiveWindow.Selection.TextPane
DTE,Windows.Item("Connect.cs").Object.ActivePane
DTE.Windows.Item("Connect.cs").Selection.TextPane

. 11-1.

Window
Window, .
.
: , , DTEActiveWindow , , DTEWiniiows.(<>). ( . 11-1 Connect.cs I (TMLPagel.htm.)
Object, TextWindow HTMLWindow
. , Object, , TypeO/Js ( Visual Basic) is I B C#):

284

II Visual Studio .NET

If TypeOf DTE.ActiveWindow.Object Is TextWindow Then


H
End If

, ,
CLR.

TextWindow HTMLWindow
TextWindow HTMLWindow IDE,
, . . 11-1 TextWindow. ActivePane Panes,
.
. 11-1. TextWindow

ActivePane

TextPane,
.
DTE .
TextPanes, .
Window.
TextSelectton
( ParentSelection).

DTE
Panes
Parent
Selection

HTMLWindow TextWindow.
HTMLWindow (. 11-2):
. 11-2. HTMLWindow

CurrenfTab
CurrentTabObject


(HTML Design).
TextWindow, HTML
IHTMLDocument2,
Design.

DTE

DTE .

Parent

Window.

CurrentTab EnvDTE.vsHTMLTabs:
vsHTMLTabsSource HTML vsHTMLTabsDesign Design. CurrentTabObject TextWindow, HTML,
, HTMLWindow TextWindow.
, Design. CurrentTabObject
msbtmllHTMLDocument2, Dynamic
HTML (DHTML) . : Design
HTML : , ,
, . , .

11

285

msbtml, (primary interop assembly) Microsoft.mshtml.dll. Program Files\Microsoft.NET\Primary Interop


Assemblies. , ,
Add Reference; , , DLL PublicAssemblies Visual Studio
.NET, .
, ,
, . , , :
Function GetTextWindow(ByVal win As Window) As TextWindow
' : TextWindow ,
Nothing, ,
Dim txtWin As TextWindow = Nothing
' TextWindow
If TypeOf win.Object Is TextWindow Then
txtWin = win.Object
' HTMLWindow, TextWindow
Elself TypeOf win.Object Is HTMLWindow Then
Dim htmlWin As HTMLWindow = win.Object
If htmlWin.CurrentTab = vsHTHLTabs.vsHTMLTabsSource Then

txtWin = htmlWin.CurrentTabObject
End If
End If
Return txtWin
End Function

TextPane
TextPane .
,
. ,
(splitter bar)
.
.
TextPane
TextPane,
TextWindow. ActivePane Panes, TextPane. , alter ego
TextWindmv HTMLWindow ,

286

II

Visual Studio .NET

, GetTextWindow , TextWindow HTMLWindow.


TextPane TextSelection.
TextPane, , . (TextPane Selection,
TextSelection .) TextWindow, HTMLWindow Selection,
Window, , TextPane,
. , ,
TextPane TextWindow.
: .
:
Function IsSecondPaneQpen(ByVal txtWin As TextWindow) As Boolean
' : , .
Return (txtWin.Panes.Count = 2)
End Function

TextPanes, Panes TextPane


, , , Count
2.
. , TextPanes 1. , :
Function GetTopPane(ByVal txtWin As TextWindow) As TextPane
' : .
Dim txtPane As TextPane = Nothing
If txtWin.Panes.Count = 1 Then
1
, .
txtPane = txtWin.ActivePane
Else
' 2.
txtPane = txtWin.Panes.Item(2)
End If
Return txtPane
End Function
Function GetBottomPane(ByVal txtWin As TextWindow) As TextPane
1
: .
1
, .
1.
Return txtWin.Panes.Item(l)
End Function

11

287

AcUvateTopPane ActwateBottomPane, , .
, , :
TextPane? , TextPane TextPanes, , 10
/s?, TextPane
. , TextSelection, ,
, :
Function IsTopPane(ByVal txtPane As TextPane) As Boolean
' : , TextPane .
Dim result As Boolean = False
If txtPane.Collection.Count = 1 Then
result = True
Else
If txtPane.Selection Is txtPane.Collection.Item(2).Selection Then
result = True
End If
End If
Return result
End Function
Function IsBottomPaneCByVal txtPane As TextPane) As Boolean
' : , TextPane .
Dim result As Boolean = False
If txtPane.Collection.Count = 2 Then
result =
(txtPane.Selection Is txtPane.Collection.Item(1).Selection)
End If
Return result
End Function


, Spffi . '
Visual Smdio .NET Wttodow&Spfat ' > . ,
IDE, . ( ,
, , UnsplitAllW 'in- =
daws );
Sub SplitAUWifldowsO

' ; .
. <\ .

288

II Visual Studio .NET

Dim win As Window

Olra txtWiR TextWindo


Dim saveWIn As Window = QTE.ActiveWindcw
For Eacn win In DTE.Windows
txtWin = SetTextWindow(win)
If Not txtWin Is Nothing Then
SpUtWLndo*(txtWlR)
End If
Next
saveVfi n. Acti vate( >

End Sub
Sub SplltWindow<ByVal txtWin As TextWindow, _
Optional ByVal restoreActive As Boolean * False)
' ;
' .
Dim split As Command = DTE.Commands.IteiB("Mindow.Split")
Olm saveWin As Window
If restoreActive Then
saveWin = OTE.ActiveWindow

End If
txtWin. Parent. ActivateQ
If split, IsAvailable And Not IsSecondParteOpenCtxtWin) Then

DTE.commands.Raisefsplit.Guid, split.IB, Nothing, Nothing)


End If
If restoreActive Then
saveWin.AetivateO

End If
End Sub

(, ), , Visual Studio .NET . ,


: , .
, , , , .
,
: Document TextDocument.

11

289

Document
Document ; ,
, .


, ItemOf>erations Projectltems (. 8 9). , ItemOperationsNewFile, File | New | File, , . ,
NewFile-.
Sub CreateNewTextFileO
1
: , ItemOperations.NewFile
1
.
Dim
Dim
Dim
Dim

Item As String = "General\Text File"


Name As String = "MyTextFile"
ViewKind As String = Constants.vsViewKindPrimary
win As Window

win = DTE. ItemOperations. NewFiledtem, Name, ViewKind)


End Sub

Name NewFile ,
. ,
. , NewFile, Name

, Visual Studio .NET .
<'>> , , , Visual Studio .NET
Name
.
Document: DTEDocuments, WindowDocument DTEActiveDocument. H
DTEDocuments Document.
, ,
Document , , , DocumentsJtem-.
Dim doc As Document = DTE.Documents.Item("HyFile.os")
Window, Document
Document. Document, Window;
,
Document:
Function GetDocument(ByVal caption As String) As Document
1
: Document,
' ,

II Visual Studio .NET

290
1

Document.

Dim win As Window = DTE.Windows.Item(caption)


1

, .
If win Is Nothing Then
win = DTE.IteimOperations.NewFile("General\Text File", caption)
End If
Return wtn.Document
End Function


Document :
Document, Document
. DocumentNewWindow, Window | New Window.
, , ,
, (, nect.cs:I, Connect.cs:2, ..).
, , , .
Visual Basic DocumentNewWindow
*.
,
DocumentParent, , . (
?) , , DocumentWindows;
Sub ListDocumentWindowsO
' : ,
' .
Dim output As New OutputWindowPaneEx(DTE, title)
output.Clear{)
output.WriteLine("- ListDocumentWindows -")
output.WriteLine()

Dim doc As Document


For Each doc In DTE.Documents
Dim win As Window
output.WriteLine(doc.Name & " windows:")
For Each win In doc.Windows

11
output.WriteLine("

291

" & win.Caption)

Next
Next
End Sub

Document,
ActiveWindow. , ,
, ,
.
DocumentActiveWindow ,
.


Document
Readonly, /
. , , , ,
Readonly, .
, Document.Undo
DocumentMedo . , Edit. Undo Redo
, , .
DocumenWndo DocumentMedo , ,
, False. , DocumentReadOnly, ,

, ( )
. Undo Redo , , , .
Document'.TextSelection TextSelection,
,
.
TextSelection . ( TextSelection . .)

DocumentSave
. Save , ; , ,
Save . ( Visual C++
, Save ,

292

II

Visual Studio .NET

.) SaveAU
Documents. :
,
Save.
Document.Close vsSaveChanges, (vsSaveCbanges), (vsSaveCbangesNo)
(vsSaveCbangesPrompt, ). Documents CloseAll,
vsSaveCbanges,
.
DocumentSaved , : False , ,
. , IDE .
, ,
, Saved True.

TextDocument
Document IDE, TextDocument
. TextDocument Document,.Object: TextDocument; null Nothing .
TextDocument
TextPoint, EditPoint TextSelection. TextDocumentSelection

, DocumentSelection. StartPoint EndPoint TextPoint.
. CreateEditPoint EditPoint TextPoint; null Nothing
EditPoint .
TextDocument.CreateEditPoint TextPoint
, TextPoint
CreateEditPoint. null TextDocument.CreateEditPoint EditPoint .


,
. :
TextPoint, VirtualPoint EditPoint.

11

293

TextPoint
TextPoint ; VirtualPoint EduPoint TextPoint,
.
, .
Line ,
.
AbsoluteCbarOffset LineCharOffset .
AtStartQfDocument, AtEndOfDocument,
AtStartOfLine AtEndOfLine ,
.
TextPoint LessTban, EqualTo GreaterThan .
TextPoint , . , EditPoint, . TextPoint (. 11-3):
. 11-3. TextPoint

StartPoint

TextDocument
TextPane
TextRange
TextDocument
TextRange

EndPoint

VirtualPoint
VirtualPoint ,
. ,
;
. ,
Tools Options, Text Editor | All Languages | General Enable Virtual Space Settings (. 11-2).
. 11-4 VirtualPoint. ,
VirtualPoint TextSelection, ; , TextSelection VirtualPoint,
, .

It Visual Studio .NET

294

G-i Environment
ource Control
ext Editor
General
anguages

Statement Completion
%? ijgtotst members
P Hide advanced members
Parameter Information
Settings

| Basic

i '.*

%f vfetual space
~ Word wrap

I C/C++
|CSS
I HTML/XML

numbers
navigation

IP1VSQI
I Plan !
ll T-SQL

. 11-2.

bar
Note: This page set; options PW all ianoueges. Tc change ortlonsfor
one ianguage, select the desired language from the dree on the left,

. 11-4. VirtualPoint

ActivePoint
AnchorPoint
BottomPoint
TopPoint


TextSelection

TextPoint, VirtualPoint
EditPoint. , , VirtualPoint
EditPoint : , EditPoint .
, , , VirtualPoint
:
Function IsVirtualSpace(ByVal vrtPoint As VirtualPoint) As Boolean
' : , VirtualPoint
' .
Return vrtPoint.LineChardffset vrtPoint.VirtualCharOffset
End Function
VirtualPoint VirtualCharOffset, , , . VirtualCbarOffset , LineCharOffset, , .

11

295

:
,
, . .. '
- .
1. .
2. I am fish, Enter.,.
3. , . .
4. Output DisplayTextSeiectionEditPoint-:.
: DisplayColumn TopPoint BottomPoint 1 11
13 .
5. DisplayTextSvlectionVirtualPomts, Display-. .'.'.
Column TopPoint BottomPoint . ,
6. DisplayTextSelectionText , =;
I am a fish..
, VirtualPoint .
.. , VirtuatPomt
.
. I. .
2. , -:;
.
3. DisplayTexiSelectionEditPoints DtsplayTextSelec-..
. . tionVtrtuatPoints. ; EditPoint , :;;'
VirtualCbarQffset VirtualDisplayColumn VinitalPoint
LineCbarOffset DisplayColumn
4. DisplayTextSelectionText ,
, .
,
, . ^ =
, WYSINWYG-"
, , , -".
,

EditPoint
EditPoint .
TextPoint ,
.
EditPoint (. 11-5):

296

II

Visual Studio .NET

. 11-5. EditPoint

CreateEditPomt


EditPoint
TextPoint
VirtualPoint
TextDocument

EditPoint TextSelection
EditPoint",

TextSelection
TextSelection :
. (
.)
,
TextSelection. . 11-3 TextSelection
.
AnchorPoint - TopPoint
using System;
Hicroaott.Off

ActivePoint = BottoaiPolnt
ActivePoint - TopPoint
ii-

using- System;
aging

HicrosofC.Office.Core;

.AnchorPoint = BottomPoint
. 11-3-

TextSelection

, TextSelection : TopPoint, BottomPoint, AnchorPoint ActivePoint. VirtualPoint . TopPoint BottomPoint


. AncborPohit ActivePoint
; , . 11-3
using Extensibility; using EnvDTE;.
TextSelection, IsActiveEndGreater, True
ActivePoint BottomPoint. ,
TextSelectionSwapAnchor, AnchorPoint
ActivePoint.

11

297

TextSelectionJsEmpty , Text. , Text . , Text


.
, TextRanges
TextRange, .
TextSelection (. 11-6):
. 11-6. , TextSelection

Selection


Document
TextDocument
TextPane
TextWindow
Window

TextSelection EditPoint
TextSelection EditPoint
(. 11-7). : TextSelection EditPoint
, 52
, , 52
, .
, , ,
. : , , .
. 11-7. TextSelection EditPoint


Cbart.eft, CbarRighl, EndOfDocument, EndOfl-ine, LineDown, LineUp, MoveToAbsoluteOffset, MoveToLineAndOffset, MoveToPoint, StartOfDocument. StartOfLine,
WordLeft, WordRight
FindPattern

TextSelection
Collapse, GoToLine,
MoveToDisplayColumn.
PageDown, PageUp

EditPoint

FindText

GetLines, GetText

SelectAll, SelectLine
DeleteLeft. Desiructivelnsert,
CbangeCase, Copy!, Cut,
Delete. DeleteWhitespace,
NewLine, Tabify, Untabify
Indent, Insert, ImertFromFue,
PadToColumn, Paste,
ReplacePattern, SmartFormat,
Unindent

ReplaceText

. . .

298

II Visual Studio .NET

. 11-7. TextSelection EditPoint ()


ClearBookmark, NextBookmark, PreviousBookmark,
SetBookmark
OutlineSection

TextSelection

EditPoint

SwapAnchor

Readonly

, TextSelection
, a EditPoint . TextSelection
, : - ,
TextSelection. ( ,
: Macro Recorder ,
, TextSelection,) WYSIWYG, , , TextSelection. ,
, , TextSelecUonLineDoum :
,
.
, EditPoint . , EditPointJLineDown EditPoint
. , EditPoint,
.
, ,
, TextSelection;
, EditPoint.


, . , ,
.

. Visual Studio
.NET, , ' .

11

299


. (
, , ,
.) IDE Visual
Studio .NET ,
. ,
, Visual Studio
.NET.
1. Visual Studio .NET.
2. spelled backwards is Enter.
3. ,
, Undo, (. 11 -4). ( , ,
.) Paste, Enter , . ,
, .
ieiul!.l>e*4loprirent Ifmianmenl [design] T*Mfife1*

. 11-4.


: ,
, ,

300

II Visual Studio .NET

. .
, DTE.UndoContext: Open
, SetAbortect , , a Close .
Visual Studio .NET ,
. -,
Open try, , .
UndoContextlsOpen, True,
, False ,
, Open. -,
, Close SetAbort. ( , , SetAbort
, Close
, .) -, SetAbort Close - , :
.
! , ,
. ,
Visual Studio .NET. (
, ,
.) , ,
SetAhort Close,
.
, ,
- .
, UndoContextJsOpen . 11-1 .
11-1. ,
UndoContextTimer
<System.ContextStaticAttribute()> Public WithEvents UndoTiraer _

As System.Timers,Tiraer

Private Const title As String <* "Text Editor"


Sub UndoContextTimerO
: , ,
' UndoContext. IsQpen,

11

301

* .
, .
If Not AdoTextO Then
UndoTiffler = Hew System.fleers.TimerO
iMdoTiae .Interval - 100
URdoTlaer,Enabled * True
End If
End Sub

private Function AddTextC) As Boolean


" : "Text File"
' "Tiraer".
Dim success As Boolean = True
Try

' .
OTE.UndoContext.Qpen("Tlmer")
' "Text File" .
Di txtOoc As TextDocument = GetTextOoeument("Text File")
Din editPnt Aa EditPoint = txtDoe.StartPoint.CreateEditPoint
* .
editPnt.!nsert("Here's text in the 'Timer' undo context."
+ System,environment.NewLine)
' .
OTE.UndoContext.CloseO
Catch

success - False
End Try
Return success
End Function

Public Sub UndoTiroer_Elapsed{ByVal sender As Object,


ByVal e As Systen.Timers.ElapsedEventArgs) Handles UndoTimer.Elapsed
' , .
If Not DTE.UndoContext.IsSpen Then
UndoTimer.Enabled = False
' , AddText .,
' . ,
If AddTextO Tften

Else

.Dispose()
Nothing

. . .

302

II Visual Studio .NET

UntJoTimer. Enabled * True


End If

End If

end sub

Function GetTextCocumeRt(ByVal caption As String) As TextOaeuaent


" : TextDocument,
'
'- TextOocumsfit.
. Dim doc As Document = GetDocument(Gaptlon)
fietyrn doc , Ob j ect ( "TextDocuiee nt " }
End Function
Function QetDocunient(caption As String) As Ooeufflent
' ; Document,
'
" .
Dim win As Window

' , .
win = 9. Windows, IteiB< caption)
Catch
' .
win = DTE.ItemOperatiorvs.NewFiie("Seneral\Text File", caption)
End Try
Return win. Document
End Function
, 11-1,
. , .


,
. ,
Document 1 Document2 Link.
Link . ,
Link Document 1, Link Document 2,
. .
DocurnentZ.
Document2. , Link Docunientl? Link, Link Document2, :

11

303

Link Document2, .
.
, . ,
, , ; , , .
Link , Link Documentl, Document2. Link
Documentl, Document2
, Documentl. , . , Link Documentl.
UndoContext.Open,
True . (+) ,

:
UndoContextsStackLinkfige .
; Soo/ , :
. ,
, .
1. Command Window Macros.InsidVSI4ET.Cfaapterll,TJndo Contexts.StackLinkage Enter. : :
Nonstiictl, Honstrict2 Nonstrict3
NonsErictLinkage.
2. Undo, Redo, ,
,
.
3. Nonstrict2.
4. Nonstrict3 Undo,
Nonstrict3 , Undo rroce-'
. Nonstrictl Nonstrict2 NonstrictUnkage, , NonsfrictLinkage - %,'
. , NonstrictLinkage Nonsmct l ,,,
Nonslrictl NonstricU, .
,
True , 1. True
StackLinkage Strict I, Strict2 Strict3
StrictLinkage. .."
. 4, The application cannot undo*. .

304

II

Visual Studio .NET

LineChanged
, , LineChanged. , , , ' :
, , , ,
- , ,
.
LineChanged , ,
.. StartPoint EndPoint
. , TextPoint :
Dim text As String
text = StartPoint.CreateEditPoint.GetText(EndPoint)
, , , , :
Dim doc As Document

doc = StartPoint.Parent.Parent
, Hint, , vsTextChanged (. 11-8). Hint , , , [ Hint , , .
, (hint).]
. 11-8. vsTextChanged

I'sTextCbangedMultiLint'?
vsTextChangedSave
vsTextCbangedCaretMoved
vsTextChangedReplaceAtL
usTextCbangedNewLine
vsTextChangedFindStarting

.
.
, .
.
.

, .

LineChanged , .
, , ,
,
.
; ,
(

11

305

, . .). StartPoint EndPoint, , , . 1 1-2.


11-2. ,
LineChanged
UndoContexts LineChanged
Private Const title As String = "Text Editing Events"
<Systew. Context &taticAttrllnite()> Public WithEvents _
TextEditorEventsl As EnvDTE.TextEditorEvents
Sub LineCftangedAndUndoContextsCOptipnal ByVal useUndoContext
As String * "False")

' :
' LineChanged.

TextEditorEventsl = UTE. Events. TextEditorEventsO

Dim useUndo As Boolean * ToBoolearKuseUndoContext)


' .
Dint txtOoc As TextDocuraent = GetTextDocuraent{"LineChanged Test")

Dim editpnt As EditPoint * txtOoc, EnttPoint.CreateEditPoint


' . ,
LineChanged.
editPnt. Insert ('" Beginning of dociwent.")
It
Try

DTE,UndoOontext.OpenC"U.rjeChangedAndUndoC0fitexts'')
1


' LineCnanged, .
editPnt.Insert(Environnient.NewLine)
editPnt.Insert("Here's a new line." + Environment. NewLine)

:;

Else

DTE . UndoContext . Close ( )


Catch

End Try
1


LineChanged.
editPnt . Insert ( Envi rsnsent . SewLine)
editPnt.Inaert< "Here's a new line." + Environnent.Kewline)
End If
. . .

306

II

Visual Studio .NET

End Sute
' tineCnanged,
. Public Sub TextEtfitorEveivtslJJlneCnangedC _
ByVal StartPoiat As EnvDTE.TextPoirrt,
ByVal EndPoint As EnvDTE.TextPotflt,
ByVal Hint As Intefer) Handles
Dim output As New 0utputWin6a*PaneExCQTE, title)
output.WriteLineC"- TextEditrEvents1_LineCnanged -")
output.WriteLlneC'Changed text:")
output. WriteLi(StartPoint,CreateE6itPoint.Get Text(ERclPoint))
output.WriteLineO
End Sub
Function ToBoolearKByVal val As Object) As Boolean
Sim bool As Boolean * False
:

* ,
bool * System.Convert,ToBoolean(val)
Catch
End Try
Return &ool
: End Function

LineChangedAndUndoContexts 11-2
. . 11-5
: LineChanged
, , .
. 11-6 , ,
. , , ,
LineCbanged, .

11

-.-.:'

tlneChangcd And UndoContcKl

PMC. 7 i-5.
LineChanged

. 11-6.
LineChanged

307

308

II

Visual Studio .NET

LineChanged
LineChanged ,
LineChanged, ,
. , , ,
;
Hint, StartPoint EndPoint ,
, .

:
MultipleHandlers LineCbanged. MultipleHanctlers
LineChanged, : LineCbangedlt LmeChanged2 LineCbcmged3. ( , .
,
.)
; , LineChangedl LineCbang&d2
, ,
LineCbanged2 LineCbanged3 .
MultipleHandfers ,
Boolean, , LineCbcmged2. False (
) ReplaceAU LineCbanged2
, True LineCbanged2
. : ReplaceAU
LineCbanged LineChanged3 ,
.
1.
1. .
2. Command Window Mu|tipleHandlers.Coanect,fieplaceAll
Enter.
3. - (, Here's a line)
Enter.
Enter LineChanged, Text Editing
Event Output Window . , LineCbanged 1 LineCbanged3
, ,
2 Hint
1. .
2. Command Window Mult ipleHand lers.Connect.Replac eAU
Enter.

11

309

3- TextMitingEventsMeplacvTextWitbLastTwoLmes. Test Editing Event Output Window , vsTextCbangedRept&ceAli


ReplaceTextWithLasffivoLines .
LineCbangpd vsTesctChangedReplaceMl, ,
. ,
, MultipleHandlers UneCbange42.
\. .
2. Command Window MultipleHandlcrs.Coiinect.KeplaceA I
Enter.
3. Enter.
, ,
usTextChangedCaretMoved vsTexiCbangedNetvline, LineChanged2 ,
vsTextChangedReplaceAU. ,
Hints :
, Hints
}' .


.
, , ?
, . ,
, ,
. 12 , , .

12

Visual Studio .NET , , 1 . : API,


,
Visual Studio .NET API .
, Visual Studio .NET.


.

, .


, # ( 12-1).
: , , , . ; ,
-, .

*
, *, . , .

12

311

12-1. #
namespace CM Names pace
<
delegate void CMDelegate(int delParam);

;;-;;. struct enstruct .


\

:j

field;

enum CMEnura

interface CMInterface<
inf CInterfaee*tetfcodC);
}
I C(Attribute("CHVal"> I
class CMClass

object member-Van

:;;;

void C^CallbaekFunotion<int param)

int C*tProperty
{

.i.get
{

return 0;
}
;;; ,/"" '
set' ""- -

.
CodeElement. CodeElement
,
. . 12-1 , 12-1 .

312

It Visual Studio .NET

CodeElement
CMNamespace

CodeElement
CMDelegate

CodeElement

delParam
CodeElemeni

'

CMStruct

CodeElement

Held
CodeElement
CMEnum

CodeElement
Member

CodeElement

CMInterface

CodeElement
CMInterfaceMethod

CodeElement

-I

GMCtess

CodeElement
CMAttribute
CodeElement
memberVar

CodeElement
CMCattbackFunction

CodeElement
param

CodeElement
CMProperty

. 12-1. CodeElement,
12-1
. 12-1 CodeElement
CMNomespoce. , CodeElement
:
.
, :
21 * cout Hello,
world;, Visual C++.
,
Visual C++, Visual C#, Visual J# Visual Basic
API. , ,
, .
;

12

313

;
.


, . 12-1,
CodeElement . FileCodeModel , FiieCodeModeLCodeElements CodeElement .
CMNamespace, CodeElement FiieCodeModeLCodeElements.
( CodeModelCodeElements,
CodeElement ,
, CMNamespace.)
, 12-2
, FileCodeModel CodeModel. .
12-2.

GetFileCodeModel GetCodeModel

Function {JetFIlsCodeModelO As FileCodeHodel


' : FileCodeHodel .
Dim txtWin As TextKindow GetTextWindow(DT,AetiveWindaw)
Dim fern As FileCodeHodel
If Not txtWin Is Nothing Then
Try
fern = txtWin.Parent.Projectlteffl.FileGodeModel
Catch e As Exception
End Try
nd If
ftetucn tea
End Function
Function GetCodeModelO As CodeModel
' : GodeHodel ,
Dim txtWin As TextWinctow = GetTextWindow(DTE.ActiveWindow)
Dim era As CodeHodel
If Hot txtWin Is Nothing Then
Try

cm = txtWin.Parent.Projectltein.ContainingProject.CodeModel
Catch e As.Exception
End Try
End If

Return effl
End function

314

II Visual Studio .NET

, CodeElement , CodeElement
CMNamespace? CodeElement,
,
CodeElement. : CodeNamespace, CodeStntct, CodeInterface, CodeClass, CodeEnum, CodeVariable, CodeDelegate. CodeProperty, CodeAitribute,
CodeFunction CodeParameter.
, , , CodeFunction
Parameters, CodeParameter . CodeElementXind
vsCMElement, . Kind CodeElement CMNamespace
vsCMElementNamespace, , CodeNamespace CodeElement.
CodeNamespace

CMNamesftace

CodeParameter
CodeStruct

GMStruct

CodeVariable
Field

CodeEnum

GodeVariable

Codelntertace

CMInterface
CodeClass
CMCiass

CodeFunction

CMInterfaceMethod
CodeAttribute
CMAttrlbute
CodeVariable

memberVar
CodeFunction
CMCailbackFunction

CodeParameter
param

CodeProperty

CMProperty
. 12-2.

12

315

CodeNamespace, Members. Members ,


.
CodeElement n CodeElement Members ,
. 12-2 . , Members.
12-3 .
CodeElements RecurseCodeElements,
, Output, ,
Members, .
12-3.
Sub TestfleeurseCodeEleraentsO
Die outjjBt As New OutputWindowPaneEx(STE)
output.Cleaf<)
output.WriteiinsC"- TestfieeurseOodeElements -")

output. WriteLineO
Hi fern As FUeCodelitodel GetftleCodeHMfelO
If Not fern Is Hofhlng TTien
RseurseGodeEletEierrtsffciB.GodeEleiBents, 0> ;
End If
ffltf Sub
Sub ftecurseCodeElementsfByVal elements As CodeEleraents, _
ByVal level As Integer)
DlB output As Hew QutputWindowPane&c{DTE)
DiiB indent As Hew StringC ", 4 * level)
Din members As Codefilssients
Dim elem CodeElement
' CodeElements.
For Eaeli elem In elements
' .
output.WriteLI(indent 4 elem.Same)
fseabers = QetMembers(elem)
If Not members Is Netfclng Tnen
' .
RecurseodeEleneftts(Ben?bers, level + 1)

End If

''

- Hext
End Sub

'

--.

'-.
. . .

31 6

II

Visual Studio .NET

Function GetMembers<8yVal elern As CodeElement) As CodeElements


Din members As CodeElements = Nothing
If Not elm Is Nothing Then
' Members.
Select Case elem.Kind
Case vsCMElefflent. vsCHElementNaeiespace
Oin) cdefiamespace As CodeNatnespace = elem
members = cdeNamespaee.Members
Case vsCHElement.vsCHElernentClass
Dim edeClass As CodeClass = elera
members = cdeGlass.Members
Case vsGHElement.vsCMElementStruct
Dim ctJeStruct As CodeStruct = elem
members * cdeStruct.Members
Case vsCMElement.vsGMElementOeleoate
Bira cdeDelegate As CodeDelegate = elem
members = cdeDelegate.Merabers
Case vsCMElement.vsCMElementEnum
Dim cdeEnum As CodeEnum = elem
raijmbers = cdeEnum. Members
Case vsCMElefflent-vsCHEleroentlnterfaee
Si cdelnterface As Codelnterface = elem
members = cdelnterface.Members
End Select
End If
Return members
. End Function

GetMembers 12-3
CodeElement,
Members . Visual Basic Members
CodeElement, ,
Members. CodeElement ( Query Interface), ,
.
GetMembers , CodeType,
, : CodeClass.
CodeStruct, Codelnterface, CodeEnum CodeDelegate. (, CodeType
Members, , -

12

317

.) CodeElement,
CodeType , CodeElemenUsCodeType.
, CodeType (. 12-3). CodeType
, 12-4. CodeType- CodeType
CodeNamespace. RecurseCodeElementsByCodeType
If CodeNamespace.
CodeNamespace

CMNamespacs
Code Type
CMOelegate

CocleParameter
tfelParam

CodeType
CMStruct

CodeVariable
Field

CodeType
CMEntim

CodeVariable
Member

CodeType
CMtnterface

CodeFunction

CMInterfaceMethod
CodeType

CMCiass

CodeAttribute
CMAttritiute

CodeVariable
memberVar
CodeFunction
CMCaHbackFunction

CodeParsmeter
param

CodeProperty

GMProperty
. 12-3.

CodeType

. . 12-2 12-3 , Members CodeElement, , - . CodeClass Attributes, CodeAttribute, , CodeDelegate CodeFunction, Parameters Code-

318

II

Visual Studio .NET

Parameter.
.
12-4.

CodeType

Sub TestReeurseCodeEleiBents8yGQdeType{ )
Dim output As Hew QMtpatWindowParwEx(DTE)
output . Glea r( }
output. WritetineC"- TestFtecurseCodeElementsfiyCodeType -")
output.
81 foe As ! = GetFileCodeHodelO
If Hot fen Is Mottling Tien
RecurseCorfeElementsByCodeType(fMB.Co6eElemeftts, t)
End If
End Sufc
Sub HecurseGodeElefflentsSyGodeType(ByVal elenetits fts CodeEleBents, _
ByVal level As Integer)

Dim output As Hew OutputWindowPar>eEx{DTE)


0i imlent As New StrlrtgC" "*, 4 * level)
Dim el em As CodeElement
' CodeElements.
Fo=r EaeN ele In elefients
' .

output. hfriteUne indent S elea.tteme)


" , .
If alem.Klrtd = vsCHEleroent. vsCMEleifientNamespace Then
Dim cdeNamespace As CodeNamespace = elem
' .
BecurseCodeElementsfiyCodeType(cdeftaispace.M6artjersF lewl + 1}
' &, CodeType,
Elself elefa.IsCotJeType Then

OiBi cdeTyps As CktdeType - elem


:
' .
RecurfieCodeElementsSyCcKfeType^deType.Heiebers, level + 1)
Ertd If

Next
End Sub

. .

; ; - : ' . - -'.- . ..

319

12

: Code Model Explorer


Code Model Explorer ()
, Visual Studio
.. ,
.
1. Visual C++.
2. Tools | Code Model
Explorer.
3- Output.
4 CConnect (. 12-4).
Codr T^mJri Exptorer

LJ ScuceFte
- -^J HutaFfet
Cwnen.li

? COM
.. ? "

. Resomci
4tdafK.h

-' i

Stow
* Children

. 12-4.
* ,
CodeSfement,
Output. Output ( 12-4) - CodeClass Details
, CConnect CodeClass; Bases
CConnect: CComObjectRootEx, CComCoClas*
/Dfspatcfefmpl; Children 14 -CodeElejn&nt
CConnect.
Show Definition,
CodeEl&tnent. Show
Definition, CConnect OnConnection, ;te OnConnection, Connect.
( 12-5).
Show Children
4( Children, CodeEl&ment Visual C++
CbUdren Members. Show Children,
- CConnect ~~ Children, '}
(. 12-6). : Members
.

cjierf.

II Visual Studio NET

320

, ,
Children. ,
COMJNTERPACE_ENTRY- OMJNTESMCEJffTKy,
, 12-7.

0 Elpltrtr - Myftttttl X .
olution WyAddmr pro
MyBddini

_pDTE - HULL;
eturn S OK;
; STDHETHODIIIP : .CiBjlOdlnsUpdaCE (Sir 1
(

ESCUCn 3_OE;
1

iSTDMETHODIHF CConnaoCi i OnStarcupCompicti

. 12-5-

Sbow Definition CMS

CConnecl

? COM
- FmalConstiuct
FinalRelease
OilComeclion
:* OnDisconnecHori
.* OrAddrsUpdale
!

On El talup Complete
OnEleginShutdown

> m_FOTE
rn_fAddlnlnslance

? COM
in_pDTE
(Xonnert

Code Model ObieK


* FUeCodeMotel
f

CctieMode!

. 12-6.

Show Detirnlran
Show Children

Show Children

12

? COM
. FnaConslrucl
- FnaHetase
* OnConneclen
OnDisconneclion
- OrAddliuHJpdatr
* OnStactupCompH!
* OnBegmShuldonn
m_[CTE

. 12-7.

Kind c

Ltnguagt

COMJNTERFACE^ENTRY

, CodeModel, Tbi CodeElement-, CodeMofteLCQd&Elements. Kpo>je


, FtieCodeModel,
CodeElement, : IDL

CodeElement
, CodeElement
. CodeElement
. .
CodeElement :
CodeElementFromPoint FileCodeModel CodeElement
TextPoint, EditPoint VirtualPoint. CodeElementFromPoint.
CodeElement CodeElementFromPoint(TextPoint Point, vsCMElement Scope);
CodeElementFromPoint TextPoint,
, vsCMElement, ,
. , 12-1 TextPoint, CMCallbackFunction,
CodeElementFromPoint vsCMElement, vsCMElementPararneter,
CodeElement, \ CodeElementFromPoint vsCMElement, vsCMElementClass, CodeElement, CMClass.
CodeElement vsCMElement, Scope CodeElementFromPoint.
, CodeElementFromPoint,
CodeElement. , CodeElement
CodeElementFromPoint -

322

II

Visual Studio .NET

xxxPointParentParentProjectltemfileCodeModel.CodeElementFromPoint.

; CodeElement
TestCodeEl&mentFromPoint TestCodeJEtementProperty -:;
, Scope CodeElement,
CodeElemetitPromPoint CodeElement.
Output,
, . CodeElementFromPoint CodeEh'ment
;; vsCMElement Scope
CodeElement Output.

, , Visual - .
* . , 12-1 '
Visual --. param ^
CMCallbac&Fitttction TestCodeMlemenfFromPoint, Visual - CMCctttbacfePttnction vsCMEtementFunction, CMClass
vsCMElementOass CMNamespac-e vsCMEfementNamespace,
param vsCMEIemeiitParameter*.
:
-' |>: Visual # Visual }# 2 3 ^sCMEt&mentPanxmeter vsCMEtemetitFunctton), a Visual Basic 1 3 ;'"
(vsCMElementParctm&tef). -~
CodeElement. vsCMElementParameter, , vsCMElementFunction,
? CodeElementFromPomt CodeElement ,
, , , .



. : AddClass, Visual C#, .cs, Visual C++
.-, Visual J# .jsl-. ,
, 12-1. :
( , , . ).


, , cAdd-.AddNamespace, AddClass, AddVariable . . Add-, CodeElement,
CodeElement. : CodeElement

12

323

CodeElemeffi
, ; ,
. 12-1 CMNamespace, :
Sub CreateLlsting_12_1{)
Dim fern As FileCodeModel = GetFileCodeModelQ
If Not fern Is Nothing Then
Dim cdeNamespace As CodeNamespace
1
.
Try
cdeNamespace = fcm.AddNamespace("CMNamespace")
Catch e As Exception
End Try

6 .
If Not cdeNamespace Is Nothing Then

End If
End If
End Sub

FileCodeModel AddNamespace
CodeNamespace. AddNamespace Try/Catch,
Add ,
. , , , .
CMDelegate
, , Try/
Catch:
Try
Dim cdeDelegate As CodeDelegate
' ,
cdeDelegate = cdeNamespace.AddDelegate("CMDelegate",
vsCMTypeRef.vsCMTypeflefVoid)
1

.
cdeDelegate.AddParameter("delParam", vsCMTypeRef.vsCHTypeReflnt)
Catch e As Exception
End Try

AddDelegate AddParameter ,
; vsCMTypeRef.vsCMTypeReJVoid , a vsCM-

324

II Visual Studio .NET

TypeRefmCMTypeReflnt .
, AddParameter,
.
:
Dim cdeStruct As CodeStruct
' .
cdeStruct = cdeNamespace.AddStructC'CMStruct",

-1)

.
cdeStruct.AddVariablef"field", vsCMTypeRef.vsCMTypeReflnt)
Catch e As Exception
End Try

:
, , A/rf-,
, . -1 i&AddStruct
; ^-. :
Try

Dim cdeEnum As CodeEnum


' .
cdeEnum = cdeNamespace.AddEnum("CMEnum", -1)
' ,
cdeEnum.AddMember("Member")
Catch e As Exception
End Try
Try
Dim cdelnterface As Codelnterface
' .
cdelnterface = cdeNamespace.AddInterface("CMInterface",

-1)

.
cdeInterface.AddFunction("CMInterfaceMethod",
vsCHFunction.vsCMFunctionFunction, vsCMTypeRef,vsCMTypeReflnt)
Catch e As Exception
End Try

AddFunction : , , . . vsCMFunction.vsCMFunctionFunction CMInterfaceMetbod . ,


, , , :

12

325

Try

Dim cdeClass As CodeClass


' .
cdeClass = cdeNamespace.AddClass("CMClass", -1)
Try

' .
cdeClass.AddAttributeC'CMAttribute", "CMVal")
Catch e As Exception
End Try

Try
1

- .
cdeClass.AddVariableC'memberVa", vsCMTypeRef.vsCHTypeRefObject, -1)
Catch e As Exception
End Try
Try

Dim cdeFunction As CodeFunction


- .
cdeFunction = cdeClass.AddFunction{"CMCallbackFunction",
vsCHFunction.vsCMFunctionFunction,
vsCMTypeRef.vsCMTypeRefVoid, -1}
' .
cdeFunction.AddParameterC'param", vsCMTypeRef .vsCMTypeRef Int)
Catch e As Exception
End Try
Try
.
cdeClass.AddPropertyC'CHProperty", "CMProperty",
vsCMTypeRef.vsCHTypeReflnt, -1)
Catch e As Exception
End Try
Catch e As Exception
End Try

, , : :! 12-1 , - , ,
Add-,. , :,
CreateListing_l2_1 : Visual C#
, , Visual C++ , , Visual J# ,
, , , , a Visual Basic
... :
, .

326

II

Visual Studio .NET


. , :
Setup, Help,
V I 2 , IDE Visual
Studio .NET, , .

Ml

13

, ,
-
Microsoft Visual Studio .NET, Windows Installer.

Microsoft Windows Installer (MSI)


- Microsoft Windows
, , DLL
. win.ini
system.ini, C:\Windows.
: , Windows, . Windows , . DLL- , . Start, .
Web-npoe Web- XMI, Web-
,
Microsoft Internet Information Services (IIS), Web- .

13

329

Windows . , Microsoft, Acme Setup , Microsoft


Office 95 Microsoft Visual Studio 6.0. Acme Setup
, , .
, . (, ) , ;
.
, Office
Windows Installer. Windows Installer, .msi;

. , ,
.msi ( , , CD DVD, .msi).
, - ( 2.0 Windows Installer, Visual Studio .NET .NET Framework) .NET Web- .NET Windows Installer,
. Windows Installer
, ,
, Add Or Remove
Programs . , , Windows Installer
, . , , , < .


Visual Studio .NET , .msi. , New Project Setup And Deployment Projects
Project Types. Setup Project ,
.NET Win32, , a Web Setup
Project Web- Web- .
Merge Module (. ) .

Build \ Build Solution, , Configuration Manager . ,

330

III ,

.msi, . , Solution Explorer


Build Build
Configuration Manager.
, Build , .
,
: File System, Registry, File Types, User Interface, Custom Actions Launch
Conditions. , ,
. , Solution Explorer
Solution Explorer
View, ,

File System
, .msi. File System
, , .

, ,
. File System
, . , ,
Add : Folder , Project Output ,
, , File Assembly
. Visual Studio .NET ,
( ).
Common Files Folder , (C:\Program Files\Common Files).
Fonts Folder , (C:\Windows\Fonts ).
Program Files Folder , (C:\Program Files).
System Folder .
(C:\Windows\System32).
User's Application Data Folder , , (C:\Documents and
Set tings \\ lie ation Data).
User's Desktop , (C:\Documents and Set tings \ \Desktop ).

13

331

User's Favorites Folder (C:\Documents and Settings\cwb3oeamaxb\Favorites ).


User's Personal Data Folder ,
(C:\Documents and Settings\ttcyz&3oe#me/zb\My Documents).
User's Programs Menu Start
(C:\Documents and $%5\\$ Menu\Programs).
User's Send To Menu Send To, ,
Windows Explorer Send To (C:\Documents and
Set tings\a/zwoeme\SendTo).
User's Start Menu Start (C:\Documents and Settings\cw&\51 Menu).
User's Startup Folder ( ),
(C:\Document.s and
Settings\nojib3oeameab\St3.rt Menu\Programs\Startup).
User's Template Folder , . New (C:\Documents and Settings\7Zcyztu306ma^b\Templates).
Windows Folder ( C:\Windows).
Global Assembly Cache Folder (GAC) . , , .NET Framework
.
Application Folder , , (:\Program [\5\\ - ;
- Properties,
Solution Explorer).
Web Application Folder , , Web Setup Project. , ,
IIS ( ) Web-.
, ,
- . ,
File System On Target Machine File System
Add Special Folder | Custom Folder. , , ,
File System. , DefaultLocation Properties.
, : ,
, .
, .


,
File System. -

332

III ,

File System.
. , Debug
Release, , , . : , .msi , . , .
File System,
, , Add | Project
Output. Add Project Output Group , , .
.
Documentation Files File System , IntelHDoc. IntelliDoc
#, ,
. Project #.
Primary Output DLL ,
. File System, .
Localized Resources ,
File System DLL .
Debug Symbols
, .pdb, .
File System, ,
.
.msi. , .
Content Files
, .
Source Files , .
Built Outputs ,
. .msi .
, Visual Studio
.NET (,
DLL ), . DLL .msi
, DLL. File System DLL ,
, Solution Explorer Detected
Dependencies.

13

333

, , ,
Exclude. , , , ,
, .msi. ,
File System,
, .
, ,
, ,
.

?
, , , , , .msi. ,
. , VSLangProj.
, ,
VSLangProj, < . , VSLangproj Primary Interop Assembly
(1) VSLangProj.tlb,
. . File System - ( ), .
.msi , Windows Installer .
VSLangProj.tlb,
, , ] >
Visual Studio .NET, , , , .
-
, File System
, -,;
, .
,
Exclude , ,
, , . {VSLangPny , .)
,msi, ! ,
, , . -, .:' , .
Visual Studio .NET, ,
. . .

334

(II

. -,
. , .
, ( VSL.angProj.tib),
, ,
, .msi.

Registry
Registry * , .msi.
, . Registry ,
Add-in Wizard ,
, (
), , Visual Studio .NET , .
Registry Registry Editor
(regedit.exe), Windows. ,
, regedit.exe, ,
Registry. , ,
Registry' Visual Studio .NET, ,
-, C++, : - Registry -
. - File
System, Register Properties vsdipCOM,
. . - ,
DllRegisterServer DUUnregisterServer. , -
, Windows
Installer. , DllUnregisterSewer,
;
, . ,
-
. ,rgs Registry ,
, -, DLL . .
User/Machine
Registry ( ) : HKEY_CLASSES_ROOT, HKEY_CURRENTJJSER, HKEY_LOCAL_MACHINE HKEY_USERS. , Registry-

13

335

.msi , , User/Machine Hive.


HKEY_LOCAL_MACHINE
HKEY_CURRENT_USER , .msi. ,
.msi,
, . 13-1.
: Everyone Just Me. Everyone,
, User/Machine Hive HKEY_LOCAL_MACHINE, Just Me
HKEY_CURRENT_USER.
, ,msi, , Guest,
, Just Me.

Select Installation Folder

The wi) install Setupl to Kia tofcwing folder


To mstat in this (oldei, cfcfc "Next". To inslaS toadiffeierit a. enter * bebw dick "".

FofdeiC. Program FJesVDetault Company Name\SeLip1\

Install Setupl fa yourself. o< iat aryone who use* iHs computer

: Back

. 13-1.

Select Installation Folder .msi


Registry * , . ,

, . , .msi.
. , Registry
;
.msi , Windows Installer .

336

III

. 13-1 200 .
Windows Installer.
, MSDN. ,
.msi, {Date] , . ,
. , jl'ime][Date] 10 2002 17:54:35 17:54:35-11/10/2002.
. Registry ,
HKEY_LOCAL_MACHINE\Software\[Manufacturer] HKEY_CURRENT_USER\Software\[Manufacturer]. , ,
; [Manufacturer]
, Manufacturer
Properties, Solution Explorer.
. 13-1.

AdminToolsFolder

AdminUser

AppDatafolder

ARPCONTACr

Author

CommonApp
DataFolder
CommonFuesFolder
ComputerName
Date
DesktopFolder
FavoritesFolder

,

.

C:\Docurnencs and Setrings\


. Menu\
Programs \Administrative
Tools\

1, ,
i
, , 0 .
, ,
C:\Documents and Settings\
,
Data\
-
.
Author, Properties,
.
.

Properties,
Solution Explorer.
,
C:\Documents and Settings\
All Users\Application
.
Data\
, C:\Program Files\Common
, .
Files\
.
CRAIGS4000
.msi.
11/10/2002

C:\Documents and Settings\
.
, C:\Docurnents and Settings\
Internet Explorer.

13

337

(]

. 13-1.

FontsFolder

C:\Windows\Fonts\

InteL

Intel,

: 4 486.
5 Pentium, 6 . .

,
.

,
.msi.
,
.msi.

Craig Skibo

MyPicturesFolder

, .

C:\Documents and Settings\


\ Documents\ My Pictures\

MsiNTProductType

: 1 1
, 2 , 3 .
,
C:\Documents and Settings\

LocalAppDataFolder

LogonVser
Manufacturer

NetHoodFolder

C:\Documents and Settings\


\
Local Settings\
Application Data\

PersonalFolder

,
.

C:\Documents and Settings\


1\
My Documents\

PhysicalMemory

( ) ,
.msi.
,
.
1,

.

384

PrintHoodFolder
Privileged

C:\Documents and Settings\

ProductID

,
Serial Number User
Information (. ).

ProductName

.
Setupl
,
ProductName Properties
Visual Studio .NET,
.
1.0.0
.msi.

Version Properties,

Solution Explorer.
C:\Progratn Files\
Program Files.

ProductVersion

ProgramFilesFolder

111-7000000

. . .

12-1116

338

III ,

. 13-1.

ProgramMenuFolder ,
Stare.
RecentFolder
RemoteAdminTS
ROOTDRIVE

ScreenX

ScreenY

SendToFolder

ServicePackLeveL

Sen'icePackLevelMinor
SourceDir

StartMenuFolder
StartupFolder

SystemFolder
SystetnLanguagelD
TARGETDIR

TempFolder

TemplateFolder

,

.
1,
,
,
.
( ) .
( )
.
, : , ,

Windows Explorer
Send To.


(service pack).

.
, .msi.

()

C:\Documents and Settings\


\$1. Menu\
Programs\
C:\Documents and Settings\

I
C:\
1024

768

C:\Documents and Settings\

C:\Documents and Settings\


\' Documents\Visual Studio
Projects\ Setupl\Debug\
,
C:\Documents and Settings\
Start.
natb3oeamejib\Sl3.n Menu\
, C:\Documents and Settings\
, .1\$ Menu\
.
Programs\Startup\
Windows.
C:\Windows\System32\
(LC1D) , 1033
,
C:\Program Files\Default
.
Company Name\ Setupl\
,
G\ Documents and Settings\
.1\
Local Settings\Temp\
, C:\Documents and Settings\
,
New
.

13

339

. 13-1. ()

Time
UserlanguagelD
USERNA
VersionNT
VirtualMemory
WindowsBuild
WindowsPolder
WindowsVolume

.msi
::.
(LCID),
.
,
.msi.
,
32- NT.
( ),
.
.
, .
, Windows.

17:54:35

craigs
1
576

2600
C:\Windows\
:\

Registry, File System. ,


, .!,
. , .
, . AppDataFolder : Documents andSettings\u$ei;nzme\4pplication Data\. , ,
. ProductName , . , C:\Documents and Settings\username\Application Data\ProductName,
D ,
. AppDataFolder
ProductName DefaultLocation
Properties [AppDataFolder][ProductName]. C:\Documents and Settings\username\Application Data\Setupl ( Setu.pl).

File Types
, Windows, , , , . MS-DOS,
, , ,
Windows , , ,
Windows Explorer, ,
. -

340

HI ,

, / . , Registry, .
File Types Visual Studio .NET
.
, , , . .NET MylmageViewer ,
. ,
, ,
File | Open, (
.myimage) File ) Print.
Windows , .

(.bmp), .myimage.
.myimage , File Types, Solution
Explorer View | File Types. File
Types On Target Machine Add File Type.
Open. , ; ( File Types ) ,
Windows Explorer. , Print Edit. .
Print, , Add Action &Print.
,
.myimage Windows Explorer . ,
. &Print
Properties Arguments Print. -print %1\
-print , ,
. Windows Explorer %1 ,
. .
. ,
, , ,
. Properties Print Verb.
, , Edit Print.
,
. , File Types On Target Machine, Properties.

13

341

Command , ;
, File System, . ,
, , , Extensions. mylmage;
.
, , Windows Explorer, File System
Icon.
,
. Windows Forms Forml,
Forml :
public Form1(string []args)
<

InitializeComponent();
if(args.Length == 1)
I
pictureBoxl.Image = System.Drawing.Bitmap.FromFile(args[0]);
this.Text = this.Text + " - " +
System. 10. Path. GetFileNaine(args[0]};

else if (args.Length == 2}
!

// :
String printCommand = "-print";
string editCommand = "-edit";
if(System.String.Compare(printCommand, args[0], true) == 0)
{
II .
// PrintDocument:
pictureBoxl.Image = System.Drawing.Bitmap.FromFile(args[1] );
PrintDocument printDocument = new PrlntDocumentO;
printDocument.PrintPage += new
PrintPageEventHandler(printDocument_PrintPage);
printDocument.Print();
System.Diagnostics.Process.GetCurrentProcess().Kill();

I
else if(System.String.Compare(editCommand, args[0], true) == 0
{

// .
// MSPaint:
System.Diagnostics.Process.Start("mspaint.exe", "\""
+ args[1] + "\"">;
System.Diagnostics,Process.GetCurrentProcess().Kill();

342

III ,

Main :
static void Main(string []args)
{

Application.Run(new Forml(args));

I
Edit Print, -editfilename -print filename. , -print -edit, :
mspaint.exe ,
, .
, , . MylmageViewer .myimage ,
.

User Interface
.msi,
. ,
, , , . , , Visual Studio .NET, , .
, Properties: BannerText BannerBitmap.
, ,
. ,
;
496x68 , File System.
, , ,
BannerText, , , .
User Interface : Install Administrative Install.
Install. , ;
. Administrative Install .
.msi ~, , msiexec.exe -a mstfile.msi, ,
.msi, ,
. Administrative Install
, Install. Administrative Install User Interface ;
Windows Installer .

13

343


(. 13-2) , .
JPG, 480x320 . , , File System,
Splash User Interface SplashBitmap Properties, , File System.

. 13-2. ,
Inside Microsoft Visual Studio


RadioButtons (2 Buttons), RadioButtons (3 Buttons),
RadioButtons (4 Buttons), Checkboxes (A), Checkboxes () Checkboxes () . RadioButtons 2, 3 4 ,
; Checkboxes 0 4
(. 13-3).
Properties
. (/ , / ), . , Properties
RadioButtons CheckBoxXPropert v (
X 1 4) Checkboxes.
, , Registry,
, , , . 13-1-

344

III ,

BannerText

QChecWxwt

. 13-3- Checkboxes
RadioButtons
(. 13-4) Registry , . ,
; ButtonXValue ,
. , RadioButtons (2
Buttons) , ButtonlValue Button2Value,
1 2 . ,
, BUTTON2. , Registry [BUTTONS] ,
. (Button 1}, ,
, 1-, (Bu(,fon2) 2.

BannerText

Q8utton3
G-Bulton*

. 13-4- RadioButtons (4 Buttons)

13

345

,
, Registry File System.


Textboxes (A), Textboxes (), and Textboxes () (. 13-5). .
, , , ,
User Interface, Properties
EdifXVisible ( X ) False.
, Properties EditXProperty.
, , Registry , . , EditI Properly
Textboxes () EDITA1, ,
[EDITA1], , .

Edi!3:

. 13-5. TextBoxes

Customer Information
Customer Information :
, () ,
, SerialNumberTemplate
Properties. SerialNitmberTemplate
Customer Information.

346

III

]), , , , .
.
#, %, ?, -. # %
, ? - ,

. ,
.
, ,
%, 7. (
.) 0,
, , ,
. . 13-6
<###-%%%%%%%>; ,
4, 5, 6, 7, 8, 9 9 48 7.
, ProductlD.

Customer Information

Entajiouf ftaffleandcorapanjJM Mgantzabon the box below. The-imtal!aFUflllij$e this inlormatiort


lor subsequent installation;

JM tc I o soil Ress

Enter jraat serial number beknv The installer will use Iliis tnlaimalior for subsequent

. 13-6.

Customer Information

License Agreement Read Me


, , .
, . .

License Agreement; , , (. 13-7). I Do Not Agree option, Next
. 1 Agree -

13

347

; , .
, License Agreement, RTF Microsoft Word WordPad. RTF-
License Agreement File System.
License Agreement User Interface,
, Properties LicenseFile RTF.

License Agreement

Please take a moment to read the fcertse agwemenE fw .If you accept Ihe terns below, okk '1
1
Agiee",then"Ne>rt" Qiheiwise click "Cancel .

[[This is some license text. Because the text displayed here is in RTF format,
[you can use different formatting options, such as

Bulleted lists
Bold or Italics
coicr (this is red, although you will not to see the color since
Shis screen capture i? in black in whiie)
mdeven different fonts

2o NotAgrae

. 13-7- License Agreement


Read Me , License Agreement, I Do Not Agree I Agree.
Read Me, License Agreement, RTF ,
.
Register User
, ,

. Register User (. 13-8). ,
, ,
; ,
, File
System.
Register Now,
File System. User Interface
Register User Visual Studio .NET Properties Executable.

348

III

Register Setup

Please legster your copy ol PsgisterUsefSeluo


CBek 'flegistet Now" to art the process, or dk*. "Menf' if you do not want to register
new.

i Now.

. 13-8.

Register User

* Windows Application Wizard . . , RegisterUser,


. , ProductRegistration, Web- .NET, Web. RegisterUser
Register Online, HTTP
Web- ProductRegistration. Web- RegisterUser
, .
RegisterUser ProductRegistration,
ProductRegistration Web-
RegisterUser . ProductRegistration
ProductRegistration.aspx TODO
. ,
, , . , .
Forml.cs RegisterUser ,
Web- ProductRegistration. localhost , , Web ProductRegistration,


Windows Installer ,
, , , - .

13

349

. 7
, Visual
Studio .NET, , .
: .NET, Win32. CustomActions, .
Custom Actions,
, ,
File System, Custom Actions .
: Install, Commit, Rollback Uninstall.
, ,
. Install
.msi. ,
Rollback.
,
, Install. ,
Commit,
.
Uninstall, , .

.NET
, .NET Framework , Windows Forms
, .NET, .NET. ,
.
,
, Windows Forms.
Windows Forms ,
File System, Custom Actions , .
, ,
,
. Windows Forms
. Windows Forms , , ,
,msi, .
Windows Forms , , ,
,
* .

350

III ,

.
Windows Forms
. ,
, , .
. , , : ? , , , . , Windows Forms
, .NET Framework,
Custom Actions InstallerClass Properties True False.
False, Windows Installer ,
, True , .NET
.NET
.NET , . , , . ,
,
.NET, Solution Explorer, Add | Add New Item Installer Class.
, System.Con[igumtionJnstallJnstaller Runlnstatter. .msi
, , ; Runlnstaller, . System.ConfigurationJnstalUnstatter , : Commit,
Install Rollback Uninstall. Class View.


, VBScript JScript, File System Custom Actions,
, ActiveX Scripting.
,
Session Session,
.msi. 13-1 VBScript, a 13-2

13

351

JScript. .
13-1. VBScript
VBScriptCustomAction.vbs
' Session
' NSI. HSDN
' !BS-help://HS,^CC,2003/HS.M8DNQTR.2003f=EB.1033/Bisl/vref_8xis,tltm
.
tisgboxCVSScrlpt Custom Action"),

13-2.

JScript

JScriptCustomActlon.js
// Session
// HSI. HSDN
// iiis-heIp;//MS.VSCC.2003/HS.HSIfflQTR.2003FSB.1033/ffiSi/vref_8xis.htai
// .
var wshShell = new ActiveXQDject("ld$cript.Shell"};

wshSnell.PopupC'JScript Custom Action"};


. -,
, VBScript JScript.
.NET, .
.
, . , ( Notepad),
, Windows Explorer.

Win32
.NET .NET Framework, , Win32. , Windows API
. Visual
C++ Win32.
Win32, Visual C++ Win32-DLL , __stdcall.
unsigned int, .
, ERROR_SUCCESS, Windows Installer , , . MSIHANDLE,

352

III ,

.
Windows Installer, DLL , Custom Actions EntryPoint
Properties. 13-3, Install Entry-Point,
, .
13-3. Win32
Win32CustomAction.cpp
slnclude
Sinclude
include
include

"stdafx.h"
<tctiar.h>
<msi.h>
<Msiquery.h>

BOOL APIENTRY GllHain (HANDLE tiModUe, DWOfiD ul_reason_fr_call,


LPVPXO IpReserved)
{

return TRUE;

declspecCdll export) unsigned int stdcall Install (MSIKAMHJE nlnstal 1)


{
essage$ox<WILL, "CustomActlon" , "VC++", RBJIK};
return ERRGR_SUCCESS;
\

'-

'-

'

:- - :

..-.

:
, .rnsi,
-to . .msi - , , . ,msi ,
, , ,
. . : , ,
, .msi. , ;, . , , . ?
.
.NET, , Processes

13

353

, msiexec.exe,
.
.NET. , .NET Framework .
.NET Windows
Forms .NET, 'X
Processes ,
msiexecexe. * ie
Win32, Processes msiexec.exe. .
Title , OKI ia
. ; ,
.
,
.msi

Launch Conditions
. , Windows XP, , .
Visual Studio .NET. , , .msi
.
, Launch Conditions.
Launch Conditions, Launch Conditions
Add Launch Condition. Properties Condition
, true,
.msi . true, ,
Message. InstallURL false, Web-, . Windows Installer
, .

, Visual Basic
.NET . , ,
. 13-1 ,
User Interface. , ,

354

III ,

,
.
. 13-2 , . ( )
, .
. 13-2.

Not
And
Or
Xor
Eqv
Imp

.
True, True, False.
True, True.
True, True,
. True,
True False.
. True, False
True.
. True, ; False.
True, .
True, , .
True, , , .
True, , .
True, , , .
And. True, .
. True, .
. True, 1 .
. True,
.
. True, 16 ,
. True,
.

Condition.
Not Privileged
.

True, -

(VersionNT = 501) And (ServicePackLevel = 1) True, .msi Windows ( 501) Service Pack 1.
(VersionNT = 500) Or (VersionNT = 501) True, .msi Windows 2000 ( 500) Windows XP ( 501).
(ScreenX >= 800) And (ScreenY >= 600)
True, 800x600 .
Physical/Memory > 128
,

True, 128

13

355

PhysicatMemory >= 128 True, 128 .


Hello World X Hello True, .
Hello World Hello True, , , , .
Hello World World True, , , .
Intel > 4 True, Intel Pentium
. ,
Pentium ( ).
Intel = 5 True, Intel Pentium.
, 5 , ,
, .
BUTTON2 = 1 True, User Interface RadioButtons (2 Buttons)
.


Registry, Launch
Conditions, User Interface File System. , Windows Installer, ,
. Launch Conditions
, ,
. , Search Target Machine Launch Conditions File Search Registry Search.
File Search , .
, .
, File Search, ,
( Properties Folder Filename
). ,
, Depth
, .
, dre.olb.
Visual Studio .NET.
Visual Studio .NET Program Files,
FolderName File Search fProgramFilesFolder], File
dte.olb Depth 20 ( , , ). ,
, FILEEXISTS1 ( - ),
F1LEEXISTS1 File System,
Registry , dte.olb .

356

III ,

Registry Search
File Search , ,
,
. , ,
Visual Studio .NET 2003- Registry
Search. Registry Search,
Search Target Machine, Add Registry' Search . Properties RegKey Visual Studio
.NET (SOFTWARE\Microsoft\VisualStudio\7.1), Value IiistallDir. InstallDir , Visual
Studio .NET. ,
Property. ,
. ( REGISTKWALUEl.) , Launch
Conditions Launch Conditions Add Launch Condition.
Properties, REGISTRYVALUE1 "" Condition, a
Message InstallURL.
.msi , REGISTKWALUE1
, Visual Studio .NET.
, True,
, , Message.
PublioAssemblies
, , , , . Macros .
C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\roE\PublicAsserriblies, ,
Visual Studio .NET.
Registry Searcb, , Visual
Studio .NET, ,
.
, File System,
File System On Target Machine
. Add Special Folder (Custom Folder. Properties Registry
' Search, ( {REGISTKYVftLLiEtJ),
\PublicAssemblies DefaultLocation.
. .msi , ,

13

357

File System, Registry, Custom Actions File Types, Properties Condition. ,


, . Condition , . ,
. , Add-in Wizard
User Interface .
User Interface RadioButtons (2 Buttons),
Properties ButtonlLabel Yes, install source code, a
Button2Label No, do not install source code. :
BUTTON2, . 1 2.
File System ,
Application Folder, Add | Folder
. ,
. ,
, Add | Project Output, Source Files. , , .msi, ,
,
RadioButtons (2 Buttons).
,
File System Properties
BUTTON2 = 1 Condition. .msi, , . ( 2') BUTTON2 = 1
False, . , .
BUTTON2 = 1 ,
, . SourceFilesAddin,
,


Windows- ,
, DLL. DLL .msi,
. ,
.NET, < >
; -

358

III

. ? , , .msi. , , , , , . ,
, ,
.msi,
.

,
( .msm). : DLL .
DLL , ; ,
.msi. , User Interface Launch Conditions.
, File System Web Custom Folder Module Retargetable Folder.
, , ,
, .
,
Solution Explorer ModuleRetargetableFolder Properties. ; Solution Explorer, Project | Add | Merge Module.

.NET
, Visual
Studio .NET. .NET,
,
.msi. , .
, , .msi , .
, (. 13-9).
? Visual Studio .NET
, .NET Framework, !
# Visual Basic .NET File System, Visual Studio .NET Launch
Conditions , , .NET Framework .
.NET Framework , , .
.msi, ,
.NET Framework, . ,
.

13

359

Yes (. 13-9) ,NET Framework,


,
, .NET Framework,

, NET FVdmewotfcversiwi l,i. 4322. Please Instil the .NET


Framework and run ths setup age"1' The . NET ftarevrark can be obtained From the
web. Waulti you Bks to do tHs now?

. 13-9- ,
JVET , NET Framework
, CD, . ,NET
Framework CD ,
.NET Framework, .msi. )~
,
. , ,NET
Framework, .msi.
, .msi.
Setup.exe, . , Windows Installer, .NET Framework. .NET Framework, , .NET Framework .msi, . Properties
.
.NET , dotnetfxredist_x86.msm , . , ( ), .NET Framework, ,
, .NET Framework ( System.XML,
System.Web . .), , .NET Framework. CLR, ,
, ,
, ,
.NET.
.NET Framework , Bootstrapper . Bootstrapper,
Visual C++, . ,
, ,

360

III ,

, . , , ; , ,
,
. , .
Setup.ini, ,
. , , , .NET
Framework. Setup.ini:
[Setup]
InstallNaine=Setup
FrameworkVersionRequired=v1.1
UseLocaleForFindingRedist=1
FrameworkRedlstName=DotNetfx
FrameworkInstallPath=FrameworkRedist
MSIFilePath=Setup.msi

INI ; - , , . .
InstattName . ,
Setup. .
FrameworkVersionRequired .NET Framework, . ,
, .NET Framework . vl.
( ;, ) vl.l. vl.O .NET Framework, Visual
Studio .NET 2002, a vl.l .NET Framework, Visual
Studio .NET 2003 FrameworkRedistName ( .), .NET Framework. DotNetfx.
.
UseLocaleForFindingRedist 1,
CD .NET Framework.
.NET Framework , , , , , ,
, .
,
. 0, .
, -

13

361

.NET Framework, , 0.
FrameworkfnstaUPatb
.NET Framework. , D:\MyProgramSetup FrameworklnstallPath , FrameworkRedist.
.NET Framework
D:\MyProgramSetup\ FrameworkRedist\DotNetfx.exe.
UseLocaleForFindingRedist 1, FrameworklnstallPatb
FrameworkRedistName .
. . 13-3; ,
D:\MyProgramSetup\FrarneworkRedist\9\DotNetfx.exe.

,
. , , .
MSIFilePatb .msi.
D:\MyProgramSetup, Selup.msi, D:\MyProgramSetup\Setup.msi.
. 13-3.


9
12
/6
/7
10

1228. 2052.
18

, .NET Framework , , .NET Framework, .


-
CD.
CD 50 .
CD, Visual
Studio .NET, . CD ;!

362

III ,

.msi, , .msi
.
.NET Framework CD Web, Microsoft,
.NET Framework (EULA) Microsoft .NET Framework SDK.
Windows - CD AutoPlay, CD
, Windows CD ,
autorun.inf, , .
autoruainf, CD
CD
:
[autorun]
open=setup.exe
icon=setup.lco

label=My Setup
shell\launch\conunand=Setup.exe
shell\launch=4Install this program

.
open ( ), CD . .NET Framework ,
;
.msi.
icon (
), Windows Explorer CD.
DLL, , .
label , CD Windows
Explorer.
sbelt\verbnnme CD Windows Explorer, , . verbname - . , , , . ,
.
sbelF\verbname\command CD Windows Explorer ,
5#e/^verbname, , .
verbname , ,
. autoruainf

13

363

( ) $jbe#\verbname, CD, .
autorun.inf ,
CD; , .NET Web- Microsoft. 20 , ( , ) , . 13- CD ,
. ( .NET Framework)
SetupCD. CD, .msi CD.
!
: FramewortiRedist

S 10
fjldotnetfx.exe
12
dotnetfx.exe
! 122B
Ijl dotnetfx.exe
:_^J 1^
IP dotnetfx.exe
5 17
^ dotnetfx.exe

FrameworkRedst
I dotnetfx.exe
s autorun.inf
3 5etup.exe
") Setup, ico
2J| Setup,mi
jiJ Setup,msi

is
-gp dotnetfx.exe
_) ^052
^ dotnetfx.exe
Hjp dotnetfx.exe
29
^1 dotnetfx.exe
r
|1 --JotnetFx.eote

. 13-. CD
NET Framework ()
()

, :
.msu Visual Studio .NET,
. .msi
, , , Registry, Web- . . InsideVSNecSetup. , .msi Inside Visual Studio .NET
2005 samples, . Readrnelitm InsideVSNetSemp.

364

III


. Visual Studio .NET MSDN. , .

14

Visual Studio .NET

JVlSDN Library, Microsoft Visual Studio .NET, , (IDE). ,


, . , Visual Studio
.NET .
. -
, ,
.
Table of Contents, Search Index Visual Studio .NET, .

Visual Studio .NET (Help collections) Visual Studio .NET.


Visual Studio .NET . -,
, MSDN Library,
1,5 . ,
, ,
.
Visual Studio .NET
MSDN, .

III ,

366

, MSDN Library Microsoft. ( MSDN, MSDN Library


Visual Studio .NET 2003 .)
,
Options. Visual Studio .NET 2003
Visual Studio .NET 2003 Combined Help Collection. ,
.
. 14-1 Help Environment
Options. : , (preferred language).
, .

j-^i environment
General
Documents
Dynamic Help
Fonts and Colors

. 1
International Setting:Keyboard
Projects dnd Solution
Task List
Web Browser

Settings

{English
Prefer red eofettlcn;
jvisualStudio .NET 2003 Combined Help Collection

?' Internal help

5ource Control
Text Editor

ftnalyzer
Database Tools
i|U Debugging
Device Tools

. 14-1- Options

(internally)
(externally) . IDE,
IDE. : , IDE .


, ,
. Contents . Index , . Search .
Search Results. -

14

Visual Studio .NET

367

500 ,
, . . 14-2
Microsoft Document Explorer . , Microsoft Visual Studio .NET 2003 Documentation
Microsoft Visual Studio .NET 2003 .
Visual Smdto Nil WifuiT.hiix-ii ,-,He(tin

Visual Studio .Hit Lembined Help toifeclion

loot

tfedbv

The Visual Studio .NET Combined Help


Collection

.
*) Vnual Sfudaj .HE'
:*,MSDN Library
= ^3 vKual studio .N1 i-*gr<

already installed, <

I:

'

. 14-2. Visual Studio NET 2003


Document Explorer
Document Explorer . Visual Studio MSDN .
.


Filtered By Search (. 14-3) Look For. ,
CString Visual Studio Macros*,
DataSet Class .NET Framework,
Visual C++ CString Operation
Relating To C-Style Strings Visual C++ Concepts. , .
, .
Search In Titles Only , .
. Match Related Words . , link*
Match Related Words linked*, linking linker. Search In Previous Results ,
.

370

III

wntion: .MET Cotnpset Framework


rt DevicesT Oft'TBcSai'W'NBKinipiittf *"

Working H|h Help Attributes


Let of i-dlaite Attributes *ic meir values
Language (DevLanq}
Locale (Locale)

. 14-4.
Edit Help Filters
COM/.NET, DocSet Technology:
("DocSet"="NETFramework" OR "DocSet" = "NETFrameworkExtender")
or("Technology"="COMt" OR "TechnolOQy"="NETt" )

.
, , ,
, .
List Of Available Attributes, .
, Calculate, , .
, ,

Command Window
, Vim,
Command Window.
Command Window HelpflHelp. , Fl (Fl keyword)
. F1, , Command Window
>help term, term . F1, , .
Visual Studio .NET.
Fl , , ,
; . , -

14 Visual Studio .NET

371

Find, >help Edit.Find Command Window.


,
, .
:

EditJZeplacelnFtles;
HelpJndex;
FileNewFile;
Debug.Start.
,
F1 , Dynamic Help,
HKCU\Software\Microsoft\VisualStudio\7,1\Dynamic Help
, Display Debug Output in Retail,
, s. . 14-5 Dynamic Help
. , , F1. Index.

Introducing VtsiMlifjJ .NET


Install. Hefc far 1
- Active Content
Keywords-priority: 900
(Fi Kd) Kfywnd-W.PropsrtWs
Keywcrite- priority. 600
[Fl KwdCS)koyword-5yam.Oa
* - priority. 9
- prlaty: 100

tm-ts
ktm-fnjta
product -C*
Prodjct-C*
Product -vs
Pio'^a-fxt

SotuBcn-Siriote
SourceControl-F
SubType-Form

. 14-5.

Dynamic Help

Dynamic Help
Dynamic Help , -,
Dynamic Help Options
(. 14-6). Dynamic Help ; , ,
. ,
Dynamic Help , , . , Samples Getting Started Help (. 14-7),

372

nvironment
General
Documents
Dynamic Help
Forts and Colors
Help
International Setting;
Keyboard
Project! and Solution
Task List
Web Browser
Ci) Source Control
Qa Text Editor
^il Analyzer
U3 Database Tools
iia Debuggng
,Sl Device Tools

Syntax

Show Inks for:

number of Inks pet category:

*" Selection only


f ftc^ve elements

Help

. 14-6.

Dynamic Help Options

Dyn.ii mt. Help

jt Window
Code and.TextEditor
Coding Techniques and Programming Practices
Getting Started
Creating and Accessing XML Web Services Wajht;
Installing Help f orVguai Studio
Customizing Oynamk: Hdo
feual Studio .NET
What's New in Visual, audio .MET
introducing Visual Studio .NET
Inside Visual Studio
Macro Information
Web Page

. 14-7.

Dynamic Help Samples

Dynamic Help
Dynamic Help XML Help Provider ,

XML Help Provider


, , HTML Microsoft Word,

, .
Dynamic Help, XML-
. Visual Studio
.NET 2003
. ,
. ,

14

Visual Studio .NET

373

XML- , C:\Program
Fiies\Microsoft Visual Studio .NET 2003\Comnion7\IDE\ HTML\XMLUnks\1033.
Visual Studio .NET Visual Studio 2002.
, : mon7\IDE\HTML\XMLLinks\1033. .xml.
Windows 1033 U.S. English.
Visual Studio .NET , ,
XML-, .
1033 XML- Context.xml,
, Visual Studio .NET.
, XML-,

XML.
Dynamic Help, :
<DynamicHelp xmlns="http://msdn.microsoft.com/vsdata/xsd/vsdh.xsd"
xmlns;xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:schefflaLocation="http://msdn.microsoft.com/vsdata/xsd/vsdh.xsd">

Dynamic Help.

. LINKGROUP.
InsideVSNET
(Inside Visual Studio NET. - ,
<LINKGROUP ID="InsideVSNET" Title="Inside Visual Studio .NET"
Prlority="300">
<GLYPH Collapsed="1" Expanded="2" />
</LINKGROUP>

Priority Dynamic Help. >


. 14-5.
GLYPH , ,
(collapsed) (expanded) . 14-3 .

374

III ,

. 14-3.

to

Qf
tf*

7
8

11

pj*'

12

Qp

13

14

gj*-

gf

Confexf
Context , Dynamic Help.

. , , Context.
Context Dynamic Help . Keywords Attributes KItem Altem , , . ,
, .
, .
. ,
, KItem VSAmbient, , VSSolutionExplorer*,
, Solution Explorer.
:
<Keywords>
<!- KItem ->

14 Visual Studio .NET

375

<KItem Name="VS. Ambient" />


</Keywords>
, , . Links Lltem-.
<LLnks>
<!- Lltem ->
<LItem URL="file: ///: \InsideVSNET\Info. htm"
LinkGroup="InsideVSNET">Macro InformatiorK/LItem>
<LItem URL="http: //www. microsoft.com/mspress/books/6425. asp"
LinkGroup="InsideVSNET">Web Page</LItem>
<LItem URL="http; //www. microsoft.com/mspress/support/"
LinkGroup="InsideVSNET">Support</LItem>
</Links>
Lltem . URL
, . LinkGroup
, .
: :,
Web- Web- Microsoft Press Support.
14-1 Inside VSNELxml, , .
1033.
14-1. Dynamic Help
InsideVSNET.xml

<?! version**"!. Q" encoding*" utf-S" ?>


<!- Dynamic Help ->
xsi:sch8malocation="http;//ffiSdn,fflicrosoft.eoai/vsdata/xsd/vadN.xsd">
<J~ ,
->
<LINKBRQUP lD="XnsideVSKET" titles-inside Visual Studio ."
Prior ity-"500">
<GtYPH CoUap8ed-"r Expanded"?" />
<Context>
<Keywords>
<! - KItem ->
<KItem NaiB6*"VS, Ambient" />
<Links>
<!- Lltem ->
B
<LIts m "file:///e:\InsdeVS8ET\lRfo.htB"
HPcSroupB"In3ldeVSNET">Macro Infornation</Lltem>
<ilteai URL~"htt^://www.Biicrosoft.coffl/Enspress/bool<s/6425,asp"
likeroup"InsideVSNET">Vfe& Pa0</LItem>
<LJteet UFtt="http;//iww.nicrosoft.eeBt/m8press/support/"
. . .

376

III

UnkGroup="IrvsideVSNFr>Si]ppQrt</LIteiB>
</Links>
</Context>
</811>
. 14-8 Visual Studio .NET Web-
Dynamic Help.

. 14-8.
Dynamic Help


. Visual Studio .NET Help Integration Kit (VSIK) 2003,
Visual Studio .NET 2003 MSDN.
Visual Studio
.NET 2003-
,
.
Visual Studio .NHT Help Integration Kit 2003
Visual Studio .NET New Project . Help Projects , .
. 14-9.
Help Integration Kit Visual Studio
.NET, , IDE.

14 Visual Studio .NET

i- :!

rojeci Types;

377

* LJ Visual J# Projects

-I +; %3 Visual C++ Projects


1

-2j 5etup and DecJoyment Projects

Convert 1.x
.chm Fie

1.-; Q3 Other Projects

Convert l,x
Project

Database Project?
Enterprise Template Projects

Visual Studio Analyzer Project;


; Het Projects
xterisbility Projects
Cr&etea
InadeVSNET
Location!

| ClDocuments and Set tings lBri3n\Desktop\INSIDE\chai

"reject will be created at C:\Documents and 5ett^slBri\Desl*3p\IN5JDE\Ltiapl4(O3de'(IrisidaVSNEt.


CK

*Mote

. 14-9.

Cancel

Visual Studio NET 2003

Microsoft Help 2.
Help 2 .
.?, ? , , .
(Help collection definition)
., (Help include) ,HxF, Visual Studio
.NET Help 2 .HWProj. . . 14-4 ,
.
. 14-4. , Microsoft Help 2

.HxS
.
.HxF
,
.
,
,

,html, .htm, .txt, and others

: . (
) .HxF ( ). ,
, Visual Studio .NET Property Pages (. 14-10),

III

378

InsideVSNET Property Pages


Compte
Genaial

Post.;ompile
Navigation
Appearance

ftecorrple

1 InsideVSNET
&ilecttonlD:

Version;
11

|T~

j.

CoBH^ght:
|2003 Microsoft Corp.

OK

Cancel

. 14-. Property Pages


, , Add New Item (. 14-11). .- () .- ().
Add New Hem - HelpProjectTesI
SafsjDtes:

SJ ip Workshop Projectiteres
-G3 HelpWoritihop Topic Items

? 1

Iwnpletes:

&

Attrbute
Definition

i*^il

3)

Keyword
Index

Samples
Definition

=r

An XML Rle used to define a table of contents f or a h elp colection


;

?1.<
Qpen

. 14-11.

Cancel

Help

Add New Item

. .,
Property Pages. Navigation, ()
(Index), (. 14-12). .
Add New Item .htm-
Intro.htm. .
. 14-13 .htm-,

14

Visual Studio .NET

379

Project Explorer. .
InsideYSNET Property Pages
Compile
Geneial

Pasteorapfe
Wavtgflfem

Launch

Aps

! rf Contents!
>Tr-,i-i U^T

op Word Fib:

Cancel

. 14-12.

Help

:In ths Help file youjll find out to i


and rtmovt tht macros and sdd-ms
ere alt d for the book In addition, you
tnks to the book1! Web page md

. 14-13. 7/ Studio NET



,
. . 14-14 . .
Global TOC.

380

lit ,

. 14-14.

Visual Studio NET

,
Web- .
Web- Icon
22 Web.
(Properties) . 45 , . , Default TOG Icons VSHIK.

. -, , . ,
Web-, Microsoft Internet Explorer ,
. , . .-.
, .
, Keyword . Keyword HomePage*.
.-:
<Keyword Term = "HomePage">
<Jump Url = "HomePage.htnT/>
</Keyword>

,
Keyword XML, . ,

14 Visual Studio .NET

381

. Indexl.HxK ( 14-2):
14-2.

Indexl.HxK
<?xal versian="1.0"?>
<!DOCTYPE Helplndex SYSTEM

"fns-help://hx/resourGes/HelplFidex.DTO">

<HelpIndex BTDVersien*"1,0"
<i - >
<Keywofd Teim = "Macros">
<Juiap Url "Macros. htnt"/>
</Keyword>
<Keyword Term = "Web Site">
<Jump Url = "http://www. microsoft. coffl/iBSpress/books/6425.asp"/>

<Keywertf Term - "About">

Url - "About. htffl"/>

<Keyword = "Add-Ins">
<Jurn(> Url ~AddIns,htV>
</Keyword>
<Keyword Term * "HotnePage">
ifrl = "HofflePage.litffl"/>

</HelpIndex>
, (. 14-15).
, Command Window
DebugStart F5. ,
.HxS-, Document Explorer (Dexplorer.exe),
, Launch Project Properties.


Dexplorer
. Windows Installer. , (merge module) Windows
SDK. Visual Studio NET Help Integration, Help 2 SDK.
HxReg.exe.

III ,

382

WM<ir-*sM( I - Home
Ffc

S*

w*

Ipclt

#s *4 -0 00 IA*

vordcm

" :*' ^

Hdp
s-help://:nsldeV5NET/IdeV5NET/Ho

f X ! Home I

Inside Visual
Studio .NET 2003
Mat it

nd Add-bis Informal! oil

this Help Be you'll find out how to install.


and remove the macios and add-ins
created for the book, fr addition, you'll findl
links to the book's Web page and
information regarding technical support

I X

. 14-15.

Document Explorer

,
HxReg.exe, (-), (-) (-/). , , Help 2
SDK PATH (C:\Program Files\Microsoft Help 2.0 SDK). , .HxS- Command Window. :
HxReg.exe - MS.InsideVSNET.1033 - InsideVSNET.HxC
-d "Inside Visual Studio .NET Help Sample"

:
HxReg.exe -n MS.InsideVSNET.1033 -i InsideVSNET
-s InsideVSNET.HxS -1 1033

; MS. .1033- : ()._.(&/).


, ,
, Target :
"C:\Progratn Flle$\Common Files\Hlcrosoft $hared\Help\dexplore.ex
/helpcol ms-help://MS. InsideVSNET. 1033

e"

Dynamic Help.
URL Utetn, .
Macro XML - :

14

Visual Studio .NET

383

<LItem URL="ms-help://MS.InsideVSNET.1033/InsideVSNET/Macros.htm"
LinkGroup="InsideVSNET">Macro Information</LItem>
Visual Studio .NET.
. , Web Dynamic Help.


Visual Studio .NET
Microsoft Visual SourceSafe.

15

Visual Studio .NET

11 Microsoft Visual
Studio .NET. 2,
IDE IDE .
, Microsoft Visual
SourceSafe (VSS).

Visual Studio .NET


Visual Studio .NET , make- NMake.exe.
Visual Studio .NET
, IDE. .
Visual Studio .NET Devenv.exe PATH
Command Prompt Visual Studio .NET 2003-
PATH, INCLUDE, UBPATH LIB IDE, Visual
Studio .NET ,
\useenv.


,
. -

15

Visual Studio .NET

385

, ,
PATH Devenv.exe, , . Devenv.exe, /foutid,
. debu^
release. (. 2), . (debug
build) :
devenv SCTestVCSI.sin /build debug

, (build log). /out . ,


(. 15-1).

UIIUinApii. Cnnl ir(in-,H :

-|.|

.N11

Skipped Build: Project: Setup. Configuration: Detiua

l:n i [.I

. 15-1.

> , ! . , ! . I . i I- '

I .hi|i

Type

/project.
:
devenv SCTestVCSI.sin /project JSConsoleApp /build debug

, . IDE , /projectconjtg. IDE , .


Devenv.exe , . -,
. ,
, . -,
, , .
, IDE.
/rebuild
. /clean Build.CleanSolution. Clean . Visual C++, Visual Studio .NET 2003 . Build,
, :

386

III ,

devenv SCTestVCSI.sln /clean debug /out clean.txt

, ( Clean ):
- Clean started: Project: CPPConsoleNet,
Configuration: Debug Win32 Deleting intermediate files and output files for project
'CPPConsoleNet', configuration 'Debug|Win32'.

Done
Clean: 1 succeeded, 0 failed, 0 skipped

, ,
/ run. IDE , DebugStart. , , .
,
IDE , .
/.
IDE .
IDE .
/runexit , ,
, .
, IDE, - :
devenv VBWinApp. sin /run
(deployment project),
/deploy.
. -,
. -,
, . , , Build . /deploy, Configuration Manager,
Configuration Manager Build. . 15-2 Release pe , IDE
/deploy-.
devenv VBWinApp. sin /deploy release
.

15 Visual Studio .NET

387

Configuration Manager
Active Solution Configuration:
JRelsase

*j

Project Cortex ts (cheek the protect configurations to build or deploy):


Project
Release
Release

. 15-2.

Setup Configuration Manager

/command IDE.
, IDE Code Model Add-in
12, :

devenv /command CMEAddln.Connect.CMEAddln


CMEAddln.Connect.CMEAddin ,
,
, ,
CMEAddln (, ), IDE,
Visual Studio .NET Command Window, Ctrl+Alt+A, :
alias erne CMEAddln.Connect.CMEAddln

Windows :
devenv /command erne
, , .
help command:
devenv /command "help command"
/command ,
.
,
, IDE.
/debugexe Visual Studio .NET
.
DebugStart. i
, .

,
, , Visual Studio .NET
.
Visual Studio .NET :

388

III

devenv /debugexe VBWinApp.exe

, Visual
Studio .NET, , .
, . Visual
# Visual C++, debug release
.
/useenv Visual C++. IDE
, , Devenv.exe.
. ,
Windows SDK
- DirectX. /useenv ,
IDE.
Devenv.exe (. 15-1):
. 15-1. Devenv.exe

/build <>
/clean <>

.
, , .
/command <>
,
Command Window IDE,
/debugexe <->
IDE,
/deploy
, , .
/out <_>
.
/project <>
,
/projectconfig

<_> .
/rebuild <>
, Clean, .
.
/run
IDE.
/runexit
IDE ,
.
/useenv
Visual C++ IDE ,
.



(GUI)
IDE . - -

15 Visual Studio .NET

389

,
GUI.
/mdi /mditabs (MDI) IDE. : IDE, /mdi
Devenv.exe /mditabs, IDE
.
,
IDE, : /fs , lDE,/fn .
, ; , IDE . /Jh
14 (. 15-3):

Clipboard Ring

'-; Start Page

General

Open an Existing Project

Ma Help
; Solution Explorer
I Managing Solutions. Proii
"" * J Samples
. Visual Studio Samples
! U Getting Started
.*.-'- Creatingjjgw Solutions a : Command Window

. 15-3. He : Devenv.exe /fn 14


/LCID IDE .
. , IDE, Visual Studio .NET .

. MSDN Universal Visual
Studio .NET.
GUI (. 15-2):
. 15-2. Devenv.exe GUI

/mditabs
/mdi

/fn <_>

IDE .
IDE MDI-.
IDE ,
. . .

390

III ,

. 15-2. ()

/fs
/migratesettings

'1 IDE .

Visual Studio .NET.
IDE .

/LCID <_>

VSIP
Microsoft Visual Studio Integration
Program (VSIP) VSIP. , (. 15-3):
. 15-3. Devenv.exe

/noVSIP
/safemode
/resetskippkgs

VSIP (VSIP license key) ,


,
, IDE .


Visual SourceSafe
Visual Studio .NET VSS, Visual Studio .NET
Enterprise Developer Enterprise Architect VSS-.
VSS-,

.

VSS
, VSS-
.

.


VSS Visual Studio .NET VSS, Visual Studio .NET. , VSS ,
Visual Studio .NET 2003 Visual Studio .NET ,
Source Control . VSS, Visual Studio .NET,
VSS. : VSS Netsetup.exe .

15

Visual Studio .NET

301

VSS VSS.
VSS .
VSS Microsoft Visual SourceSafe . Ctrl+p, !
Open SourceSafe Database (. 15-4). VSS srcsafe.ini.
Open SourceS.ife Database

ame:

btiano

W SpentfedatabaserftEima 1 runVisuatSoureeSele

. 15-4- Open SourceSafe Database




. . 14-5 VSS,
. VSS. Visual Studio .NET.
risuatSourceSafe Explorer

'' /* -> '.


WS

- Dap

. 15-5. VSS, VSS


, < i , IDE . Visual Studio .NET
File Source Control, Add Solution To Source Control
(. 15-6).

III ,

392

SOUTH
Control...

e Forinl vb faun Sour Cffifrol

Add Pro! From Some Contrd


Maosoft Visual Sources*!

. 15-6. VSS Source Control Visual Studio NET


Visual SourceSafe Login,
Add To SourceSafe Project (. 15-7),
.
ftdd to SourceSafe Project
Project

Chaptes
i ..!
Samples

. 15-7.

Add To SourceSafe Project

VSS-. , ,
(working copy), (checkout) VSS. . 15-8 Solution Explorer . Solution Explorer , , .
.

15 Visual Studio .NET

393

Solution t Htilofi-r VBWmApn

jjal References
Assernblylnfc.vb
Fotml.vb
Setup
..1| Detected Dependencies
Sjj} Primary output From VBWinApp (Active)

. 15-8.


,
Visual Studio .NET. , , VSS
. VSS, .
VSS-, File Source
Control Open From Source Control Command Window
File.OpenFromSourceControl. Visual
SourceSafe Login
VSS, . , Create local project from SourceSafe (. 15-9).
Create local project irom SourceSafe
Create a new project in (he folder

ChapCB
ChapIO
;

Diap12
Chap13
Chapl 4

. 15-9.

111 ,

394

. Browse Folder,
.
Create A New Project In The Folder. OK .
,
Open Solution .sin- . .sin- ,
.

. VSS
.
.
, , .
.
, ,
, , VSS
Visual
Studio .NET. , . Check Out For Edit (. 15-10),
, ,
.

.a-

jie!

g some UIAmanti to op air's men fo

. 15-. VSS
: Visual Studio .NET,
.
VSS Visual Studio .NET ,
VSS.
, .
.
, , .

15

s Visual Studio .NET

395

,
(. 15-).

jMp

. 15-11-

I ,*-

,
,

,
. , , , .
, , ,
,
, , , .
, .
, Solution Explorer
Check In. Check In
(. 15-12). .
.

Select items to check in:

Name

Change type I Mootfisd Tune

E3 j? ^J Items below solution 'CSWinApp'


|? |pl Files below pro|ect 'CSWinApp'
r-arn1! i .[

12/11/2002 11:22:36 PM

Comments:
I've added the second button per the new spec,

Check In
f

jsp!ay silent cfiecfc ii cfflnmsnrfih menus

. 15-12. VSS
.
, ?
, VSS
.
File.GetLatestVersion.
Solution Explorer.

III ,

396

, , . , , .
VSS, Visual Studio .NET. History (FileHistory).
Source Control File Command Window.
History' , ,
(. 15-13).
History- Details, ,
(. 15-14).

,;
12/12/0212 3\t
12/11/02112*

12/11/

Checked
Chocktd
Cieoted

. 15-13- VSS
HBIOI tails

Rfe

Version:

Dflte

12/12/02 1231 a

User:

Marc

n $/SamplesChap1 5/CSWirApp
Comnmt
I've added the second button per Hie new spec

. 15-14-

Pending Checkins
(. 15-15). ,
. Source Control
File Solution Explorer.
, .

15 Visual Studio .NET

397

, ' Option Pending Checking,


,
. ,
, .
Pending thertirt*
Name

Change type

$ 1 Items below solution 'C5WirApp'


1

p |p Rles below project 'CSWIrrtpp

p"|i^) Files below project 'CSClassLibrary'

. 15-15.

Pending Checkins

:
, - Web, > , , . ,
- , ,
Source
Control File Visual Studio .NET.
CSWinApp Chapter 15
. ,
, . ,
, .
Ctrl+Alt-f , Command Window, JFHe.ChangeSourceControl Change Source
Control:

, , .

398

III ,

,
Unbind , ' . , , . ,
Web. ,
. , , , .


VSS , ,
, . . ,
, , ,
, , .
, Visual Basic
.NET. , Visual C#, - Visual
C++. ( 2 .)
,
, .
,
.
, VSS
. ,
, , -
.
VSS Microsoft
,
, , Team
Development with Visual Studio .NET and Visual SourceSafe
MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
dnbda/html/ tdlg_rm.asp.

He
, . , . , , ,
.

. , VSS, , , -

15 Visual Studio .NET

399

. , , .

.
,
.
, VSS .


Visual Si.udio
.NET.
IDE. , ,
, .

12 Visual Studio .NET,


. , ,
.


.
*.

FileCodeModel CodeModel
FileCodeModel CodeModel , ;
, , . FileCodeModel (, -1):
. -1. FileCodeModel

CodeElements
DTE
Language
Parent

CodeElement , .
DTE.
GUID, .
Projectltem .

FileCodeModel
. FileCodeModel FileCodeModel -

401

Projectltem, ; FtieCodeModel, Parent 1>


Projectltem, FtieCodeModel,
, CodeElements,
.
Language GUID, . EnvDTE.CodeModelLanguageConstants GUID Visual Basic, Visual Cff Visual C++ ( GUID Visual J#: E6FDF8BF-F3D1-11D4-8576- 00025168).
, GUID , , GUID :
string LanguageFromGUID(string langGuid)
{

string language = String.Empty;


switch (langGuid.ToUpper())
{

case CodeModelLanguageConstants.vsCMLanguageCSharp:
language = "Visual Ctf";
break;
case CodeModelLanguageConstants,vsCMLanguageVB:
language = "Visual Basic";
break;
case "{E6FDF8BF-F3D1-11D4-8576-0002A516ECE8}":
language = "Visual Jff";
break;
case CodeModelLanguageConstants.vsCHLanguageVC:
language = "Visual C++";
break;

default:
language = "Other";
break;
I

return language;

! Visual
Studio .NET (, FileCodeModel
Solution Items). ,
.

14-1116

402

. -2 FileCodeModel. Addxxx
Remove ;
CodeElementFromPoint . CodeElement
12.
. -2. FileCodeModel

AddAttribule
AddClass
AddDelegate
AddEnum

.
.
.
.

AddFunction

Addlnterface
AddNamespace
AddStruct
AddVariable
CodeElementFromPoint

.
,
.
,
,
TextPoint.
.

Remove

CodeModel, ProjectCodeModel,
, FileCodeModel CodeModel
, , CodeElements ,
FileCodeModel.CocteElements.
CodeModel , . FileCodeModel, , . CodeModel (. -3).
. -3. CodeModel

CodeElements
DTE

IsCaseSensitive
Language
Parent

CodeElement , .
DTE.

, .
.
GUID, ,
Project,

CodeModel FileCodeModel, .
, , CodeModelLanguage
, (, , FileCodeModel}. IsCaseSensititte
CodeModel , , .

403

CodeModel . -4.
Addxxx Remove *.
. -4. CodeModel

AddAttribute

AddClass

AddDelegate

AddEnum

AddFunction

Addlnterface

AddNamespace
AddStruct

.
.

AddVariable
CodeTypeFromFullName

CreateCodeTypeRef
IsValidlD
Remove

CodeType,
.
CodeTypeRef,
.
,
.
.

CodeTypeFromFullName CodeType .
CreateCodeTypeRef CodeTypeRef vsCMTypeRef
(. -5).
, , IsValidlD , . .
. -5. vsCMTypeRef

VsCMTypeRejOtber

VsCMTypeRefCodeType
VsCMTypeRefArray

CodeType

VsCMTypeRejVoid

VsCMTypefteJPointer
VsCMTypeRejString
VsCMTypeRefObject
VsCMTypeReJByte
VsCMTypeRefChar
VsCMTypeRejShort
VsCMTypeReflnt
VsCMTypeReJLong
VsCMTypeRejFloat



. . .

404

. -5. vsCMTypeRef

VsCMTypeReJDouble
VsCMTypeRefDecimal
VsCMTypeReJBoot
VsCMTypeRejVariant

()

CodeElement
CodeElement
. , . CodeElement (. -6):
. -6. CodeElement

Children
Collection

CodeElement,
.
CodeElements.

DTE

DTE.

TextPoint,
.
Extender'
-.
ExtenderCATID
(ID) .
ExtenderNames -,
FullName

.
InfoLocation
vsCMInfoLocation, , .
IsCodeType
, CodeType.
Kind
vsCMElement.
.
Language
,
.
Name
.
Projectltem
Project/tern, .
StartPoint
TextPoint,
.
EndPoint

# ,
get . get.
CodeElement: Name, FullName Kind. Name,
,
. [ Visual Basic Name () .] , , , , ,
.

405

FullName . Kind
vsCMElement, , . vsCMElement
40 , , ( ,
, , ).
Children CodeElements,
, .
, . , Visual Studio .NET, Visual
C++ Children.
, , Visual
C++ . Visual Studio .NET

, Visual C++ . Visual C++ Visual
Studio .NET (, ), Visual Studio .NET , Visual C++.
, CodeElement.Children, Visual C++ , ,
vsCMElement.
InfoLocation ,
vsCMInfoLocation, , . .
-7 vsCMInfoLocation.
. -7. vsCMInfoLocation

vsCMInfoLocationProject
vsCMInfoLocationExternal
vsCMInfoLocationVirtual
vsCMInfoLocationNone

.
.
Visual Studio .NET 200 :>.

.

InfoLocation vsCMInfoLocationProject,
StartPoint EndPoint TextPoint, .
Extender, ExtenderCATID ExtenderNames
-, (- , , , IDE).
Language Projectltem FileCodeModelLanguage
FileCodeModelParent . Collection CodeElements. IsCodeType true, CodeElement CodeType ( . ).
CodeElement (. -8);

406

. -8. CodeElement

GetEndPoint
GetStartPoint

TextPoint,
.
TextPoint, .

GetStartPoint GetEndPoint TextPoint,


.
vsCMPart (. -9). GetStartPoint GetEndPoint ,
StartPoint EndPoint, CodeElementStartPoint CodeElementEndPoint CodeElement.GetStartPoint(vsCMPartWboleWithAttributes)
CodeElement.GetEndPoint(vsCMPartWholeWithAttributes) . GetStartPoint GetEndPoint,
Chapterl2\CodeDiscovery\TextFromStartAndEndPoints, vsCMPart .
. -9. vsCMPart

VsCMPortName
VsCMPartAttributes

VsCMPartHeader
VsCMPartWhole
VsCMPartBody
VsCMPartNavigate
vsCMPartAttributesWithDelimiter
vsCMPartBodyWitbDelimtier
vsCMPartHeaderWitbAttributes
vsCMPartWholeWtihAttributes

.

.
,

,
.
, ,
Class View.

.
.
.
.


,
. , CodeElement,
, . CodeEletnent,
, . , . -10: CodeEletnent,
, .

407

. -10. ,

Comment
DocComment
Parent

,
.

.
CodeEletnents.

DocComment XML
, (, # J#). , DocComment, XML-, <doc></doc>.
Comment (# J#, ,
Comment,
XML- <summary>~).
CodeNamespace
CodeNamespace .NET
(package J#, namespace # C++, Namespace Visual Basic).
CodeNamespace (. -11):
. -11. CodeNamespace

CodeElement

Members

. . -.
. . -10,
,
.

. -11. CodeNamespace Members,


, .
. -12 CodeNamespace,
.
. -12. CodeNamespace

CodeElement

. . -7

AddCloss

AddDelegate
AddEnum
Addlntetface
AddNamesp&ce
AddStruct
Remove

.

.
,
.
.

408

CodeType
CodeType , CodeElement.
, .NET Framework.
, (CodeClass, CodeStruct,
CodeDelegate, Codelnterface CodeEnum) CodeType.
CodeType (. -13) :
. -13. CodeType

CodeElement

Access
Attributes
Bases
DerivedTypes
IsDerivedFrom'
Members
Namespace

. . -6.
. . A-10.
.
.
.
.
,
.
,
.
CodeNamespace,
.

# ,
get . get.
Access vsCMAccess,
(public, private . .). ,
CodeType Access Visual C++ Visual
Basic. vsCMAccess (. -14):
. -14. vsCMAccess

vsCMAccessPubtic
vsCMAccessPrivate
vsCMAccessProject
vsCMAccessProtected
vsCMAccessProjectOrProtected
vsCMAccessDefault
vsCMAccessAssemblyOrJFamily
vsCMAccessWtibEvents

(public)
(private)

. - . . . , :
.
(protected)



WithEvents

Attributes CodeElement, CodeAttribute, ,


CodeType. Bases CodeElement,
CodeClass; CodeClass
CodeType.

409

IsDerivedFrom , ,
CodeType. Visual C++
, , # J# , Visual Basic .
DeriveaTypes CodeElement,
,
. .
Members CodeElement, , Codt Type.
, , Namespace .
. -15 CodeType, .
.
. -15. CodeType

CodeElement
AddAttribute
AddBase
RemoveBase
RemoveMember

. . -7,
.
.
,
.

CodeClass CodeStruct
CodeClass CodeStruct
. ,
C++ class,
, private.
CodeClass CodeStruct ;
, .
. -16. CodeClass CodeStruct

CodeElement
CodeType


Implementedlnterfaces
!&\bstract

. . -6.
. . -11.
. . -10.
,
,
.

Implementedlnter/aces CodeElements,
, . #, J# Visual Basic
; Visual C++ Bases, Implementedlnterfaces
.

41 0

IsAbstract , . ,
# J# .
. -17 CodeClass CodeStruct, .
.
. -17. CodeClass CodeStruct

CodvElement
CodeType
AddCloss
AddDelegate
AddEnum

. . -7.
. . -12.
.
,

.

.
.
,
.
.
,

AddFunction
Addlmplementedlnterfctce
AddProperty
AddStmct
AddVariable
Removelnterface
Code Interface

Codelnterface . .
-18 Codelnterface; , .
. -18. Codelnterface

CodeElement
CodeType

. . -6.
. . -11.
. . -10.

Codelnterface . -19- Addxxx


. .
. -19. Codelnterface

CodeElement
CodeType
AddFunction
AddProperty

. . -7.
. . -12,
,
.

411

CodeEnum
CodeEnum . . -20,
CodeEnum .
. -20. CodeEnum

CodeElement
CodeType

. . -6,
. . -11.
. . -10,

CodeEnum . -21, .
*.
. -21. CodeEnum

CodeElement

. . -7.

CodeType

. . -12.

AddMember

CodeDelegate
CodeDelegate .
CodeDelegate (. -22):
. -22. CodeDelegate

Codetilement
CodeType

BaseClass
Parameters
Prototype'

'

. . -6.
. . -11.
. . -10.
CodeClass,
.
CodeElements
.
,
CodeTypeRef,
.

# ,
get . get.

BaseClass CodeClass SystemDelegate. , Visual C++.


Parameters CodeElement,
. Visual C++ .
Prototype vsCMPrototype, ,
. vsCMPrototype (. -23)
; , , -

412

. , vsCMPrototypeFullname, vsCMPrototype, vsCMPrototypeParamNames usCMPrototypeParamTypes }'


. , Visual C++, .
. -23. vsCMPrototype

VsCMPrototypeFullname
VsCMPrototypeNoName
I'sCMPrototypeClassName
I'SCMPrototypeParamTypes
vsCMPrototypeParamNames
vsCMPrototypeParamDefauUValues
vsCMPrototypeUniqueSignature
VsCMPrototypeType
vsCMPrototypelnitExpression

.
.
.
.
.
.
, .
.
.

, , CodeTypeRef,
. , #, Jit Visual
Basic.
CodeDelegate . -24, .
*.
. -24. CodeDelegate

CodeElement
CodeType
AddParameter
RemovePararneter

. . -7.
. . -12,
.
.

Code Variable
CodeVariable . . -25 CodeVariable.
. -25. CodeVariable

CodeElement

Access
Attributes
InitExpression
IsConstant

. . -.
. . -10.

.
,
.
, .


. -25. CodeVariable

IsSbctred
Prototype'

413

()

,
.

CodeTypeRef,
.

" # ,
get . get.
Access CodeTypeAccess vsCMAccess (. -14). , # J#.
Attributes CodeElements,
CodeAttribute .
InitExpression . . , Visual Basic, . , InitExpression, , . ,
.
IsConstant , . ,
J# False. , Visual Basic, .
IsShared ,
( True)
(False). , # J#.
Prototype , .
, CodeDelegatePrototype-,
vsCMPrototype (. -23),
. InitExpression Prototype ' '('''-' ' 'vsCMProibtypelmtExprestiori).
.
CodeTypeRef,
. , Visual C++.
. -26 CodeVariable. .
.
. -26. CodeVariable

CodeElement
AddAttribute

. . -7.
.

414

CodeProperty
CodeProperty . , -27 CodeProperty. , J J# get__xxx setjxxx
CodeFunction. . -27 J#.
. -27. CodeProperty

CodeElement

Access
Attributes
Getter
Prototype
Setter

. . -.
. . -10,
.
.
CodeFunction, - (getter) .
.
CodeFunction, - (setter) .
CodeTypeRef,
.

Access /
(. -14). ,
, Visual Basic not implemented, a Visual C++
(public) readonly.
Attributes CodeElements,
CodeAttribute , .
Getter Setter /
. Getter Setter
CodeFunction,
. # Visual Basic .
, , CodeFunction, CodeFunction,
Prototype .
Prototype vsCMPrototype (.
-23) . , CodePropertyPrototype . Prototype
,
CodeTypeRef, . , . , Visual
C++ ,
.

415

. -28 CodeProperty, .
*.
. -28. CodeProperty

CodeElement
AddAttribiile

. . -7.
,

CodeAttribute
CodeAttribute , .NET
Framework. . -29
. -29. CodeAttribute

CodeElement

Value

. . -.
. . -10.
,

Value / . :.4
, J# ,
. Visual C++ .
. -30 CodeAllribute .
,
. -30. CodeAttribute

CodeElement
Delete

. . -7.
.

CodeFunction
CodeFunction . . -31
CodeFunction.
. -31. CodeFunction

CodeElement

Access
Attributes
CanOverride
FunctionKind
IsOverloaded

. . -.
. . -10.
.
.

.
vsCMFunction,
, .
, .
. . .

41 6

. -31. CodeFunction

IsShared
Mustlmpletnent
Overloads
Parameters
Prototype'

()

,
.
,
CodeEIements,
.
CodeElements,

.
CodeTypeKef,
.

' # ,
get . get.
Access (. -14). , , Visual
Basic, .
Attributes CodeElements,
CodeAttribute , .
CanOverride ,
. ,
Visual C++ True. J# ; J#
(final) .
FunctionKind vsCMFunction (. -32). .
. -32. vsCMFunction

vsCMPunctionOther
I'sCMFunctionConstructor
vsCMFunctionPropertyGet
vsCMFunctionPropertyLet
vsCMFunctionPropertySet
vsCMFunctionPutRef
vsCMFunctionPropertyAssign
vsCMFunctionSub
vsCMFunctionFunction
vsCMFunctionTopLevel
vsCMFunctionDestmctor
vsCMFunctionOperator
vsCMFunctionVirtual
vsCMFunctionPure
vsCMFunctionConstant
vsCMFunctionSbared
vsCMFunctionlnline

get-
fef-
5?-
pwf-

Sub

417

IsOverloaded , .
True, Overloads , . ,
Overloads J# , Visual C++ Visual Basic
.
IsShared , -
(True) (False). , Visual C++,
# ]#.
Mustlmplement , . . Visual +- , # J# .
Parameters ,
. ,
Prototype ,
vsCMPrototype (. 23) . .
CodeTypeRef, , . , Visual C++ .
. -33 CodeFunction, .
*.
. -33. CodeFunction

CodeElement
AddAttribute
AddParameter
Kemovef'arameter

. . -7,
.
.
.

CodeParameter
CodeParameter ,
. . -34 CodeParameter,
. -34. CodeParameter

CodeElement

Attributes

151116

. . -6.
. . -10.
,
CodeTypeRef,
.

418

Attributes CodeElements,
, .
#, J#, Visual Basic.
CodeTypeRef,
.
, Visual C++.
. -35 CodeParameter, .
*.
. -35. CodeParameter

CodeElement
AddAttribute

. . -7.
.

CodeTypeRef
CodeTypeRef , , , ,
. . -36 CodeTypeRef.
. -36 CodeTypeRef

AsFullName
AsString
CodeType
DTE

ElementType
Parent
Rank
TypeKind

.
.
CodeType, .
DTE.

,
CodeElement
.
.

AsFullName . , Visual C++


, AsString.
AsString ,
(, # AsString int System Jnt32.) , Visual Basic ,
, AsFullName.
CodeType CodeType, . #, J#
Visual Basic , Visual Basic vsCMElementOther.
CodeTypeRef , ElementType , Rank
. .
Co^feTy/Je^e/' CodeElement , Parent
CodeElement. .
TypeKind vsCMTypeRef (.. -5),
CodeTypeRef. .

419


.
, , :
- , .
: , , Addxxx,
, Remouexxx, .
,
.
, .
, , (.); Visual C++
, (::). , ,
, Addxxx, Visual
C++ ,
.


Addxxx . ,
.
, - , .
, . Visual C++
, , .
CodeModellsVa'idlD.
.
CodeTypeRef,
vsCMTypeRef, ,
. , . , /^',
SystemJnt32 SystemBoolean, C# int bool .
Position ,
. 0 , , 1 .
. , CodeElements -

420

, CodeElement, ( Visual Studio .NET


CodeElement Position).
Access . vsCMAccess (. -14). .
CodeModel
Visual Studio .NET Addxxx : Variantl
Variant2. CodeModel
CodeModel , Addxxx Location, , .
, Location
; , (, , ). , Location
(, myfile.cp Visual C-H-, myfile.cs # , .).
CodeModel.

yWd-
, : , , . .
Add Names
AddNamespace CodeModel, FtieCodeModel CodeNamespace :
CodeNamespace AddNamespacef
string Name,

object Position
);

,
CodeNamespace. CodeModel FileCodeModel .
. .
AddClass AddStruct
AddClass AddStruct CodeModel, FileCodeModel,
CodeNamespace, CodeClass CodeStruct :
CodeClass AddClass(
string Name,
object Position,
object Bases,
object Implementedlnterfaces,
vsCMAccess Access

421

CodeStruct AdtJStruct(
string Name,

object Position,

object Bases,
object Implementedlnterfaces,
vsCMAccess Access

):
Bases
CodeClass, ( Visual C++ ). , CLR
, , , . Visual
C++ Bases,
Implementedlnterfaces . Codelnterface, . Bases, Visual
C++ . Implementedlnterfaces Visual C++.
Add Interface
Addlnteif CodeModel, FileCodeModel CodeNamespace-.

Codelnterface Addlnterface(
string Name,
object Position,
object Bases,
vsCMAccess Access

);
Bases . Codelnterface
, .
, , Codelnterface'AddBase.
Add Delegate
AddDelegate CodeModel, FileCodeModel, CodeNamespace, CodeClass CodeStruct:
CodeDelegate AddDelegate(

string Name,
object Type,
object Position,
vsCMAccess Access

);
#.

422

Add Function
AddFunction CodeModel, FileCodeModel, CodeClass,
CodeStruct Codelnterface;
CodeFunction AddFunction(
string Name,

vsCMFunction Kind,
object Type,
object Position,

vsCHAccess Access,

);
Name , ( ,- ).
Kind
vsCMFunction (. -32). , ,
, - (getter constructor),
.
Add Property
AddProperty CodeClass, Codelnterface CodeStruct:
CodeProperty AddProperty(
string GetterName,
string PutterName,
object Type,
object Position,
vsCMAccess Access,
object Location
);
#. GetterName
PutterName . # , , , GetterName
PutterName . , PutterName null;
, GetterName null.
Location ,
; , Location CodeModel (. CodeModel). #
.
AddEnum
, AddEnum CodeModel, FileCodeModel, CodeNamespace,
CodeClass \\CodeStruct-.
CodeEnum AddEnum{
string Name,
object Position,
object Bases,

423

vsCHAccess Access

);
Bases CodeType
, . Bases .

AddVariable
AddVariable CodeModel, FileCodeModel, CodeClass
CodeStruct:
CodeVariable AddVariable(
string Name,
object Type,
object Position,
vsCHAccess Access

);

AddVariable , # J# , CodeModelAddVariable
FileCodeModelAddVariable
.
AddAttribute
AddAttribute CodeModel, FileCodeModel, CodeClass,
CodeDelegate, CodeEnum, CodeFunction, Codelnterface, CodeParameter, CodeProperty,
CodeStruct. CodeVariable CodeType ( ?):
CodeAttribute AddAttributef
string Name,
string Value,
object Position
);
# J# AddAttribute. Visual C++
CodeDelegate CodeProperty ,
. Codexxx, Visual C++, , CodeParameter AddAttribute.

//-
Xrfrf- , , ?- .
AddBase
AddBase CodeClass, CodeStruct, CodeDelegate, CodeInterface, CodeEnum CodeType:
CodeElement AddBase(
object Base,
object Position

424

Base ;
#- CodeEnum Base ( CodeEnumAddBase # ).
AddBase -; . -37
, ( )' , CodeDelegate AddBase ).
. -37. AddBase
****1*.

CodeCloss.AddBase
CodeClass
Codelnterface
CodeTypeRef
CodeType

CodeStruct AddBase
CodeClass
Codelnterface
CodeTypeRef
CodeType

Codelnterface. AddBase
CodeClass
Codelnterface
CodeTypeRef
CodeType

Visual C++

Visual C#

Visual J#

'1.1

CodeEnum.AddBase

CodeClass
Codelnterface
CodetypeRef
CodeType

Add Implemented Interface


Addlmplementedlnterface CodeClass CodeStruct:
Codelnterface Addlmplementedlnterface(
object Base,
object Position
Base Codelnterface
, , . J#.

425

Add Member
AddMember CodeEnum-,
CodeVariable AddMember(
string Name,
object Value,
object Position
);

. Name , Value
. Value ,
, ;
,
AddParameter
AddParameter CodeDelegate CodeFunction-.
CodeParameter AddParameter(
string Name,
object Type,
object Position
);

AddParameter
CreateArrayType
CreateArrayType CodeTypeRef.
CodeTypeRef CreateArrayType(
int Rank
);

CodeTypeRef,
. Rank , CodeTypeRef.
(, cdeModel
CodeModel, cdeClass CodeClass):
Dim cdeVariable As CodeVariable
Dim cdeTypeRef As CodeTypeRef
Dim cdeTypeRefArray As CodeTypeRef
1

.
cdeTypeRef = cdeModel.CreateCodeTypeRef(vsCMTypeRef.vsCMTypeRefInt)
1

.
cdeTypeRefArray = cdeTypeRef.CreateArrayTypeO
' : .
cdeVariable = cdeClass.AddVariableC'mylntArray", cdeTypeRefArray)
.

426


, .
Delete
Delete )" CodeAttribute-.
void DeleteO;
.

Remove
Remove CodeModel, FileCodeModel CodeNamespace:
void Remove(
object Element

);

Element CodeElement CodeType. # J# ;


Visual C++ ()
CodeParameter, Visual C++ .
# J# CodeVariable\ , , , , object:.

RemoveBase
RemoveBase CodeClass, CodeDeiegate, CodeEnum,
Codelnterface, CodeStruct CodeType:
void RemoveBase(
object Element

);

RemoveBase AddBase. Element CodeElement, ( #


CodeType). : RemoveBase System.Object, .
# CodeEnumRemoveBase , .
AddBase, # CodeEnumRemoveBase CodeType CodeTypeRe/, .
Remove! nterface
Removelnterface CodeClass CodeStruct:
void Removelnterface(
object Element
);

Element Codelnterface,
Implementedlnterfaces . J# ,

427

RemoveMember
RemoveMember CodeClass, CodeDelegate, CodeEnum,
Cadelnterface, CodeStruct CodeType-.
void RemoveMember(
object Element
Element CodeElement,
, . RemoveMember CodeDelegate, Members,
Remove Para meter
RemovePammeter CodeDelegate CodeFunctii>n\
void RemoveParameter(
object Element

Element CodeParameter. ,
. Cf J#.


.NET Framework 3
3
3, 4
349
.NET Framework SDK 17
Active Template Library CM. ATL
ActiveX 3, 249, 270, 279
Add New Item wizard . ,

add-in .
Add-in Manager 125, 128
Add-in Wizard . ,

API 4, 8, 19
ASP.NET 4, 32
ASP.NET Web Service Wizard . , Web- ASP.NET
ATL (Active Template Library) 3, 7
101
7

build .

2, 4
C# 187, 283
C# Class Library Wizard . ,
#
C++ 2, 4, 7, 10
CLR (common language runtime) 3,
4, 8, 284
CLS (Common Language Specification) 4
CME (Code Model Explorer) 319
COBOL 4
Code Editor . ,
Code Model Explorer CM. CME
code-behind . ,

Command Mode . ,
,
common language runtime . CLR
Common Language Specification
CM. CLS
common type system CM. CTS
Common User Accessibility CM. CUA
CRT 7
CTS (common type system) 4
CUA (Common User Accessibility)
71
CUA (Common User Accessibility) 51
Custom wizard . ,

Design Time Extensibility CM. DTE


Development Tools Extensibility
CM. DTE
DHTML

DirectX 3
DLL 4, 36, 100, 109, 130
142, 145
DTE (Design Time Extensibility) 132
DTE (Development Tools Extensibility) 19
FUID (for-the-most-part unique identifier) 125
GAC (global assembly cache) 190,
250
GUID 125, 148, 191, 216, 240, 268.
388
ID 148, 160
IDE 2, 5, 7, 8, 12, 16, 17, 35, 48, 49,
53, 70, 78, 81, 82, 84, 91, 92, 100,
101, 125, 138, 147, 212, 284, 365

IDL (Interface Definition Language)


7
Immediate Mode . ,
,
IntelliSense . ,
Interface Definition Language
. IDL
ISAPI 7
J
Java 3
L
LIBID

191

M
Macros IDE 10, 12, 78, 79, 82, 84,
91, 101, 109, 125
Margin Indicator . ,
,
MDI . ,
merge module . ,
MFC (Microsoft Foundation Classes)
2, 3,7
Microsoft CLR Debugger 110
Microsoft Foundation Classes
CM. MFC
Microsoft Interface Definition Language CM. MIDL
Microsoft Intermediate Language
CM. MSIL
Microsoft Visual C++ 6.0 78
Microsoft Windows Installer CM. MSI
MIDL (Microsoft Interface Definition
Language) 38
MSDN Library 365
MSI (Microsoft Windows Installer)
328
MSIL (Microsoft Intermediate Language, IL) 4, 8, 32

N
named command .

New Project wizard . ,


429

OptionsPageWizard . .
Options
outlining . ,
output type . ,
- (portable executable) 4
project .
Property Page .
references node . ,

SDK 147, 153


shim control .
solution .
splitter bar , ,
STL (Standard Template Library) 7

Text Editor . ,
Tlblmp (Type Library Importer) 132
U
UI- . ,

V

VBScript (Visual Basic Scripting


Edition) 78
Visual Basic 3, 4, 12, 283
Visual Basic .NET 4, 23; 78
Visual Basic 6 10
Visual Basic Scripting Edition
CM. VBScript
Visual .NET 7
Visual C# 4, 5, 8, 23, 87
Visual C++ 2, 3, 4, 5, 12, 87, 270
Visual C++ .NET 5, 7, 23
Visual C++ 6 10
Visual InterDev 3, 10
Visual J# 23
Visual J# .NET 4
Visual J++ 3

430

Visual SourceSafe . VSS


Visual Studio 3
Visual Studio .NET 2, 147
-IDE 8
7
52, 54, 71
12
12
-Web Forms 12
- Windows Forms 12
- XML 12
12
10
214 .
310
6

18
9
16
12
18
65, 365
68
11, 369
160
9
4
Visual Studio 6 3
VSIP (Visual Studio Integration Program) 9, 19, 21, 40, 390
VSS (Visual SourceSafe) 390
W
Web 3
Web Forms 12, 13, 14, 23
Web Services Description Language
CM. WSDL
Web- 229
Web- 191
wildcards .
Win32 3, 147, 153, 351
Windows Forms 12, 13, 14, 23, 229
Windows- 4, 23
WSDL (Web Services Description Language) 191
WYSIWYG (What You See Is What
You Get) 12

XML 2, 7, 229
12
XSD (XML Schema Definition) 12


51

53

. GUID
. GAC
72, 73

114
8, 48
264

14


. LIBID
. ID
15, 48. 69,
70, 71

AboutBoxDetails 144
AboutBoxlcon 144
CommandLineSafe 140, 141
CommandPreload \ 38
Description 144
FriendlyName 144
LoadBehavior 140
PreloadAddinState 138
SatelliteDLLName 142
- SatelliteDLLPath
142

. IDE

BuildEvents 114

CodeAttribute 314
-CodeClass 314
CodeDelegate 314
~ CodeEnum 314
CodeFunction 314
~ Codelnterface 314
- CodeModelEvents
119
CodeNamespace 314
CodeParameter 314
CodeProperty 314
-CodeStruct 314
CodeType 316
CodeVariable 314
CSharpBuildManagerEvents 119
CSharpProjectltemsEvents 119
CSharpProjectsEvents 119
CSbarpReferencesEvents 119
-DTEEvents 111
-EnvDTEDTE
131
- EnvDTEEvents
112
- EnvDTEJDTWizard
215
- EnvDTEProject
189
~ ExtensibiUtyJDTExtensibility2
121
IDesignerHost 264
IDispatch 280
- IDTCommandTarget 102, 107,
153, 154, 155
- IDTExtensibility2 20, 102, 121,
122, 126, 127, 130, 153, 183
- IDTToolsOptionsPage
280
-IDTWizard 215, 227, 231, 233
InsideVSNetWizardLibraryJWizardPage 232
lOleCommandTarget 153
-ITDWizard 20
- IWizardPage
236
Projectltems 187
VBBuildManagerEvents 119
VBImportsEvents 119
VBProjectttemsEvents I \ 9
VBProjectsEvents 119
VBReferencesEvents 119
VCProjectEngineEventsObject 119
- VSLangProj.VSProject
189
-VSUserControlHostLibJVSUserControlHostCtl 270
-32>>> 242
51
13, 238

COMException 133

431

SystemRuntimeRemotingRemotingException 264
14

121

Connect 102
CString 7
- EnvDTE.Constants
240
- EnvDTE.TaskListEvents
258
GuidAttribute 125
InsideVSNetWizardLibraryWizardLibrary 231
Installer 166
System.WindowsFormsJFomn
264
- WinWrapper
243
-WizardLibrary 233, 236
51
13

For Each 148
foreacb 148
-& 283
-TypeOfJs
283

66
322
59
310
5, 7, 8
48, 62
5
48, 49
50
50
50
50
48, 64
- 50
8
32
48, 56
147
- GUID
149
- ID 149
161
150
157
151
158

432

151
- 149, 155
169
147
153
153

155

168

156

148

156
154, 155
15
5
34, 35
39

EnvDTE.Constants.vsProjectKindUnmodeled 198
EnvDTE.Constants.usWizardAddltem 216
EnvDTE Constants.vsWizardNewProject 216
ext_cm_AfterStartup 13 2
ext_cm_CommandLine 132
ext_cm_Extemal 132
ext_cm__Solution I32
ext_cm_$tartup 132
ext_cm_UISetup 132
ext_dm_HostShutdown 138
ext_dm_SolutionClosed 138
ext_dm_UISetupComplete 138
ext_dm_UserClosed 138
prjKindCSbarpProject
220
- prjKindVBProject 220
vsInsertFlagsCollapseToEnd 87
vslnsertFlagsCottapseToStart 87
vsInsertFlagsContainNewText 87
vslnsertFlagsInsertAtEnd 87
vsInsertFlagslnsertAtStart 87
~ vsMiscFilesProjectUniqueName
196
vsSolutionltemsProjectUniqueName 197
vsTasklcon.vsTasklconComment 254
vsTasklcon.vsTasklconCompile 254
vsTaskIcon.vsTaskIconShortcut 254
vsTasklconvsTasklconSquiggle 254
vsTasklcon.vsTasklconUser 254

vsWindowKindCommandWindow 241
vsWindowKindMacroExplorer 241
vsWindoivKindOutput 241
vsWindowKindServerExplorer 241
vsWmdowKindSolutionExplorer 241
vsWindowKindTaskList 241
vsWindowKindToolbox 241, 247
vsWindowKindWebBrowser 241
298
125, 140

16, 19, 39, 70, 78


79
85
81
- ToolsEdit 82
ToolsJLoadMacroProject 81
- ToolsMacrosIDE 81
- ToolsNewmacro 82
- ToolsNeivMacroProject
81
- ToolsJSeiomodule 82
79
11
85

95
81
85
82
169
91
94

94
94
259
264
20, 214
- Web- ASP.NET 230
# 230
235
231
# 224
235

214, 216, 227
- 219, 228

- 100, 101, 121, 158: 183.


225, 334 .
214, 227
214, 216, 223
215
234
230
229
-- Options 279
2 2 1 , 2 2 7
32

Activate 112, 201, 248, 264


-Add 112, 190, 255, 262
AddCiass 322
AddExistingltem 187
AddFromDirectory 187. 223
-AddFromFUe 187, 222, 223
-AddFromb'ileCopy 187, 223
AddFromTcmplale 187, 222, 223
AddJnsJtem 13 3
AddNamedCommand 152, 154,
155
AddWebReference 192
- Close 242
CodeElementFromPoint 3 2.1
CommandAddControl 158
Command.Delete 165
CommandBarShowPopup 160
CommandsAddCommandBar 159
Commands AddNamedCommand 160
ConfigurationManagerAddConfigurationRow 208
ConfigurationManager.ConfigurationRoiv 207
ConfigurationManager Platform 207
ConnectSolutionEvents 182
Count 112
Create 175
- CreateEditPoint 292, 296
CreateMediaPlayerToolWindow 269
CreateProject 235
- CreateToolWindoiv 269, 270, 273
-Delete 112
DeleteBetween Tokens 235
DllRegisterServer 334
DUUnregisterServer 3 34

433

Document 242
Document. lose 292
DocumentJtedo 291
Document.Save 291
Document.Undo 291
DoDefaultAclion
246
DTEExecuteCommand 151, 155,
168
DTELauncbWizard 228
EqualTo 293
Events.GetObject 200
tt?c 107, 153
Execute 215, 218, 228, 233, 236
ExecuteCommand 151, 168, 169
FtieCodeModelAddNamespace 3 2 3
FindProjectltem 186
.Form .ShowDialog 242
GreaterThan 293
HostUserControl 271
HostUserControl2 2 71
IDesignerHost.CreateComponeitl

265
IDTCommandTargeLExec 168 169
. 7'C'o w mandTarget.QueryStati j.s
152
IDTToolsOptionsPage.GetProperties
280
IDTToolsOptionsPage.OnOK 280
IDTWizardExecute 216, 227. 233.
234
Initialize 233
Insert 87
Install 166
112, 118, 148, 205, 240
ItemOperationsNewFile 197, 289
IWizardPagePerformWorki
235
IWizardPagePerformWork'l
2 35
LessThan 293
MakeReplacements 235
%; 88
MsgWin 89
My Macros MecordingModule.TemporaryMacro 79
Navigate 257
NeivFile 289
NewTexlFile 85
O&ye-ct

242

Object.Equals 276, 277


OleLoadPictureFile 255, 273
OnAddinsUpdate 107

434

- ()nAddlnsUpdate
102, 121
- OiiAfterCi-ealed
280
- OnBeginShutdoum 102, 107, 1 2 1
-Of/Connection 102, 107, 121, 122,
131, 153, 183, 269
- OnDisconnection 102, 107, 121,
122, 183
- OnStartupComplete 102, 107, 1 2 1 .
269
OutputWindotvPane.OutputString 263
Perform Work]
232, 236
PerformWork2
232, 236
Project 242
- Projectltem 242
Properties Jtern 275
PropertyDescriptor.GetValue 26(>
QueryStatus 107, 154, 155
References Add 190
References AddProject 191
Remove \ 1 2
- SatetiiteDtlPatb
143
-Select 246
- Se/ectDoirn
246
Selection 242
- SelectUp
246
SetSelectionContainer 273
-SbowHelp 233
Solulion.Create 224
Solution Jtem 176
Solution.Open 17 5
SolutionProjectltemsTemplatePatb 221
SolutionSaveAs 175
SolutionBuildBuild 201
System.Console,Write 91
System.ConsoleWriteLine 91
SystemReflection Assembly Load 250
- Taskltem Delete 256
- Task-Items Add 255
- TaskJlem&.PorceltemsTo taskList 256
- TextSelection 87
- 'loolBoxltemsAdd 249
- ToolBoxTabAdd
248
- ToolBoxTabsAdd 247
- Type.GelType
265
- UIHierarchy.Getltem
244, 245
UIHierarcby.SelectDown 246
UIHierarcby.SelectUp
246

Uninstall 166
- Window.SetSelectionContainer
273
- Window.SetTabPicture
273
- Windows.CreateToolWindow
267
- WindowsJtem 239, 244, 247
- WizardLibraryAddPage
233
91

357
381

19,78 .

126
121
184
182
128
107
138
151, 155
122
153
109
126
138
102
165
125, 126
- 123
127
121
107

92, 114, 178,


308
. CTS

. CLR

. CLS

Addln 107, 112, 133


Addlnlnst 268
BuildDependencies 205
BuildDependency 206
- CMNamespace
314
CodeElement 311, 321

CodeFunction 111
Codelnterface
111
CodeNamespace 111, 323
CodeVariable \ 11
COM 101, 123, 191
Command 111, 158
CommandBarControl 156
CommandWindow 88, 111
CommandWindotvPaneEx 90
ConfigurationManager 200, 207
Debugger 111
-Document 86, 111, 289, 292
Ore 111, 131, 174, 241
DTEAddln 131
DTEAddlns 131
DTE.Commands 152
DTEMvents 112
DTESolutionAddlns 131
DTE.UndoContext 300
EditPoint 111, 295, 297
EnvDTE JBuildDependency
205
EnvDTEProject 189, 205
EnvDTE Properties
209
EnvDTE.Solution 174
EnvDTE Taskltem 251
EnvDTE TaskList 251
EnvDTE.ToolBoxItem 251
EnvDTE.UIHierarchyItems
246
EnvDTE.Window 239
FileCodeModel 111, 321
Glohals 212
HTMLWindow 283, 284
IPicture 255
IpictureDisp 255
IPictureDisp 254, 255, 273
ItemOperations 175, 187, 289
MenuBar 158
Microsoft.Office.Core.CommandBar 156
Microsoft.Office.Core.CommandBars 156
OutputWindow 88, 111, 262
OutpulWindowPane 91, 264
OutputWindowPaneEx 90, 91
OutputWindowPanes 262
-Process 111
Program 111
Project 111, 189
Projectltem 111, 184, 186
Projectltems 184, 186, 289
Properties 274

435

-Property 274, 280


PropertyDescriptorCollection 266
Selection 273
-Solution 111, 175, 176, 186, 219
SolutionBuild 200
SolutionConfiguration 200, 201
SolutionContext 200
SolutionEvents 177, 182
StackFrame 111
System.ComponentModel PropertyDescriptorCollection
265
Systemlteflection Assembly
250
SystemString 15 0
System.Type 265
$ystem.Windoivs,Control 265
-iaskltem 256
-TaskList 88, 111, 241
- TaskListEvents 258
TextDocument 86, 111
- TextPane 285
- TextPoint 86, 111, 293
- TextSelection 86, 87, 111,291,
296, 297
- TextWindow 88, 283, 284
- Ture^rf 111
-ToolBox 88, 111, 247
- ToolBoxItem 248
-ToolBoxTab 112, 248
Type 265
UIHierarcby 243, 244, 246
UIHierarcbyltem 243, 244, 246
UIHierarcbyltems 243
- VirtualPoint 293, 294
VSLangProj References
190
-VSProject 189, 190, 192
-Window 88,118,238,240,241.
242, 247, 268, 276, 283
215

111

49
51
247
8,290

243
8, 12. 49, 267
238
52, 69
69

436

70

69

51
51
243
51
282
88

-Imports 86, 193


-Is
276,277
using 193

/case 76
-/doc 76
- IGL 5
-/GS 6
/hidden 76
/markali 76
-/06
/open 76
/options 76
/proc 76
/regex 76
- /RTCc 6
-/RTCn 6
- /RTCs 6
-/sel 76
- /up 76
jwild 76
/word 76

addlnsCollection 136
addlnsList 136
exclusiveProject 234
NetvItemLocation 235
NewItemName 235
NetvProjectLocation 2 34
NewProjectName 2 34
NewSolutionName 234
objIPictureDisp 255
ProductlnstallDirectory 235
Projectltems 235
ProjectName 235
-RunSilent 234, 235

serviceName 2 30
tasktistEi >ents 258
VisualStudioInstallDirectory 2 34
- WizardType
234, 235
6

- EnvDTE.vsHTML.Tabs
284
EnvDTE.vsTaskPriority 260
ext_ConnectMode 122
ext_DisconnectMode 122, 137
Extensibility.ext_ConnectMode 132
vsCommandBarType 159
vsTextCbanged 304
71
71
72
75
71
76
72, 73
33
Visual
Studio . VSIP
22, 23, 31, 48, 81
Deployment 40
- Visual C# 40
- Visual C++ 40
-Visual J# 40
COM- 130
-Visual Basic .NET 40
- Visual C++ 36
35
197
195
331
45
45, 203
40
200
46, 200, 384
208, 209
102
189
32, 207
176. 184
33
46

34
33

174
198
212
45
- 190
202
- 40, 101
130
189
- 31
43
222

187
187

- DTE 86
-DTE.Windows 88
-EnvDTE J06, 130
-Extensibility 106, 122, 130
Microsoft,Office.Core
107
SystemRuntimeJnteropServices 162
-SystemXML 194
-Utilities 130
70, 85


- HKEY_CLASSES_ROOT
334
- HKEY_CLASSES_ROOT\<ProglD>
123

- HKEY_CLASSES_ROOT\<ProglD>\CLS1D 123
- HKEY_CLASSES_ROOT\CLSID\<CLSID> 123
- HKEY_CLASSES_ROOT\CLSlD\InprocServer32 123
- HKEY_CURRENT_USF,R
334
- HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1 \AddIns\<ProgID> 125
- HKEY_CURRENT_USER\Software\Microsoft\VSA\7.1\AddIns\<ProgiD> 125
- HKEY_LOCAL_MACHINE
334
- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.1\AddIns\<ProgID> 125

437

- HKEY_LOCAL_MACHINE\SOFTWARE\Microsof t \VSA\7.1 \AddIns\<ProgID> 125


-IIKEY_USERS 334
19
. DTE
72-75
8. 48
49
13, 22, 23, 24, 48, 174
- HTML- 24
- XML- 24
175
175
24
46
200, 207
200
200
182
51
26
22
24
26
26
27
24

27
26
177
175
24
- 31
200
- 23, 24, 223
27
30
27
24

22, 45, 78, 90, 250

ActivePane 284, 285


ActivePoint 294, 296
AdminToolsFolder 3 36

438

AdminUser 336
AncborPoint 294, 296
AppDataFolder 336
ARPCONTACT 336
Author 336
AutoHides 242
Bindings 171
BottomPoint 294, 296
DuildEvents 113
ButtonProperty 343
Caption 242
Category 256
- CbechBoxOption 280
CbeckBoxXProperty 343
Checked 256
CodeBase 250
CodeElement 321
Collection 112
Command.Bindings 169
CommandJsAvailable 155
Command J\!ame 1 51
CommandEvenls 113, 118
CommentTokens 259, 260
CommonAppDataFolder 336
CommonFilesFolder 336
ComputerName 336
ConfigurationProperties 209
ConfigurationName 201
Connected 128. 136
- CurrentTab 284
CurrentTabObjecl 284
-Date 336
DebuggerEvents 113
Description 256
DescriptionLabel 233
- DeskiopPolder 336
Document Parent 290
Document.Saved 292
Document.TextSelection 291
DocumentEvents , 8
-D77F 1 1 1 , 198, 284
DTEActiveDocument 86
DTEActiveSolutionProjects 177
- DTE Active-Window 283
-DTEAddlns 183
DTE.CommandBars 156, 157
-DTEvents 112
- DTE Properties 274, 277
DTE.Windows 2?8
-DTEErtmts 113
-EndPoint 86, 292

Events.SolutionEvents 17 7
Events.TaskListEvents 258
FavoritesFolder 336
Filename 2 56
FindEvents 113
FontsFolder 3 3 7
- FullName
112
-Globals 212
-GUID 149
HeadingLabel 233
/cow 233
-

149

IDesignerHostMootComponent
264, 266
-7te/ 337
IsF loafing 242
-IsSettable 256
ItemOperations Prompt ToSave 175
-/ft>K/ 398
Line 256
Linkable 242
LocalAppDataFolder 337
LogonUser 337
MainWindow 241
Manufacturer 337
MiscFilesEvents 113
- AfebVV TroductType
337
MyPicturesFolder 337
-Name 198
NetHoodFolder 3 37
-Object 189,241,283
- ObjectKind 240
Optimize 209
OutputWindowEvents 113, 118
-Panes 284
-Parent 112, 265, 284
PersonalFolder 337
PbysicalMemory 337
PrintHoodFolder 3 37
Priority 256
Privileged 337
-ProductID 337
ProductName 337
ProductVersion 337
ProgramFilesFolder 3 37
ProgramMenuFolder 338
Project.ConfigurationManager
200
Project.Projectltems 184
Project.UniqueName 176
Projects 176
PromptToSave 175

Readonly 291
RecentFolder 338
RemoteAdminTS 338
ROOTDRIVE
338
ScreenX 338
ScreenY 338
Selection 86, 284, 297
SelectionEvents \ 13
SendToFolder 338
ServicePackLevel 3 3
ServicePackLevelMinor 338
SbouldBuild 202
Solution 174
Solution Addlns 183
Solution.SolutionBuild 200
SoluUonBuild. ButidDepen dencies 205
Solution Co nfiguration.Solu tionContexts 201
SolutionContexts 2 01
SolutionEvents 113
SolutionltemsEvents 113
SourceDir 338
StartMenuFolder 338
StartPoint 86, 292
StarlupFolder 3 38
SubCategory 256
SystemFolder 3 38
SystemLanguagelD 338
TARGETD1R
338
Taskltems 251
TaskListEvents 113, 118
TempFolder 338
'lemplatePolder 338
TemplatePath 219, 230
TextDocument. Selection 292
TextEditorEvents 113, 118
TextSelectionJsEmpty
297
339
233
ToolBoxTab.ToolBoxItems
248
- TopPoint 294, 296
UIHierarcby.Selectedltems 245
I'll IierarcbyItem.Object 246
UIHierarchyltem.UlHierarchyIterns 244
- UndoContextJsOpen 300
- UserLangimgelD 339
-USERNAME
339
-VersionNT
339

439

- VirtualCharOffset
294
- VirtualMemory
339
- Vte 1 1 2
VSProject References 1 90
- Window.Objecl 247, 264
-WindowEvents 113, 118
- WindowsBuild 339
WindowsFolder 339
- WindowsVolume 339
ToolBox.ToolBoxTabs 247

AfterClosing 1 1 3
AfterExecute \ 1 3
BeforeClosing 1 1 3
BeforeExecute 1 1 3
DocumentClosing J 1 3
DocumentOpened 1 1 3
DocumentOpening 1 1 3
DocumentSaved 113
FindDone 1 1 3
- IDTExlensibuityl
1 28
-ItemAdded 113, 199
ItemRemoi>ed 113, 199
ItemRenamed 113, 1 99
-LineChanged 113, 304, 306
ModeCbanged 1 1 3
NavigateHandled 257
- OnAddlnsUpdate 128, 133,
137
- OnBeginShutdown 113. 128, 137
- OnBuildBegin 113, 21 0
- OnBuildDone 1 1 3, 2 1 0, 2 1 2
OnBuildProjConfigBegin 113,
OnBuildProjConfigDone 113,
OnChange 1 1 3
OnConnection 111, 128
QnDisconnection 128, 137
OnEnterBreakMode 1 1 3
OnEnterDesignMode 113
- OnEnterRunMode 1 1 3
OnExceptionNotHandled 113
OnExceptionTbrown 1 1 3
~ OnMacrosRuntimeReset 113,
OnStartupComplete 113, 117,
133
- Opened 1 1 3
PaneAdded 113
PaneClearing 113
PaneUpdated 1 1 3
ProjectAdded 1 1 3

440

ProjectRemoved 113
ProjectRenamed
QueryCloseSolution 113. 178
Renamed 113, 182
SolutionEvents 199
-TaskAdded 113
- TaskModified
113
TaskNavigate 255
- TaskNavigated 113, 257, 259
- TaskRemoved 113
WindowActivated 113, 267
- WindowClosing 113
WindowCreated 113
- WindowMoved 113
112
119
114, 210
127
116
119
198
177
117
270
7

14
265
266

- CMCallbackFunction 321
GetMembers 316
Main 215, 342
-MsgWin 92
5
114

, FUID

247, 249. 266,


270, 279
14


. IDL

: ,
Microsoft Press,
, . , : , . Microsoft Office
and VBA Developer MSDN Microsoft Visual J++ informant.
. .
, , . , Microsoft Visual Studio. Visual Studio, Visual
Studio. .
Microsoft Press. , Microsoft: VGA MS-DOS .NET.
, -.

, ,
Microsoft Visual Studio .NET 2003

. .
. . , . .
. .
. .
. .

-
Adobe PageMaker 6.0

;.

IN

I E G A L

USE

. ,

*
e-mail: info@rusedit.ru, http:// www.rusedic.ru

Bl.
OS.08.03 . 3 000 .
70x100/16. . . . 29
,
105005, . , . . , 46



MSDN Magazine/ -1
:

Web: -* otseru,
Web-.
XML 1_
(XML Schema, VS-Seeunty. Wefa . .). .
ASP --
ASP ASP.NET.



,
,
'- ADO.NET,

(SOAP. Weo- , .NET Framework

.).

.NET
.NET .
/
,
.


: &

Microsoft,



.
KanotOM
,
- .
.

., 1
.
.

,
Microsoft.

C++: ,
C++.

,
Microsoft
(MSDN Magazine/ ,
1, 2002 .)


www.micro5oft.cQm/rus/ni5dn/magazinit


rnyiSoKQ
,

-

www.ITbook.ru

( , - )
,
,
, ,
. .





ADO.NET

SQL Server


MSDN Magazine
Microsoft MSDN Library

, 1;
Microsoft ADO.NET, Microsoft SQL
Server,
.
4GO ., 2003 -


.

.NET Framework { ,
, ,
. .),
,
.NET, /
.

MSDN Magazine MSDN Library,
www.rusedit.ru almanah@rusedit.ru.

.

, 2:
Microsoft ASRNEF, Web-,
Web-.
400 .. 2003 .

19

: e-mail: sale@rusedit.ru;
-: http:// ww lTbook.ru

e d u c a t i o n

Microsoft


Microsoft
:
Windows 2000/
Sun Solaris S
Visual Studio .NET

Soft tine

119991 . , . , .
.: (095) 232 00 23
e-maif: educ@softline.ru
http://education.softline.ru

*
40 .

.
.
.

wiw.softline.ru 232 ODE3 - jnio@softlint


:


3.
: (095) 778-7269
*- . , 6,
.: (095)928-3567
- . 3.
.. (095] 290-4507
" - 40.
.: (095) 137-6019
. . 28,
.. (095) 238-5001
-, 78.
. .(095)152-4511
- . 13, . 1.
.: (095) 150-6917
.' . 2- -. 5^
.: (095)978-5047
. , 8.
.: (095) 229-6483

-:
, -., 28
.: (812)318-6402
. -., 20
.: (812) 312-0563, 314-7134
" .
-., 57. .: (812) 273-5053

Microsoft Press


.

, . , 2,
.: (812) 164-6565,164-1413
, -., 13.
: (812) 312-6734
^ : (312) 247-1433
- ,
. (8121567-7025
:
,
. , 12.
: (3432) 59-4200
:
' .
-, 44,
, 2-
:
000 Ton-, : (3832) 36-1026
- ():
,
. .: 8-327-908-2-57, (3272) 76-1404

():

000 -
.: (+1038044) 269-0423
" ,
141038044)268-5346


. .
.
, ,
,

. , ,
.

Вам также может понравиться