QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2355|回复: 0
打印 上一主题 下一主题

函数大全(i开头)

[复制链接]
字体大小: 正常 放大
韩冰        

823

主题

3

听众

4048

积分

我的地盘我做主

该用户从未签到

发帖功臣 元老勋章

跳转到指定楼层
1#
发表于 2004-10-4 02:59 |只看该作者 |倒序浏览
|招呼Ta 关注Ta
< align=center><FONT color=#0000ff size=3><B><FONT color=#cc0000>函数大全(i开头)</FONT></B></FONT></P>$ P& G( @8 j+ q. s% Q0 C' R- _2 O
< align=left><FONT color=#ff0000>函数名: imagesize</FONT>
* A; r3 D6 i, j3 J功 能: 返回保存位图像所需的字节数 / |3 B6 z! J* L# |- q5 b2 r
用 法: unsigned far imagesize(int left, int top, int right, int bottom); 8 R/ G, a) C- p% {0 a( m. |( m) X; u
程序例: </P>
9 D% u7 q; s. a" d' z<><FONT color=#0000ff>#include <GRAPHICS.H>+ t, f+ J) _( z) Y) t
#include <STDLIB.H>' N0 |8 R: o# J
#include <STDIO.H>) U( I( x) f1 x3 H% i* q: _, l
#include <CONIO.H></FONT></P>
( m" M) k$ c) p/ m' ?3 Y<><FONT color=#0000ff>#define ARROW_SIZE 10 </FONT></P>
( c3 T: E! z/ G$ ~& C5 G<><FONT color=#0000ff>void draw_arrow(int x, int y); </FONT></P>
4 J. R# u1 e* w$ ?; {  @# D/ ^0 U+ \8 J8 W<><FONT color=#0000ff>int main(void) * \7 E2 Y( ]( A$ e
{
0 X! Y0 h) b- `) j! a+ r* i/* request autodetection */
7 h( s( G, N) M  Fint gdriver = DETECT, gmode, errorcode; 4 U/ ^2 W. K" J( Q
void *arrow; . j% }: i! S: g! o
int x, y, maxx;
* L% g) [% K( Z5 U9 N$ X6 N" Runsigned int size; </FONT></P>
/ a1 `9 `  N. x$ S+ J$ O- X$ t  S<><FONT color=#0000ff>/* initialize graphics and local variables */
) n; r6 \$ m8 M, U, t1 X! zinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>+ N( H; p* d1 ^2 D
<><FONT color=#0000ff>/* read result of initialization */
  ?4 J: ?. k1 ~6 T  V. {errorcode = graphresult(); * a# E3 \% i# U6 M
if (errorcode != grOk) /* an error occurred */   o. H+ e  A/ m4 k+ n% T
{ ! F  t9 m7 n' X$ t0 `
printf("Graphics error: %s\n", grapherrormsg(errorcode));
5 `2 T$ l9 S0 |printf("ress any key to halt:");
. q6 O$ M' [9 @) h  c, Mgetch(); 9 m0 U  w& f& h
exit(1); /* terminate with an error code */ * b6 {* _& g) s6 }+ ]0 \# l
} </FONT></P>
( [$ U. k, F7 m" w<><FONT color=#0000ff>maxx = getmaxx(); - X; p& C3 ?; Q% I* y+ x
x = 0; 1 q# m4 C' O2 P+ B# V
y = getmaxy() / 2; </FONT></P>
1 j9 _# U9 ~! L4 }# }<><FONT color=#0000ff>/* draw the image to be grabbed */ 7 x' E% H5 `- _" R  F0 X2 S
draw_arrow(x, y); </FONT></P>
7 ?6 t$ D. s9 A1 [<><FONT color=#0000ff>/* calculate the size of the image */
) H7 N7 u* Z9 `3 Y' bsize = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE); </FONT></P>: P+ r  X+ K5 D% j
<><FONT color=#0000ff>/* allocate memory to hold the image */
% o5 K8 A6 z9 }" `arrow = malloc(size); </FONT></P>
$ j' @* T% q  |+ g<><FONT color=#0000ff>/* grab the image */
& T' w" r8 o  C8 {6 t" w  a$ x9 t$ rgetimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow); </FONT></P>
/ l$ b/ n& ^  c1 ^) y% `<><FONT color=#0000ff>/* repeat until a key is pressed */ 3 L8 L4 R0 T$ K" t4 d6 Q
while (!kbhit())
  U8 ], l6 V* R2 Y" f- a{ 4 c1 {& \' Y) D% Z
/* erase old image */
  d# \4 `  |9 F* vputimage(x, y-ARROW_SIZE, arrow, XOR_PUT); </FONT></P>7 O9 f& b0 `1 n& }& g) F& h
<><FONT color=#0000ff>x += ARROW_SIZE;
5 {  q) x4 ]0 Lif (x &gt;= maxx)
- t3 _$ U- ^1 n: b: ux = 0; </FONT></P>
$ Y9 Q$ _8 G3 W% l1 M7 S2 a<><FONT color=#0000ff>/* plot new image */ 4 P6 g6 K( h5 c, N/ D0 T, T
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); 5 k0 B. W+ m2 l( L: X( M: o/ _. W
} </FONT></P>' I/ C! T8 t2 J# Z' N' w5 O6 l1 f. l
<><FONT color=#0000ff>/* clean up */
5 u4 B& m( _/ Ufree(arrow);
; T$ f8 r( q# P& s' A5 cclosegraph();
5 u6 G& d! k& y5 n+ Oreturn 0;
0 P6 V( ?9 K7 W# K% @  w} </FONT></P>
4 j' C+ W- [" D9 N9 V& w<><FONT color=#0000ff>void draw_arrow(int x, int y) # h. f7 o( a8 E) l! L  m
{ 6 H- h% h( W$ K; V0 V; I3 H
/* draw an arrow on the screen */
! b* _9 }7 n6 Z* u: n. R( R7 nmoveto(x, y); , v% H& D0 M5 q0 D) L7 S
linerel(4*ARROW_SIZE, 0);
% d4 S/ `9 [$ @0 @1 c8 Wlinerel(-2*ARROW_SIZE, -1*ARROW_SIZE);
' Z; u( G' y8 d3 n$ B* Mlinerel(0, 2*ARROW_SIZE); . E0 q. b8 o9 V. V$ J
linerel(2*ARROW_SIZE, -1*ARROW_SIZE);
/ s8 R; [9 x. s8 h2 u2 S3 o2 g* E} ) |( T7 P: l4 v. P
$ |5 V/ b, \3 @% ?

0 s6 y; A( e% w8 M</FONT></P>
9 b0 N% s( `. B6 u6 Z+ P& s- P<><FONT color=#ff0000>函数名: initgraph </FONT><FONT color=#0000ff>7 r) m9 V3 p1 c8 W5 r' H
<FONT color=#000000>功 能: 初始化图形系统
6 I- }! Z# o$ D* T, p用 法: void far initgraph(int far *graphdriver, int far *graphmode, # m& P' u& V3 r6 \3 W; J
char far *pathtodriver); 8 C0 w. R# ?/ d0 A1 |
程序例: </FONT></FONT></P>) c  z# o3 P  _# p+ X" d; I0 O
<><FONT color=#0000ff>#include <GRAPHICS.H>% f, u5 @) ?9 L, ?
#include <STDLIB.H>
6 }5 X( n( n) X* W#include <STDIO.H>* _' N1 {* W/ x* L! t
#include <CONIO.H></FONT></P>
8 q: j& I5 ]1 U* F: f<><FONT color=#0000ff>int main(void)
% n( M2 u$ \) i, J{ 8 E( E  @$ z# f' ]5 y4 G, I
/* request auto detection */
+ @3 k' e: d0 _& j) W& k# U' v! y. S( Mint gdriver = DETECT, gmode, errorcode; </FONT></P>
& T5 z# w0 F# c# V<><FONT color=#0000ff>/* initialize graphics mode */ 5 c* `& c1 ~5 U% v+ T6 P
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
' i2 D. t3 A* P! p* q0 K<><FONT color=#0000ff>/* read result of initialization */ 8 D6 b* ~, H) v* E% X
errorcode = graphresult(); </FONT></P>$ ]8 v( l2 m* l' |
<><FONT color=#0000ff>if (errorcode != grOk) /* an error occurred */
* H' s; Q6 ]& o5 A{ 9 j, }% H: z4 M& R! [5 Z
printf("Graphics error: %s\n", grapherrormsg(errorcode)); ; s" j0 e8 g" w: C+ S+ U: b& X
printf("ress any key to halt:"); " R; I- _6 }1 ^0 Y7 o
getch();
/ p: \& _; [9 d3 Q3 Q& k* c3 Hexit(1); /* return with error code */ ! }% V, w1 w7 ~3 R' B+ `: X9 ?, C
} </FONT></P>9 f' a1 e' _7 i, [- K  u. V8 ]/ f
<><FONT color=#0000ff>/* draw a line */ % P1 {" H# J* b. W; f
line(0, 0, getmaxx(), getmaxy()); </FONT></P>! ^  N$ N9 F& {4 }. S% i
<><FONT color=#0000ff>/* clean up */ ) S) s0 k$ B- u# ?4 L$ j! B: {
getch(); ' D+ D0 v- c4 X- y: g7 Q$ B5 u
closegraph(); # U  b" Q+ ~! |% H' v
return 0;
0 H) v; a! H# C$ ]} </FONT>
3 t0 y5 U* x' y1 N6 ^. h; |$ B+ A) [. C: k# `. c
</P>
4 ^) ?' {6 {9 N( b<><FONT color=#ff0000>函数名: inport </FONT>- B0 J! D8 B& p% o) y' f' d: @8 I
功 能: 从硬件端口中输入
; H  z1 W0 V# O& ^5 _用 法: int inp(int protid); ; A. @- {' H% |6 s( J+ h8 M
程序例: </P>) v: U5 y+ a; U' f8 t8 E+ a+ [" c
<><FONT color=#0000ff>#include <STDIO.H>
4 X2 Z2 P7 s) z#include <DOS.H></FONT></P>
. [" q  w/ I9 ?% {9 k& e4 O+ x9 z3 r<P><FONT color=#0000ff>int main(void)
# P$ j( u0 G) N, F( A{ 1 }+ r( A: q" F6 P! d. |
int result; 4 v6 t- D- u% p0 F  x6 r  y: Y. h8 u9 J
int port = 0; /* serial port 0 */ </FONT></P>
- K6 \* m3 {; k- H$ p<P><FONT color=#0000ff>result = inport(port); # D& P9 h1 E* A- ~8 O8 s
printf("Word read from port %d = 0x%X\n", port, result); " C: A( P5 Y4 j
return 0; 7 x" H% S' x& \
}
" u5 Z& q& h1 r/ C3 }
5 M3 g  l6 P/ {" f* G& q</FONT></P>* C0 u; E0 @: e9 A
<P><FONT color=#ff0000>函数名: insline </FONT>
+ Q" X  j' B" p7 j( C- T功 能: 在文本窗口中插入一个空行
  H8 g8 F- j. g- ^3 A+ ^5 Z  _1 o# [用 法: void insline(void); ) d4 f4 f2 g" _1 [' a
程序例: </P>4 i5 W+ D5 i, Y7 }( P$ q+ @
<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>0 H2 m! r) V+ n" P  l2 F. o0 M
<P><FONT color=#0000ff>int main(void)
) I0 l' T( @1 w0 Y2 P{
7 K, S. Z; k, X( k# r6 W2 @clrscr(); 6 f( l6 I" q& |9 d3 y
cprintf("INSLINE inserts an empty line in the text window\r\n"); . A2 k, P* r5 A( x/ C- m& I
cprintf("at the cursor position using the current text\r\n"); / _. U" r* c( l  x( d# ~
cprintf("background color. All lines below the empty one\r\n"); " R. Z6 [# [: q5 P/ i
cprintf("move down one line and the bottom line scrolls\r\n");
9 u* i) Z( m' @" t' E, R# K1 W- qcprintf("off the bottom of the window.\r\n");
& [# m8 p! {* H, ?1 P$ Q3 Ncprintf("\r\nPress any key to continue:");
1 m/ o8 }8 L$ i' S! k# agotoxy(1, 3); % @: ?  m5 {, {9 @# k
getch();
" @5 a) M- i9 ]! ]0 U6 Vinsline();
" O& ~# c! d8 pgetch();
% m3 w5 u! G& d% M/ `3 Ereturn 0; 8 P/ P6 t3 x4 K( c! [+ ?
} 5 E$ S9 q: E5 l. n! J- u4 o
</FONT>
8 b" y; c- d( i9 u' G; }) A8 r
) U1 Y& g$ D4 @+ t</P>  ^0 _8 s/ K2 M
<P><FONT color=#ff0000>函数名: installuserdriver </FONT>
! C9 H  Z" l. J2 b# B, A功 能: 安装设备驱动程序到BGI设备驱动程序表中
2 q( Q6 o( n  k9 I3 N用 法: int far installuserdriver(char far *name, int (*detect)(void));
2 K2 k# d. a$ @. ^  o程序例: </P>1 f: @) T& m4 p) o' [
<P><FONT color=#0000ff>#include <GRAPHICS.H>
, Q- w% L& N& E+ s, v#include <STDLIB.H>% n( ]& x- w5 M4 W
#include <STDIO.H>
# i& y, _+ t) X6 o  _8 J8 W#include <CONIO.H></FONT></P>0 I7 a9 r) c# t6 c% n: i
<P><FONT color=#0000ff>/* function prototypes */
. E, ]) E9 Q) F- tint huge detectEGA(void); / O! q/ D' @1 E
void checkerrors(void); </FONT></P>
& ?/ Q6 U. e1 x7 |' U/ L<P><FONT color=#0000ff>int main(void) & z9 U2 I) }- f: l' `0 l' ]' p, z8 Q
{
! K7 K6 E+ t. n8 T" C0 hint gdriver, gmode; </FONT></P>
+ \' V* p" p% R4 a: s: U<P><FONT color=#0000ff>/* install a user written device driver */ * g$ {; M" @1 H2 }
gdriver = installuserdriver("EGA", detectEGA); </FONT></P>
/ e2 O( o$ k* w. R: W3 |* q+ x<P><FONT color=#0000ff>/* must force use of detection routine */
: R* M. N- n/ o/ Ngdriver = DETECT; </FONT></P>! q, m# e9 E, E3 Z+ w+ E7 J/ v
<P><FONT color=#0000ff>/* check for any installation errors */ + j" O' ?# A  \& F1 N% |* P
checkerrors(); </FONT></P>! k$ w$ h! p9 H( c$ N7 S
<P><FONT color=#0000ff>/* initialize graphics and local variables */ " o) V0 p' [- W% G0 x6 s" c
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>9 X- l1 c1 B( a* h
<P><FONT color=#0000ff>/* check for any initialization errors */
: V% ?& ?8 {+ K* zcheckerrors(); </FONT></P>: U6 [/ u$ L6 t& q5 T
<P><FONT color=#0000ff>/* draw a line */
! W8 N/ z  e, Y- i. {line(0, 0, getmaxx(), getmaxy()); </FONT></P># Z/ P+ T$ E6 }4 \$ {0 z
<P><FONT color=#0000ff>/* clean up */
5 N1 p+ g5 q$ p3 Q2 z' pgetch();
( c, A9 F3 J8 Qclosegraph();
2 H9 i+ ^1 N) S: M2 Ireturn 0;
) h. \6 z4 C6 {  p$ d4 D} </FONT></P>, `4 X& ^2 a. G; G. K3 ]
<P><FONT color=#0000ff>/* detects EGA or VGA cards */
+ E4 ^* {# A* A7 j! B# {0 {3 Pint huge detectEGA(void) 0 f6 ~0 U0 v8 i; r/ S" D/ g
{ # E  {9 V$ `! K& i5 M; u) N
int driver, mode, sugmode = 0; </FONT></P>
. H% F- K2 Y# Y2 d9 ^" x<P><FONT color=#0000ff>detectgraph(&amp;driver, &amp;mode); 2 s! m: v: W3 J3 j
if ((driver == EGA) || (driver == VGA)) / ?1 p  E7 l, ~; j, [. x
/* return suggested video mode number */
- K" i/ |: d& @9 e6 W) M6 p4 Greturn sugmode; % R0 r  a5 b7 u2 q$ M; n
else
& K( F/ q! |" i: U! `2 _/* return an error code */
; m$ y4 }: H5 Q3 xreturn grError;
/ n% o8 _8 ]  M( C, v} </FONT></P>1 w1 _  r& m' ^' B. h5 e9 {
<P><FONT color=#0000ff>/* check for and report any graphics errors */
% b' o6 ?" z2 V/ y, Mvoid checkerrors(void)
2 p$ R' Z' R' A3 A% b{
8 E5 M% M5 V/ Q) P6 S: k) Xint errorcode; </FONT></P>, C# N( k3 |' D6 c' ]5 k9 B
<P><FONT color=#0000ff>/* read result of last graphics operation */ % M2 ^- b' G0 h; j+ V* u
errorcode = graphresult(); + R! E; Z) ~' s  o* Q+ C
if (errorcode != grOk) 8 W3 R6 W7 n& |- T" z
{ , t% V  Q' j7 G8 ^# p1 ^
printf("Graphics error: %s\n", grapherrormsg(errorcode));
' t1 I: y8 e1 M0 S+ q  |printf("Press any key to halt:");
' y) E3 d1 k. @5 e1 K6 _getch();
9 n: t* @2 K5 o. z4 Qexit(1);
$ E* P8 Q3 p3 g/ b/ Z} 2 r( x2 h% R* _9 U# f
} </FONT></P>
0 a+ j) E' A, R* y<P><FONT color=#ff0000>函数名: installuserfont </FONT>
+ Q  k. e, i* A功 能: 安装未嵌入BGI系统的字体文件(CHR) 0 w# ~" j1 `" P, x- Q. O
用 法: int far installuserfont(char far *name);
5 D" P: y: {0 N程序例: </P>
  W+ l& Q! D' _5 u2 \0 l<P><FONT color=#0000ff>#include <GRAPHICS.H>: ^) Y$ D, D9 K* K$ d. b
#include <STDLIB.H>
  \, e  l- r- |9 ~#include <STDIO.H>
* L% C! B3 b; r, A4 V, U8 h: l#include <CONIO.H></FONT></P>" g7 P& u! j$ Q# X3 k# H8 t* Q
<P><FONT color=#0000ff>/* function prototype */ 2 c2 {( u" F$ |; [& S$ O& x
void checkerrors(void); </FONT></P>
) i& `0 P& h: b. A, _<P><FONT color=#0000ff>int main(void)
- ?3 H. [5 Z- n9 U{
4 G8 L2 t" `. h/* request auto detection */ " w, l2 _# }, E, L* ^8 L
int gdriver = DETECT, gmode; 3 N9 f" |: ]. [& X- @3 d+ g
int userfont; ) l2 F$ T" G3 }
int midx, midy; </FONT></P>5 w( A7 N( z; {8 c) y
<P><FONT color=#0000ff>/* initialize graphics and local variables */ ' s4 N# i: I6 o" D* i; f
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>2 y7 j9 N8 z! |8 X
<P><FONT color=#0000ff>midx = getmaxx() / 2; & H9 a$ ?% ]3 ]5 F0 D
midy = getmaxy() / 2; </FONT></P>  E- E, I2 \! r* j# O
<P><FONT color=#0000ff>/* check for any initialization errors */
+ W$ L8 R# }  A- \  C  ]+ dcheckerrors(); </FONT></P>
. E. C+ k& R/ F( A" {0 f<P><FONT color=#0000ff>/* install a user defined font file */ ; ~4 d" X  x  x0 ~! ], P
userfont = installuserfont("USER.CHR"); </FONT></P>% a: [2 Y  h3 Y1 Z% s: T$ Y; u! H
<P><FONT color=#0000ff>/* check for any installation errors */ 5 O- L  r$ x$ |0 G
checkerrors(); </FONT></P>7 W4 ^; _/ V1 J
<P><FONT color=#0000ff>/* select the user font */ ; n: r0 L' s6 }3 Y& g4 ^( t
settextstyle(userfont, HORIZ_DIR, 4); </FONT></P>
3 a2 |; P+ I# \<P><FONT color=#0000ff>/* output some text */ 5 G+ g8 P+ e) O/ p0 P' v
outtextxy(midx, midy, "Testing!"); </FONT></P>
% N  x# p* p# v<P><FONT color=#0000ff>/* clean up */ 9 {. J6 V% p2 b. w
getch(); . s, W- l4 y* ?
closegraph(); $ P" R1 |% p2 p+ h' S7 B
return 0;
. i6 G% V3 p9 {9 [; l} </FONT></P>
" E) m( J7 i) r6 O/ `<P><FONT color=#0000ff>/* check for and report any graphics errors */ , j6 L0 T/ I; K; M2 t0 [$ k
void checkerrors(void) 3 ^8 G2 {$ L) H9 ?
{ " b+ q9 _4 }) u% ~7 M0 \9 R
int errorcode; </FONT></P>$ W; V5 C) @9 C8 g: g7 x; H+ _
<P><FONT color=#0000ff>/* read result of last graphics operation */
( {. k/ Z: Z& Herrorcode = graphresult(); % w) |% Q1 D1 D9 M6 x7 }8 v
if (errorcode != grOk) 0 t, L/ A4 X/ ^8 k6 ?
{ $ R3 c; X# d7 g# T
printf("Graphics error: %s\n", grapherrormsg(errorcode));
5 u4 _) M2 k3 L5 w% rprintf("Press any key to halt:");
( a; S; p5 p( e/ O+ z3 vgetch();
& V" p+ F7 G4 m9 l# t. p$ hexit(1);
/ h2 {' M  q) O* r( U' J8 d} # s# r7 H2 l7 L/ d2 l5 ~
} </FONT>; a8 S+ \# l9 H8 M6 y
! t$ C+ n$ D5 N$ Q7 @1 k
$ w1 X( w9 O; H- @3 y, K; t
</P>
1 d0 _; [2 Q" `" l* x6 W$ W<P><FONT color=#ff0000>函数名: int86 </FONT>  }/ w$ L) m: r3 \" h& [" K
功 能: 通用8086软中断接口 5 m3 B6 W1 b8 R9 D0 N& e; _
用 法: int int86(int intr_num, union REGS *inregs, union REGS *outregs); ( R5 o! v* H  {  }
程序例: </P>
7 r" U6 t4 l" M0 L<P><FONT color=#0000ff>#include <STDIO.H>
1 P4 u: Y5 c4 y$ \" p#include <CONIO.H>
. t) s$ ]! g: N#include <DOS.H></FONT></P>
1 A* V. _) a9 H% \7 f$ V5 R<P><FONT color=#0000ff>#define VIDEO 0x10 </FONT></P>8 G# J# A; p. D2 L
<P><FONT color=#0000ff>void movetoxy(int x, int y)
3 Y# M% u# d3 a* ^% Q{   G- [: ]' o) L2 {7 R
union REGS regs; </FONT></P>4 C2 ~/ s# x% l: V) f
<P><FONT color=#0000ff>regs.h.ah = 2; /* set cursor postion */ 2 ~! R6 a/ P3 U5 p- z
regs.h.dh = y; 3 ?& m/ `% O8 B& H, c8 P) N
regs.h.dl = x;
) U" a6 Z& r- a% j2 {3 Eregs.h.bh = 0; /* video page 0 */ . I: ~! N6 @/ Y: C8 u
int86(VIDEO, &reg;s, &reg;s);
8 {. D" ?& K5 `$ a, t+ |} </FONT></P>
+ w* ]6 _$ w" t: V  L<P><FONT color=#0000ff>int main(void) 3 e7 G5 C) w) ]1 K/ s0 Y- T) G
{ : Z- h9 M& n; u- i$ i
clrscr();
4 R6 p) B4 ]1 H& ^: ~3 v; q0 c+ Tmovetoxy(35, 10);
' n) r! _4 u, Vprintf("Hello\n"); 4 \  ?5 s! j. D7 ?$ }3 I8 E
return 0;
- E# a/ E: k# R: n' r. @} </FONT>
3 G/ l% f. C! E# Z
& P7 ?+ U( I5 C& Q4 t. O& r1 q</P>
4 x0 o, P6 ?' d1 x+ f& _5 r+ S<P><FONT color=#ff0000>函数名: int86x </FONT>- ?9 R1 L. ?: x1 ?" `$ |/ ^$ v
功 能: 通用8086软中断接口 , d' T9 q% ~  m( k/ e# a
用 法: int int86x(int intr_num, union REGS *insegs, union REGS *outregs, ! ]9 Q* l  w; `* g! R" B
struct SREGS *segregs); 5 B+ F: k0 U# a% [6 \' d+ z
程序例: </P>
: p: o* v2 F* I0 E9 z0 S: Y" S- h<P><FONT color=#0000ff>#include <DOS.H>( L& b+ K/ L7 h  S" o3 N% A. j- u
#include <PROCESS.H>* [; P+ q& t6 a( o: A7 _! C8 {
#include <STDIO.H></FONT></P>
" m( x7 h. G' t8 w8 O+ V<P><FONT color=#0000ff>int main(void) - t, h8 q9 g: m+ v
{
) ?0 w/ N( T( E' tchar filename[80];
# E* [5 w8 e7 G( G0 q2 junion REGS inregs, outregs;
2 a0 Y- i( K; l1 Y( M. [! Estruct SREGS segregs; </FONT></P>( z! ?1 S  Z) o
<P><FONT color=#0000ff>printf("Enter filename: "); 6 e* k6 o5 Y- K+ p: x' G: W
gets(filename); 6 I4 s3 M9 X. a/ J0 M
inregs.h.ah = 0x43;
! _7 @* K- h: o3 }; Rinregs.h.al = 0x21;
/ e  Q8 s! b5 _. T  |% {1 \inregs.x.dx = FP_OFF(filename);
; u& U) D0 g! h* g. Isegregs.ds = FP_SEG(filename);
, ~7 t& W" y+ g# R) {int86x(0x21, &amp;inregs, &amp;outregs, &amp;segregs); # b% N# {% K" v$ H) K
printf("File attribute: %X\n", outregs.x.cx);
" T7 j( T+ [6 b8 Creturn 0;
' j9 O, N2 S' p) q3 f# A- d}
% T& h0 o! t  W( S$ F9 [0 H' g3 h! h7 x# w! l
</FONT>7 Z" ?) R' o+ E+ L( g5 D% O, M
</P>
9 ]) G5 S& @5 c; e<P><FONT color=#ff0000>函数名: intdos </FONT>
! D8 J. y- b; w3 x3 A( y8 H) W. K6 M功 能: 通用DOS接口
/ l- E; P' R7 d; b, g用 法: int intdos(union REGS *inregs, union REGS *outregs);   s6 y" Q6 y1 U
程序例: </P># _7 V- L1 i( u$ U
<P><FONT color=#0000ff>#include <STDIO.H>
& c! x7 e& t" K) D$ ]2 o7 {' f#include <DOS.H></FONT></P>6 p( }  H, A- i, p
<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */
7 n. n, W1 z' Q: g: c" {int delete_file(char near *filename) * E! C6 |( [1 _+ D. B+ z6 F
{
% `6 b) i7 a+ c0 |union REGS regs; ) l% X  R0 p% q' x7 g
int ret;
; F% b9 t, k6 [! \! {) j* l! H7 Nregs.h.ah = 0x41; /* delete file */
/ Q0 I  I! f+ V; n9 Nregs.x.dx = (unsigned) filename;
3 ~' z$ s. g% {7 W8 G$ u( V0 `ret = intdos(&reg;s, &reg;s); </FONT></P>
& R/ w8 A/ y: ~# @/ D- C+ Z7 }<P><FONT color=#0000ff>/* if carry flag is set, there was an error */
  _+ x* j+ M! L  W# t2 ^1 ~4 }return(regs.x.cflag ? ret : 0); 2 h. q5 }* G2 |& h3 f, o
} </FONT></P>
  p" c5 G* B! B$ u: k, c<P><FONT color=#0000ff>int main(void)
7 n6 I/ W& t2 o% i' N/ H{ ' j) [" j6 E, ~$ E3 L" Z
int err; ' B0 R( _) F2 T! I4 b- |
err = delete_file("NOTEXIST.$$$");
+ m4 O0 E. M* H! |6 P! _. uif (!err)
1 W5 O2 B1 j; ]9 uprintf("Able to delete NOTEXIST.$$$\n"); . k2 w9 C; t4 z5 ~8 x, O
else
# {& }0 m  T6 |& @# Wprintf("Not Able to delete NOTEXIST.$$$\n");
1 A. x: R+ g, g7 y  X1 _return 0; : N; E! @# z0 K- w/ u  m" I& Q* C
} & c) F$ d6 T* g

( \( z$ m+ X2 H. n</FONT>
. U  F2 |) `+ w/ M/ \</P>
1 ]* G9 y$ F5 ?# F8 q<P><FONT color=#ff0000>函数名: intdosx </FONT>! l# }4 n& \6 l/ t5 m! {& \
功 能: 通用DOS中断接口
. \$ H8 K. b" q6 T5 @! R. W4 E用 法: int intdosx(union REGS *inregs, union REGS *outregs,
2 b* ^2 d" _- r7 ~; B, g9 sstruct SREGS *segregs); # k0 ]/ k# l# @) a+ Z
程序例: </P>
  M# t$ f3 X8 c0 f<P><FONT color=#0000ff>#include <STDIO.H>2 g* b) @) o. [" q
#include <DOS.H></FONT></P>7 ^3 [3 R' Q, a/ A+ @
<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */ & d3 G& X3 [5 q; G9 j4 d' n
int delete_file(char far *filename)
! O/ @/ C. R) L1 U{
. y5 f9 `; N  Q( u  e- Eunion REGS regs; struct SREGS sregs; / d8 p1 y+ s' S# O6 H* r' w
int ret; 5 e8 O; G7 t0 x) ?0 L3 T0 D
regs.h.ah = 0x41; /* delete file */ 9 i- O4 `. G6 t0 M9 I- E
regs.x.dx = FP_OFF(filename); - S' O/ Q! k7 u+ }
sregs.ds = FP_SEG(filename); ( _' @! I1 c4 s  m3 a/ n
ret = intdosx(&reg;s, &reg;s, &amp;sregs); </FONT></P>
  O; R9 [5 r& _/ c8 ^<P><FONT color=#0000ff>/* if carry flag is set, there was an error */
1 H. W# N- p7 s0 D. z) creturn(regs.x.cflag ? ret : 0);
, q0 _6 E% |. @6 W} </FONT></P>7 _& {7 _+ L. S5 L! l3 U
<P><FONT color=#0000ff>int main(void) $ s* `6 l8 n# e. W3 b
{
' V1 z& d1 q* p5 X) iint err; ( }4 ]9 ~" z2 W8 G& @( C# A
err = delete_file("NOTEXIST.$$$");
1 M" C& F( K/ A: x) p8 [if (!err) 9 P! I$ v- [; a5 \4 @7 k
printf("Able to delete NOTEXIST.$$$\n"); 3 I. U) I& |0 s. q
else . o* ?5 l9 H1 ~9 T: {  b
printf("Not Able to delete NOTEXIST.$$$\n");
( O: }1 m( R* Y: f( ^return 0;
/ K! c4 v! d& q8 m0 e) A} ) N3 W/ J! Q2 a4 O9 f* C
</FONT>
2 H9 R) t; M7 f: T6 d3 a</P>2 G1 S2 i/ N* j/ @8 C" K, t8 X0 g
<P><FONT color=#ff0000>函数名: intr </FONT>
9 D* p: N- T7 O- K7 O1 Z, [3 w功 能: 改变软中断接口
. a! T/ k# Q5 w用 法: void intr(int intr_num, struct REGPACK *preg);   F5 j7 ^+ Z& k: y, d% H. T" \
程序例: </P>
9 w2 P2 c/ S! Z& _: _, A<P><FONT color=#0000ff>#include <STDIO.H>
. Q1 f+ t8 Q6 H$ s$ H#include <STRING.H>/ }5 A( |# m. g7 T4 Q* T) {3 E. J- V
#include <DIR.H>
2 R" W( C$ Y9 A2 J) d& y#include <DOS.H></FONT></P>
0 F3 h& t3 n3 ]- i0 O<P><FONT color=#0000ff>#define CF 1 /* Carry flag */ </FONT></P>- M2 f1 G; `: @% ?4 b: H$ Y: Q
<P><FONT color=#0000ff>int main(void)
- Y/ b( @, d& `% [8 ^, f0 T{ 6 P2 S/ H, H  f. B) x3 R% X% l
char directory[80]; ( j2 C) t5 v2 j1 C, ]2 d
struct REGPACK reg; </FONT></P>+ l) P; R( k/ q5 d) Q: A. ~8 x
<P><FONT color=#0000ff>printf("Enter directory to change t "); 2 c: n% J/ Z$ f4 F$ O9 {
gets(directory); ' a% q; m- @/ @0 w1 R
reg.r_ax = 0x3B &lt;&lt; 8; /* shift 3Bh into AH */ ( }& L) B  ?2 `1 ]7 s
reg.r_dx = FP_OFF(directory); + _2 X3 e6 r" ]
reg.r_ds = FP_SEG(directory);
. f$ _  b: ~+ e3 }! ~+ W. \( qintr(0x21, &reg;); 7 m) y) D5 g& B4 g& t
if (reg.r_flags &amp; CF) / R5 K) `) k! ~4 C/ ?8 w; u
printf("Directory change failed\n"); ( x6 `! R+ a2 z7 Y8 D1 ?2 {, U
getcwd(directory, 80);
/ i3 R( N1 z/ Zprintf("The current directory is: %s\n", directory);
. i+ _# c( ^+ i. }' }# R3 _* ureturn 0; 1 ~9 ~2 u9 b8 j, w% s
}
  `3 i( i  R4 m+ V</FONT>( u$ E2 [6 E" {1 A3 r* l& Z
</P>: m& b- r1 O, N: F
<P><FONT color=#ff0000>函数名: ioctl </FONT>7 P5 N% i9 J& J* z
功 能: 控制I/O设备
  z5 Z6 I4 M7 E* S" p用 法: int ioctl(int handle, int cmd[,int *argdx, int argcx]);
- E! X/ _7 j+ U程序例: </P>
; {: Y6 E) |! }  @<P><FONT color=#0000ff>#include <STDIO.H>
  _5 P. v( i8 `& L#include <DIR.H>
9 {9 k. S% k) p& H; j#include <IO.H></FONT></P># z2 a6 B% H- K( B. p
<P><FONT color=#0000ff>int main(void) 9 X, n2 r( }' U9 E5 d+ j
{ ( X+ o3 J& p/ {9 @; c# K
int stat; </FONT></P>$ o* ?9 w! C! e
<P><FONT color=#0000ff>/* use func 8 to determine if the default drive is removable */
0 F8 I" i3 V6 C% @1 D5 _# K1 ystat = ioctl(0, 8, 0, 0); + [; F# N6 k& {  w$ ]
if (!stat)
1 n. F4 w4 \) b( Yprintf("Drive %c is removable.\n", getdisk() + 'A');
0 y/ `" Z) b  D* ?" Selse % N6 i- O  ?2 S4 m" B
printf("Drive %c is not removable.\n", getdisk() + 'A');
' f6 m# _5 H: A- G7 freturn 0;
3 Z: B$ F: K' N4 w& h}
0 A# T% {. J4 Z- ]. s. x2 {8 N! O
; j& W4 |0 _1 B: y3 u4 m! o" _# c7 p</FONT>6 Q& w6 R1 k4 j9 y! q
</P>
2 R, \& B) Z! ?9 T% D1 e<P><FONT color=#ff0000>函数名: isatty </FONT>( ]" ?( X7 E3 T& e- ^  x
功 能: 检查设备类型 - w# ?0 i8 O, X1 @
用 法: int isatty(int handle); 0 b( n) N2 D/ \: r
程序例: </P>. ^9 m& ^1 Q) \
<P><FONT color=#0000ff>#include <STDIO.H>8 c: ?/ a' z4 P1 g3 r
#include <IO.H></FONT></P>3 g. _. e' f4 B
<P><FONT color=#0000ff>int main(void)
2 F. [  c& x5 V( Y9 w{
6 D) O0 {, O& e3 D8 uint handle; </FONT></P>. H2 S7 M0 A& V# c6 S* y
<P><FONT color=#0000ff>handle = fileno(stdprn); ; v+ U& X7 y/ J( G7 I8 b6 o# P5 Z
if (isatty(handle)) , B, y5 d: i1 e8 g. e
printf("Handle %d is a device type\n", handle);
6 M( U9 B7 t, C( ?else . t) p9 h1 s$ j0 l7 g1 v1 z" q- ?5 }1 H
printf("Handle %d isn't a device type\n", handle);
- A0 z' X; J: L$ L/ `return 0; ' }( O) J; E+ L$ _
} - i: B1 V1 M- n& h# _

0 }5 m( I/ Q6 }, Q' N# s* y$ {6 m5 ]</FONT>
, j1 H! N3 L, I</P>- T4 Y  E& w! s9 U: r; b! A
<P><FONT color=#ff0000>函数名: itoa </FONT>* h% W4 h6 o3 T0 X+ p. C  X
功 能: 把一整数转换为字符串 $ a" G1 k) {  O/ [1 r/ |! n
用 法: char *itoa(int value, char *string, int radix); 1 J' j# W0 {% }1 |7 p
程序例: </P>* G# y# {2 I* d2 D! Z" f
<P><FONT color=#0000ff>#include <STDLIB.H>
3 d. B( [% `4 d& v4 U#include <STDIO.H></FONT></P>
3 z  F& G6 @( _9 |5 O% r! D$ k' X<P><FONT color=#0000ff>int main(void)
& o, C0 g/ H. i5 t1 r# z% Q9 }{
* s7 g, _" k! c  v; Pint number = 12345; 1 J' X2 k, B' q! y7 R' Y
char string[25]; </FONT></P>
. Q4 ~/ I5 S3 A2 d& [' R( ~<P><FONT color=#0000ff>itoa(number, string, 10);
  ^7 d1 U/ M. j- U3 g( {2 H) }' mprintf("integer = %d string = %s\n", number, string); . p0 U# j6 g- P6 @2 K& N+ K
return 0; # R" n- E6 o/ l# N5 g+ L% {
} </FONT><FONT color=#0000ff>
8 e1 d( H2 P1 O: ^; a</FONT></P>
zan
转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
您需要登录后才可以回帖 登录 | 注册地址

qq
收缩
  • 电话咨询

  • 04714969085
fastpost

关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

手机版|Archiver| |繁體中文 手机客户端  

蒙公网安备 15010502000194号

Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

GMT+8, 2026-6-12 22:47 , Processed in 0.429088 second(s), 52 queries .

回顶部