QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2333|回复: 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>) S* B* _  y' c  P7 a
< align=left><FONT color=#ff0000>函数名: imagesize</FONT>
2 D: t: d; P( D' H1 w$ u功 能: 返回保存位图像所需的字节数
1 b5 w, _( v' _用 法: unsigned far imagesize(int left, int top, int right, int bottom); 5 S8 c, I0 j% S2 G6 D
程序例: </P>
7 Y$ ?; ]! l4 k3 i<><FONT color=#0000ff>#include <GRAPHICS.H>
4 n4 _0 a0 w9 ?8 m- m' D+ e5 |#include <STDLIB.H>+ n& }: x9 W4 i9 Z3 V/ {
#include <STDIO.H>
/ e+ s" `( y! i( ?#include <CONIO.H></FONT></P>( u+ i' E5 @( r; k& D& l! R
<><FONT color=#0000ff>#define ARROW_SIZE 10 </FONT></P>: B  A) z- ~6 E
<><FONT color=#0000ff>void draw_arrow(int x, int y); </FONT></P>* V0 l2 o- {* y$ ^/ S
<><FONT color=#0000ff>int main(void) 7 b" R- q; l, ~; k* P+ r, Y9 i
{
% O5 f+ k/ j8 u% ^; L/* request autodetection */
9 ^$ M5 J; d) t6 q- y6 `5 B+ B( |int gdriver = DETECT, gmode, errorcode; 0 h+ E4 a0 s9 ]) K) S% n
void *arrow;
. f. W! c5 P5 A8 T& U0 Y+ `int x, y, maxx; 6 S0 @( }/ A/ T
unsigned int size; </FONT></P>" z% O* l+ O6 W0 q' ]( S& l
<><FONT color=#0000ff>/* initialize graphics and local variables */   a+ d" R4 E# W7 ^* F' A. g
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>. U( \& t1 e2 D, N6 `, _
<><FONT color=#0000ff>/* read result of initialization */ ; `7 H+ Y$ G2 l2 \  k. ]# Z: c
errorcode = graphresult();   s3 R( U& g4 W3 f. y# l8 U
if (errorcode != grOk) /* an error occurred */
/ c1 r- {; ~6 N# A{
7 |- z. {! T' |% b/ H, N9 Iprintf("Graphics error: %s\n", grapherrormsg(errorcode)); # S/ |; r7 V: T2 n' N' |4 I$ {
printf("ress any key to halt:"); 4 e, J$ Y( j# D; J4 ?) r
getch(); ; ?1 c  c+ k/ w4 V  F' V( E
exit(1); /* terminate with an error code */ 4 a" u2 a- ~6 y4 q5 u: q& a: K# f+ d
} </FONT></P>. ~8 J9 K# T" x) d3 U9 W& |% A
<><FONT color=#0000ff>maxx = getmaxx(); : N  m4 a" M! s# [
x = 0; & g! j6 i7 z7 ?$ z9 ?
y = getmaxy() / 2; </FONT></P>$ e/ U' c; j% w6 T! h6 R
<><FONT color=#0000ff>/* draw the image to be grabbed */ & r) j6 C- U* m" R& R% A! {" X
draw_arrow(x, y); </FONT></P>
" f2 i/ J8 g+ T+ H<><FONT color=#0000ff>/* calculate the size of the image */ 4 @* E' [3 v' W8 u1 U
size = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE); </FONT></P>
. O3 A% A& y3 {! j: [8 y<><FONT color=#0000ff>/* allocate memory to hold the image */
  D7 W( h5 N, carrow = malloc(size); </FONT></P>" x# T$ h# j+ U
<><FONT color=#0000ff>/* grab the image */
3 W: u8 e) e; E- M$ T! Z  i  X" ?getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow); </FONT></P>7 Y! F$ o# l7 T
<><FONT color=#0000ff>/* repeat until a key is pressed */ ) L$ {8 {' z# O) z# x
while (!kbhit()) # w- S" V6 T# x$ @4 G
{ 6 R2 d$ s% k* m# A8 }. W. b
/* erase old image */ ( i5 w8 y+ P5 z, b- z/ x) D
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); </FONT></P>
+ G+ Z( E6 |$ u* D. v6 i4 K% g<><FONT color=#0000ff>x += ARROW_SIZE;
- O+ n: v, i! P. Iif (x &gt;= maxx)
# {* X) W& C3 p$ E, x& q+ zx = 0; </FONT></P>
$ n& A& f. _, t7 z2 r0 V! F2 t<><FONT color=#0000ff>/* plot new image */ % m1 R6 Y: t7 d& u; C+ Y! W
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); + C4 R8 S; u# p6 h. Q
} </FONT></P>
' B( ?/ s$ f8 `& c! j  P<><FONT color=#0000ff>/* clean up */ 5 A4 {- z( }1 L  {: I4 U; @
free(arrow);
3 n! W2 u8 M; c, o0 A7 G* m6 Vclosegraph(); / r2 _0 v2 ?3 |2 z' k& s
return 0; ( o; M, f: i) t% i9 h/ l4 T
} </FONT></P>
4 n! c& N- n* K* |<><FONT color=#0000ff>void draw_arrow(int x, int y)
$ Z: i" F: K, q1 P{
0 D/ e  a7 e8 D/* draw an arrow on the screen */ 7 D0 y1 j  Q) ~& Q4 g
moveto(x, y); - M+ w) ]  N- d* C  _! X- y
linerel(4*ARROW_SIZE, 0);
1 M; j) Y$ g3 y; n: k6 I" ylinerel(-2*ARROW_SIZE, -1*ARROW_SIZE);
& s; n; d  ~# `* U1 W, R7 o9 f: Wlinerel(0, 2*ARROW_SIZE); % Q1 p+ u( _% {0 U+ X5 C& X
linerel(2*ARROW_SIZE, -1*ARROW_SIZE);
3 z2 q3 ?0 S+ y( w8 J2 ^( {9 X9 i}
  B, K8 z: C. x# \# T0 C
; l" F+ E0 u# a/ \2 r+ Y* m  r4 R5 Q) H! X$ y/ {8 a+ y
</FONT></P>
% Z7 G2 a( e& p# G0 A) J6 `$ @<><FONT color=#ff0000>函数名: initgraph </FONT><FONT color=#0000ff>
2 D! \  ^' k* r& r: q<FONT color=#000000>功 能: 初始化图形系统 - N. z" c* l' G8 ~0 U
用 法: void far initgraph(int far *graphdriver, int far *graphmode, 9 P% g, h+ G0 a! ^2 `  F: w
char far *pathtodriver);
. Q& v& V) v7 Z4 X7 L: y% a4 o程序例: </FONT></FONT></P>- r& ^' [$ \( J4 q; i
<><FONT color=#0000ff>#include <GRAPHICS.H>% N& I- N7 c9 f) Y2 J
#include <STDLIB.H>
" q, G; Q, h, _3 S#include <STDIO.H>/ s4 Y7 `$ C# W$ q# V. u
#include <CONIO.H></FONT></P>
0 ]3 E# `2 E5 N<><FONT color=#0000ff>int main(void) ( l7 X2 z! V: z1 S+ G, r6 B% w4 R
{
* i! a( P' x2 x- g( b1 |1 [, h/* request auto detection */
. t' W# L! K# ^* {( xint gdriver = DETECT, gmode, errorcode; </FONT></P>. a& c5 e' r6 b$ |, n& X  V
<><FONT color=#0000ff>/* initialize graphics mode */
8 R( [+ e' i' d/ ]  Jinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>, K/ r/ |; R. x* x. X2 b/ Y8 S* @: a
<><FONT color=#0000ff>/* read result of initialization */
6 [9 Q9 `. K, |$ rerrorcode = graphresult(); </FONT></P>8 }, ~) v# ^. {) t- C
<><FONT color=#0000ff>if (errorcode != grOk) /* an error occurred */
* d4 u' Z7 H( A/ T0 p. P( D{ % l/ M' P0 c+ v0 I" b
printf("Graphics error: %s\n", grapherrormsg(errorcode));
" x% [0 ~) m- E1 o  Cprintf("ress any key to halt:"); " j7 f! C+ K" W; w. ?' O* F% [
getch(); 5 \4 f$ ]" I  J- T, j# }! @" @- X
exit(1); /* return with error code */ 6 c9 |# `9 M9 B& w2 Y, u  y$ `
} </FONT></P>+ R+ w' W- U0 g" _
<><FONT color=#0000ff>/* draw a line */
7 b/ i  ], [) m8 `3 t, d& rline(0, 0, getmaxx(), getmaxy()); </FONT></P>
1 V/ J3 j7 A# Q1 B8 H0 ~<><FONT color=#0000ff>/* clean up */ 8 T# d. Y! r, x7 V- c
getch(); . |9 u) W% B' g6 K; H
closegraph();
& h/ I( V8 Y; a$ W7 ]' v' xreturn 0; ' l3 Z2 t9 Q8 l+ P! G, h
} </FONT>+ V6 S7 s, B4 I" J

* O' H/ G. F, t( n2 G</P>1 }  y0 j) b- x2 |! k
<><FONT color=#ff0000>函数名: inport </FONT>
2 X3 G( K# f4 W功 能: 从硬件端口中输入
# j( R+ T3 A& @+ x9 q用 法: int inp(int protid);
" p; u( U9 ?; ?7 ?; P程序例: </P>4 B$ b& I) \3 I* {0 a
<><FONT color=#0000ff>#include <STDIO.H>- L2 O; M) y; @; M9 k
#include <DOS.H></FONT></P>
; x$ V+ o5 u: q; }& X<P><FONT color=#0000ff>int main(void) # Z( H  \+ ]$ M- h4 L: d
{
$ i9 T/ q; }( `' I; qint result; 0 y! i* M$ r* x! y
int port = 0; /* serial port 0 */ </FONT></P>1 p# x6 m& n% Y9 g! y
<P><FONT color=#0000ff>result = inport(port);
& X6 i$ q9 E6 U( ~$ nprintf("Word read from port %d = 0x%X\n", port, result);
( ]6 M) {* W: X6 j; sreturn 0;
/ v8 j+ }  b* p+ n5 f$ G0 b}
% e2 W$ U( Q. G0 l: `  _! _) i) b1 k% {$ d* C
</FONT></P>- N3 h9 S: l+ k0 M& [
<P><FONT color=#ff0000>函数名: insline </FONT>9 e: K! y" ~& F$ `
功 能: 在文本窗口中插入一个空行
% c* k7 s; n  a用 法: void insline(void); * R* V9 y4 @% G' C3 O
程序例: </P>
* |  f* E; \% H2 z6 n<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>
% l; O& ^$ J& ]. \. H; m<P><FONT color=#0000ff>int main(void)
; U/ T. Z" }7 n/ X: P9 j{ 6 {$ @. X2 M. u: c8 l
clrscr();
6 B# }5 _" E! L; M: B& ccprintf("INSLINE inserts an empty line in the text window\r\n");
( z0 r0 X0 M: J8 Z$ L2 `" D4 r% lcprintf("at the cursor position using the current text\r\n"); 9 {) E5 R/ l9 p* o2 E; H
cprintf("background color. All lines below the empty one\r\n");
) w; {8 n) `, Mcprintf("move down one line and the bottom line scrolls\r\n"); 4 a. O) @) l8 o* e, Y
cprintf("off the bottom of the window.\r\n");
0 q+ B7 ]% C1 k  T" A* gcprintf("\r\nPress any key to continue:");
; N7 q$ D3 y5 K$ L0 U) Jgotoxy(1, 3); * t+ y/ t9 m/ V) |  f* V2 E( P1 ]
getch();
6 T/ z  ?. ^" {6 L1 G. t6 v1 ]$ cinsline(); - U( Q# j$ \7 n2 `4 p3 f0 I
getch(); ' T7 H" R  k1 x4 l1 E
return 0;
" I' @3 A7 ?) N( f. d# \$ w" e} + `! r( v$ G3 ]* r8 z& i
</FONT>0 J, b2 N$ ?' H' N

/ T& E4 \8 e; K2 b</P>
) T0 H% _1 b' k+ B<P><FONT color=#ff0000>函数名: installuserdriver </FONT>
5 s# s/ `! k: F8 C5 o功 能: 安装设备驱动程序到BGI设备驱动程序表中
8 }: D# m. l3 N0 b  e; \, a. v: p4 B用 法: int far installuserdriver(char far *name, int (*detect)(void));
4 L8 G& w$ `" K5 _8 j! v0 O8 Y) f程序例: </P>" V1 S& x; j+ t% N9 @3 ^) d) _
<P><FONT color=#0000ff>#include <GRAPHICS.H>% G" ^' y6 l' }* D* p  ]
#include <STDLIB.H>
. X6 Q# L* c$ b8 P#include <STDIO.H>
2 [/ p0 _! U3 _9 Z: Y3 C! A#include <CONIO.H></FONT></P>
" w8 {+ @9 w  y& Y' j/ ~# i/ j9 K<P><FONT color=#0000ff>/* function prototypes */ 1 m" i$ j: T' ]3 |* U: w6 n
int huge detectEGA(void); ' }1 a! H9 c; N6 E* m$ F
void checkerrors(void); </FONT></P>" `) D1 o2 _# @6 u+ l8 R) }
<P><FONT color=#0000ff>int main(void)
. }& d6 P. g' }1 U" t  o! E{
) l7 g8 s, Y& E: h% ^6 Z1 Rint gdriver, gmode; </FONT></P>
# I, V  `5 y. y8 s: `<P><FONT color=#0000ff>/* install a user written device driver */ : k2 {' |* F- A, Y: s
gdriver = installuserdriver("EGA", detectEGA); </FONT></P>
: [- m+ r& _4 H" q3 }1 X8 L<P><FONT color=#0000ff>/* must force use of detection routine */   G9 E6 U  K* B: E/ A5 U  R- e
gdriver = DETECT; </FONT></P>0 o7 x6 i& O, D+ T
<P><FONT color=#0000ff>/* check for any installation errors */ ! o; f. X) M# w7 _
checkerrors(); </FONT></P>
! k. J4 L- z- S9 G  O% S  C- Z# n<P><FONT color=#0000ff>/* initialize graphics and local variables */ 7 P3 _. K  |2 O: A9 D5 {
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
1 V' P- C! W  V6 d# W6 r: r<P><FONT color=#0000ff>/* check for any initialization errors */
% I, c3 M9 k0 R3 f. N* s$ g7 _, t- D- g  Qcheckerrors(); </FONT></P>( u# b. T; W8 I8 ]+ {- `+ L1 E
<P><FONT color=#0000ff>/* draw a line */
* Z/ H, w5 r; w" Dline(0, 0, getmaxx(), getmaxy()); </FONT></P>6 I% o  R& l6 t2 ~
<P><FONT color=#0000ff>/* clean up */
- G5 r! _& N- Y* }  agetch();
5 n/ F! E! Y' L) nclosegraph();
, }8 V5 f, G  Nreturn 0;
! R9 u7 w9 ^# E% R} </FONT></P>/ C( ~% K# T) k6 e- V" f
<P><FONT color=#0000ff>/* detects EGA or VGA cards */
( `5 q# W, _9 s5 z3 yint huge detectEGA(void)
: X0 U6 q/ Y) M4 e{
( h6 P' m6 u9 k; i! {: {2 oint driver, mode, sugmode = 0; </FONT></P>( b1 E' Y- w& C8 |/ [# o$ w0 ~" ~
<P><FONT color=#0000ff>detectgraph(&amp;driver, &amp;mode);
  ?; o! e- Z9 x" M8 Cif ((driver == EGA) || (driver == VGA))
: r, Q' F2 n. @& Y3 T/* return suggested video mode number */
) t2 ~: l8 ^4 m5 Xreturn sugmode; 6 P, H; i- v% i: S5 B
else + Z- c6 b# ]. b$ _6 d
/* return an error code */ ( W, V- u0 R+ ^* j- d9 F
return grError; , ?( S2 T# W3 `  x0 r
} </FONT></P>
5 U3 U! y8 a5 R, ^2 a7 ~<P><FONT color=#0000ff>/* check for and report any graphics errors */ ' B- B7 r- P2 y6 O1 r
void checkerrors(void) 4 ~: H! {* u4 C1 J& R
{ ( b9 m- O& F1 z: j
int errorcode; </FONT></P>' N8 D5 Z; G! l* M
<P><FONT color=#0000ff>/* read result of last graphics operation */ / Z" Q$ s' p' M% A
errorcode = graphresult();
/ i; H4 ?5 E/ f9 I3 qif (errorcode != grOk) " P# u' J7 U- q3 ~; `
{ 6 B3 S' j& A$ h# c) m
printf("Graphics error: %s\n", grapherrormsg(errorcode)); " c+ [7 a! Y  `6 F8 N
printf("Press any key to halt:");
9 `  R6 W6 ~5 N; D1 h: O8 _, Vgetch(); $ @% I, Q# B3 q% n
exit(1);
% A" R4 W+ i& J}
$ S  ]! f7 H2 S# y4 |7 K} </FONT></P>4 b0 U! T3 Y6 u# m: _
<P><FONT color=#ff0000>函数名: installuserfont </FONT>
, q' {+ e7 s+ g5 e5 e功 能: 安装未嵌入BGI系统的字体文件(CHR) ( K1 Q( c: I* T3 z, M8 m
用 法: int far installuserfont(char far *name); - D6 o+ W8 o# D
程序例: </P>, c5 R) I3 i% d# Y0 ]. i; B
<P><FONT color=#0000ff>#include <GRAPHICS.H>
* O0 G  u6 [& ~& j#include <STDLIB.H>
! B! o1 m8 r& ?* s; Z% R  q, c#include <STDIO.H>2 W& c# R: u0 B4 G: M. r
#include <CONIO.H></FONT></P>: {9 ~5 C! b0 s6 d/ B/ O2 S! o
<P><FONT color=#0000ff>/* function prototype */
$ }' a7 k. q, Z2 T1 [5 @) Mvoid checkerrors(void); </FONT></P>% L2 O3 m* v! ^! x, _
<P><FONT color=#0000ff>int main(void) + z7 d1 C0 x" a9 ~
{ 5 |( q. f4 f! L& w. f+ i$ i
/* request auto detection */
8 h. b& \+ q. q0 _int gdriver = DETECT, gmode;
1 y" F1 j4 s& Q4 R5 _int userfont;
& y( t* M2 K' Fint midx, midy; </FONT></P>0 {3 v8 ]% [, {5 c
<P><FONT color=#0000ff>/* initialize graphics and local variables */
! m$ N+ {8 W0 \initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>; j/ o6 g- s+ s, Z; r4 d
<P><FONT color=#0000ff>midx = getmaxx() / 2;
" E* }+ t+ A7 umidy = getmaxy() / 2; </FONT></P>, B# W4 l2 M( }5 `/ W
<P><FONT color=#0000ff>/* check for any initialization errors */
3 U9 J" y8 d5 A4 N/ Echeckerrors(); </FONT></P>$ o- y" X* r% c2 g# j, _
<P><FONT color=#0000ff>/* install a user defined font file */ % `: t+ f* U7 e. R. ?# i
userfont = installuserfont("USER.CHR"); </FONT></P>1 K! S( ^' E/ J# E  `
<P><FONT color=#0000ff>/* check for any installation errors */
1 j; \- [' `* [  Z9 ~& T& W: Vcheckerrors(); </FONT></P>0 \* S2 U8 C7 d  F' J
<P><FONT color=#0000ff>/* select the user font */
- F# b9 l' Q6 Ksettextstyle(userfont, HORIZ_DIR, 4); </FONT></P>
- S) N0 Z4 u' E$ c5 j/ I* n<P><FONT color=#0000ff>/* output some text */
3 q$ i' X9 ~/ Routtextxy(midx, midy, "Testing!"); </FONT></P>
  G6 I; g' `' g: y<P><FONT color=#0000ff>/* clean up */ * @! a- t$ m. c  g& W6 V7 c. L3 I
getch(); : }- q: A( j1 V  O# @
closegraph();
: M$ S8 ?8 d$ A6 Jreturn 0; 7 Q( i0 [6 b9 X* I* d" P) h
} </FONT></P>
% E+ c/ _$ F, [8 Z  x" i& f<P><FONT color=#0000ff>/* check for and report any graphics errors */
  F, Y6 p0 P( `# _  _void checkerrors(void) 2 B1 N8 t: w+ [, d- I+ i
{
( e) j6 V- a/ ~! Eint errorcode; </FONT></P>0 k, }7 C+ Z# v
<P><FONT color=#0000ff>/* read result of last graphics operation */
) j( m" `* T% n% `% @  l- xerrorcode = graphresult(); 3 Q3 c, N5 a& N$ N) x. n$ b+ i5 j, J9 J$ ]
if (errorcode != grOk)
5 O9 U4 b. w: X" W{
( h! v( ~% l5 w. O  I2 c' Uprintf("Graphics error: %s\n", grapherrormsg(errorcode)); * n4 I7 Y; w  a& }. ]
printf("Press any key to halt:"); 9 e2 y9 j0 }( P* N
getch();
+ {0 o+ c. H0 h; j$ z+ N) b# B, s* Hexit(1);
  w- K# u5 q5 c5 x$ e5 Y$ }}   ]5 u9 V  q% b+ b& d1 V
} </FONT>: S; `1 g) G: e/ W) q% I

9 x! t& O3 |, s, o$ T6 y/ Q2 o
- M4 T2 S: j2 s</P>) H7 d  s0 n2 r
<P><FONT color=#ff0000>函数名: int86 </FONT>/ n* ]5 v( I) N0 ~# K) T# t
功 能: 通用8086软中断接口 7 C/ J8 C/ c; \+ j% z
用 法: int int86(int intr_num, union REGS *inregs, union REGS *outregs); 6 h, c0 }+ g4 C2 u- y( @+ n7 P' R
程序例: </P>9 N5 Q% c# i$ o1 `2 y2 _7 T
<P><FONT color=#0000ff>#include <STDIO.H>
$ |8 v4 n* Q5 Z0 B6 I2 ^; `2 A#include <CONIO.H>6 M, }" S# w+ ^) k  \, a
#include <DOS.H></FONT></P>
2 r" i2 W" x) c% [8 [& i; G% j<P><FONT color=#0000ff>#define VIDEO 0x10 </FONT></P>
5 c3 J( `6 D* y# O- K<P><FONT color=#0000ff>void movetoxy(int x, int y) 3 s1 N7 Z( p" `8 b, r5 X
{
( Q; ?, t( @. X. Z! c* W5 x$ {$ ]union REGS regs; </FONT></P>' ]( v4 Y( z6 C
<P><FONT color=#0000ff>regs.h.ah = 2; /* set cursor postion */
/ Y" Y7 D) _7 n# M$ N4 yregs.h.dh = y;
. W- R) Y0 e( a1 p$ [regs.h.dl = x; 3 C! B/ s$ q6 L1 c7 M
regs.h.bh = 0; /* video page 0 */   o% E- t0 Y) M
int86(VIDEO, &reg;s, &reg;s); 8 y$ y8 J" S+ U+ f- l7 g
} </FONT></P>
/ I8 W8 V: m3 L3 w- {7 O<P><FONT color=#0000ff>int main(void) . M; G  k1 q) f+ g8 A( I  Q5 ^$ O
{ 0 G% k. G- v- R+ q
clrscr(); 6 l$ n0 ~& ]" G! s. ~* X$ E6 R1 y2 M
movetoxy(35, 10);
6 x6 i' V2 A% l. Y  P* Eprintf("Hello\n");
. s6 x* `' k) ]2 Dreturn 0;
$ B, U' l0 G) V' _' u} </FONT>
5 s" m+ a4 B) a7 z' V: N* w8 \! g+ z2 P8 e& E
</P>3 [" }% O' v& j+ y
<P><FONT color=#ff0000>函数名: int86x </FONT>3 y9 `$ L- d& |  y' T& r
功 能: 通用8086软中断接口 6 a' K2 q5 q7 V! ?: ^# f
用 法: int int86x(int intr_num, union REGS *insegs, union REGS *outregs, 9 N2 `, b4 b3 ], Q" t) g8 v; o
struct SREGS *segregs); " K6 i& c+ D3 Y- A! p7 J9 ]  G
程序例: </P>8 D/ M/ h! V) N- h
<P><FONT color=#0000ff>#include <DOS.H>! {3 i# \, k; W; L6 w4 I
#include <PROCESS.H>
" O4 ]8 f- b' ?3 e#include <STDIO.H></FONT></P>! s+ [1 t+ P/ D' v, l" w" w5 g, b
<P><FONT color=#0000ff>int main(void)
; B' N3 i! Q! ^7 Z; R- P. G{
, p0 Q8 t; ~1 |" {* j+ c3 p# b" Wchar filename[80];
$ a+ w: V# D8 ~7 A' D* s# x9 ~union REGS inregs, outregs;
: X5 |- l3 }0 Fstruct SREGS segregs; </FONT></P>' H% Z" R0 e9 s9 D. @
<P><FONT color=#0000ff>printf("Enter filename: "); 1 O. @, z" r5 k
gets(filename); # g$ }) u' H5 {4 A3 N( Z
inregs.h.ah = 0x43; ! \) F$ S5 }1 f8 }# I  {/ k
inregs.h.al = 0x21; 0 Y9 v- S& H2 c
inregs.x.dx = FP_OFF(filename); - \: ]  p2 J. v- l
segregs.ds = FP_SEG(filename);
) i; a& J$ H. n1 d' ?7 Cint86x(0x21, &amp;inregs, &amp;outregs, &amp;segregs); , r6 s, m& o( u4 ~) n4 U$ }
printf("File attribute: %X\n", outregs.x.cx); 2 k. ]+ i) C6 H7 r9 Y
return 0; ! }+ E2 p# R; S
}
* h6 B4 a! d0 f0 y3 v% Q: ]3 S3 f. P8 _
</FONT>
# }' G3 M3 _/ Z5 L</P>2 c& c) C+ d; r
<P><FONT color=#ff0000>函数名: intdos </FONT># K$ k3 z" F( ^+ I( n
功 能: 通用DOS接口 ( c7 u, Q! N% X& `: W
用 法: int intdos(union REGS *inregs, union REGS *outregs); " p! Z/ G. Q' ]7 \5 |
程序例: </P>9 h5 g" _/ ^, `  F& ~1 l
<P><FONT color=#0000ff>#include <STDIO.H>$ C7 |2 w0 @0 ]8 |
#include <DOS.H></FONT></P>, ~8 _8 x! P. G0 o) I7 }
<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */ . W" j6 g  O  M* a0 s# |) D5 A
int delete_file(char near *filename)
! K  M% d& \: f& D  [{ . ?8 Q9 a/ w% I1 \) b$ a8 t
union REGS regs;
) K* d/ s; S; z* g0 Hint ret;
' a* D* c0 C0 E; a6 o6 nregs.h.ah = 0x41; /* delete file */ 7 X; E6 W0 a: [5 e4 [
regs.x.dx = (unsigned) filename;
3 o: W8 K0 Q2 P' m: ^" W0 {ret = intdos(&reg;s, &reg;s); </FONT></P>
; [$ V# F6 @! `8 h  C) i<P><FONT color=#0000ff>/* if carry flag is set, there was an error */ 5 x# h" J: r; |: e3 k* A
return(regs.x.cflag ? ret : 0);
3 Z) c" l" u6 B} </FONT></P>
/ P! N  N% y+ [! A<P><FONT color=#0000ff>int main(void) 6 }5 |3 R4 A( e! L4 r4 d: o- m
{
; R) }! u% ^! S! c" ^int err;
- x8 G& o9 g6 b" o& Berr = delete_file("NOTEXIST.$$$"); . ~8 G6 v  [8 _+ i2 y/ X
if (!err)
) a( r0 w* f) Q6 R# w6 J. _printf("Able to delete NOTEXIST.$$$\n"); ' i! V' b9 s. q1 T. e. z& e: T
else
5 \- Y3 k1 G+ J4 h  r1 F, ]printf("Not Able to delete NOTEXIST.$$$\n");
8 Y3 }, i1 c0 O* }6 q2 r: s; @3 ireturn 0;
/ m! g$ f4 t3 i+ \1 R} 4 b$ t3 C1 m" s# S( o3 T
0 R) i: ?6 ~( w* J0 N( S1 ^
</FONT>2 b5 q$ `7 M* B
</P># d; U: {5 Q" v
<P><FONT color=#ff0000>函数名: intdosx </FONT>6 T; b/ s2 g% ^8 E
功 能: 通用DOS中断接口
1 L: e# ], X/ T3 x. W6 j2 O用 法: int intdosx(union REGS *inregs, union REGS *outregs,
; {4 w1 Y0 t% V# R/ Nstruct SREGS *segregs); + [$ {9 `* X8 L5 T
程序例: </P>
: J. p) f4 ?) z- q; c$ z<P><FONT color=#0000ff>#include <STDIO.H>
2 ?0 U# C+ {: c/ E% L#include <DOS.H></FONT></P>3 B( h3 A: `9 G; e
<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */ 8 k0 \9 ]+ `' i3 |# P
int delete_file(char far *filename) ; Q7 f4 l: C$ g. I6 q  H
{
4 X% V9 G0 d! V7 Eunion REGS regs; struct SREGS sregs;
$ [' _: `! d  q9 x, Rint ret; $ t! z5 ^2 F9 F9 v9 F) ~7 A& d
regs.h.ah = 0x41; /* delete file */
/ b/ c) n6 n7 Y/ }regs.x.dx = FP_OFF(filename);
$ w/ Q7 D! I' \8 u3 h/ d: {- q+ lsregs.ds = FP_SEG(filename);
0 C) H" E) c/ D) o6 aret = intdosx(&reg;s, &reg;s, &amp;sregs); </FONT></P>
6 N( P0 q9 {: {( E2 e3 w/ p<P><FONT color=#0000ff>/* if carry flag is set, there was an error */
% a$ f  `1 J1 Dreturn(regs.x.cflag ? ret : 0); 8 d; U" E1 Q' W% D. I5 z" B
} </FONT></P>) x# Z7 {, e# {1 w8 {& T. p
<P><FONT color=#0000ff>int main(void) / l1 \8 J' L5 E0 s* @8 P% L
{ , R/ s3 X; B. W! h& _" H- V
int err; / z0 u; O3 C% H
err = delete_file("NOTEXIST.$$$");
4 C  m0 `1 F* Y% ?0 L2 S" O; pif (!err) ( O- }8 X- Q3 `
printf("Able to delete NOTEXIST.$$$\n"); 9 k5 _1 {/ @: l0 e" T% W# t' h8 X
else
6 j5 B3 N% ^* Uprintf("Not Able to delete NOTEXIST.$$$\n");
* F) x. p% o" p' preturn 0;
& A' W5 f$ A& Y% n4 g}
1 V: e8 l9 q, X  J</FONT>' j  D( Z4 w/ R1 F% y0 b
</P>) e/ R, p! R; s- t( C2 X
<P><FONT color=#ff0000>函数名: intr </FONT>
; M7 x+ P+ D' x4 I/ ~功 能: 改变软中断接口
: W$ t/ f3 B5 d9 S& r* u- I0 b, U用 法: void intr(int intr_num, struct REGPACK *preg);
1 E# g+ O  E6 F4 A; Z' p! m4 W程序例: </P>
+ `5 D2 ^- Y0 v" f, P<P><FONT color=#0000ff>#include <STDIO.H>; ?- V0 k) _. p& j8 K- x0 Z8 u) A
#include <STRING.H>- }# w: G( _5 A! l! X
#include <DIR.H>
  h$ \1 R5 R% u  }9 D; @0 B#include <DOS.H></FONT></P>0 y& I2 C* b" B9 ^/ _
<P><FONT color=#0000ff>#define CF 1 /* Carry flag */ </FONT></P>) Z3 ^; \* X" k. r8 J3 {. [/ O& s
<P><FONT color=#0000ff>int main(void) + V! ^- ], x! c
{ # b$ l: D. f) W5 v, N* b" @0 }
char directory[80];
% V  y1 Y  Q& v# Fstruct REGPACK reg; </FONT></P>" A6 O; k% j. j: y
<P><FONT color=#0000ff>printf("Enter directory to change t "); 1 a- w# k: ?/ ^# |( X" @% |
gets(directory); ) W6 Q$ `8 O, y* \
reg.r_ax = 0x3B &lt;&lt; 8; /* shift 3Bh into AH */ 3 I/ P6 I% @) V
reg.r_dx = FP_OFF(directory);
3 n% _6 d. N' h$ Rreg.r_ds = FP_SEG(directory); , F1 N8 T8 Y2 Q1 V/ f/ x
intr(0x21, &reg;);
4 k7 ~8 l1 o, X) [# x, I3 jif (reg.r_flags &amp; CF)
* B7 q6 ]2 p  Xprintf("Directory change failed\n"); # Q! T1 q2 m' F; W! S$ @
getcwd(directory, 80);   g; W" Y4 K1 ^9 |5 L) o! x
printf("The current directory is: %s\n", directory); . f* ~3 x- f- e0 J& K* t
return 0;
& P: ^0 Y7 C8 v! W# Y} 0 |) C+ W- O1 \1 L
</FONT>6 I9 N  ~. e# Z0 K# x; l
</P>, m9 S! Q0 ^* ]/ X, n
<P><FONT color=#ff0000>函数名: ioctl </FONT>
+ T* N, X" K/ K) [功 能: 控制I/O设备 3 Q. b$ X9 M: ^5 ]
用 法: int ioctl(int handle, int cmd[,int *argdx, int argcx]);
& `  N% q# R" l% P程序例: </P>
" u0 n% g$ ?2 l; L- K<P><FONT color=#0000ff>#include <STDIO.H>
$ I& }0 x4 p9 [% I  ?#include <DIR.H>
% C: \3 ]( B+ S  C  M  m3 F#include <IO.H></FONT></P>
; v( c2 t7 o" C2 }9 l8 `<P><FONT color=#0000ff>int main(void) , z! }' m2 c  ^# I4 K
{
3 Q! g4 g  |2 E6 K' Vint stat; </FONT></P>
1 R: o9 ^7 a1 d* A4 U3 [<P><FONT color=#0000ff>/* use func 8 to determine if the default drive is removable */ 5 E, t. Q4 [8 `' g. m$ {
stat = ioctl(0, 8, 0, 0);
6 z8 P# D$ o- J4 L+ iif (!stat)
6 _* o3 [, g4 {) G* J- fprintf("Drive %c is removable.\n", getdisk() + 'A');
/ T5 k! O( r6 ]else 4 M& R( e7 M, ~0 D
printf("Drive %c is not removable.\n", getdisk() + 'A'); 6 J. K6 e; @; f7 G
return 0;   K7 |3 M- n  n( G( x% ?  ]
}
% `5 y9 C# s& ]
& e: w) p1 P' l0 r" T+ e5 H; f: t7 F</FONT>) I& k9 G/ e! ^' ~' i
</P>( x8 k8 r- i) W
<P><FONT color=#ff0000>函数名: isatty </FONT>, h1 q- W( g8 Q$ L
功 能: 检查设备类型 1 d- m) x7 x: z/ v1 D. L
用 法: int isatty(int handle); " Y% f* m1 d/ ]5 C) E8 _
程序例: </P>
5 P' b6 A. z- ?# W1 c  O2 J<P><FONT color=#0000ff>#include <STDIO.H>! T5 {. M3 u' P3 a5 H; ]
#include <IO.H></FONT></P>
% N# w  g" @5 l5 |! w! D<P><FONT color=#0000ff>int main(void)
' h8 v0 r, a% h' P5 j0 p8 z4 b7 w# r{ 2 G" k& F  r* P1 O* u; b, V
int handle; </FONT></P>
  f- |) Q4 x' x<P><FONT color=#0000ff>handle = fileno(stdprn);
6 K+ W. U% I7 ?$ C1 yif (isatty(handle))
' f6 t; @! h5 _- Xprintf("Handle %d is a device type\n", handle); , a# V9 \& E( x+ o7 s$ Q  @
else
6 t" p! c  j  R  K! l* Dprintf("Handle %d isn't a device type\n", handle);
' T- b9 I9 F' v- T9 O) [7 `# preturn 0; 2 s. ?6 h  q7 u1 m; s: F7 \7 \' A; Q
}
7 ]/ d5 u$ l* [. |7 }4 R2 ^, H$ V8 L# T' ]; g9 g
</FONT>, q5 a! ]! j; R3 c! ~" a! I
</P>3 y( l) m0 }) f; }. F' p5 S
<P><FONT color=#ff0000>函数名: itoa </FONT>+ h5 N- p( g" M; |: N& e3 V6 E4 D
功 能: 把一整数转换为字符串
# R8 F. a$ k! Y! ^6 a用 法: char *itoa(int value, char *string, int radix); 1 @2 ^* S, |! g0 G
程序例: </P>+ D6 |7 Q- @- g8 X
<P><FONT color=#0000ff>#include <STDLIB.H>" _* S" f7 Q/ d- |/ O* f! _; n
#include <STDIO.H></FONT></P>
; j* S% x1 D- y: c( ?! @8 f<P><FONT color=#0000ff>int main(void)
1 g0 R( W) L7 g' |1 o0 v: i- e- R. B4 }{ * h" g. d3 I9 h7 w' D
int number = 12345; ; S3 k9 [4 d* {* V
char string[25]; </FONT></P>
6 y: d8 @! \" v5 s! U<P><FONT color=#0000ff>itoa(number, string, 10);
& s; I* {( f8 C% g  S" Z& b* |' lprintf("integer = %d string = %s\n", number, string);
4 H9 P; r5 r$ s2 f8 D/ P8 v$ B* X4 preturn 0;
3 S+ p! T( x1 e; h) z; V3 g} </FONT><FONT color=#0000ff>
' A! e# u" o) t4 p</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-4-20 06:15 , Processed in 0.287065 second(s), 52 queries .

回顶部