QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2368|回复: 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>9 Q8 K5 ^, Z0 x# m+ {) M2 K7 K
< align=left><FONT color=#ff0000>函数名: imagesize</FONT>
( Z: P6 _# {0 d1 i功 能: 返回保存位图像所需的字节数
( B/ W$ U: t# i# y( o  ?' ~0 e4 G用 法: unsigned far imagesize(int left, int top, int right, int bottom); , [9 @  E% \. j( J
程序例: </P>
  z8 G6 i2 b" H2 I) r! G* A0 X<><FONT color=#0000ff>#include <GRAPHICS.H>
* q' B7 B9 E* j+ s! O# Y#include <STDLIB.H>
4 B/ k: A4 j  x8 M( F#include <STDIO.H>9 V% D0 u( G% l  w- ~+ X. C
#include <CONIO.H></FONT></P>
' G/ x( |! t3 D7 v0 o<><FONT color=#0000ff>#define ARROW_SIZE 10 </FONT></P>: T: |9 O8 m- K* E
<><FONT color=#0000ff>void draw_arrow(int x, int y); </FONT></P>; T- i; u' q& \: t& X, I
<><FONT color=#0000ff>int main(void) 0 A% ]. S3 E: i- @
{ " H# U- H6 @4 e7 `" a: e$ y& j7 P
/* request autodetection */ 9 i+ h3 O$ d8 ]+ M6 ]
int gdriver = DETECT, gmode, errorcode;
! q$ }: q2 t. N, w; B; Avoid *arrow; 3 }8 j  `1 H( ~+ x4 t
int x, y, maxx; 3 \. J) h# P" K! d
unsigned int size; </FONT></P>
2 Q1 m+ y, Z4 u/ s# |" E<><FONT color=#0000ff>/* initialize graphics and local variables */   {" f+ x' S& P3 D3 G& i0 r
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>1 O$ f: k4 j& p: e6 T0 i
<><FONT color=#0000ff>/* read result of initialization */
+ y$ g$ Q3 E  f8 f+ yerrorcode = graphresult(); % r: b. V1 W9 \* |
if (errorcode != grOk) /* an error occurred */ % {: x" X+ n4 d9 E! H$ H
{
3 H- E% v/ _9 X+ mprintf("Graphics error: %s\n", grapherrormsg(errorcode));
3 q! e$ v+ u" G% S8 [5 X. Lprintf("ress any key to halt:"); 8 D1 {2 M/ e# }
getch(); " B5 t0 S2 `4 P- l) k4 j8 Y5 D
exit(1); /* terminate with an error code */
; Q( z# E, `. J/ ?3 |} </FONT></P>
' o5 @8 j3 i: x' `<><FONT color=#0000ff>maxx = getmaxx(); 5 t! `2 X7 D! j- N) }7 c
x = 0; 7 _9 M8 j- r( o: S: i  V3 ?, C
y = getmaxy() / 2; </FONT></P>9 O% O5 E; S1 W1 b! s
<><FONT color=#0000ff>/* draw the image to be grabbed */
' o( o1 v, o' ^, s6 o6 c7 hdraw_arrow(x, y); </FONT></P>
4 V5 P/ b% ~. ]5 i% `7 t) ]<><FONT color=#0000ff>/* calculate the size of the image */
7 `( g$ c- x4 Y# k& V2 ~size = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE); </FONT></P>
/ W8 N& |0 M4 Z$ u# {" S3 x<><FONT color=#0000ff>/* allocate memory to hold the image */ 8 u/ ^0 H+ e1 E: h  }
arrow = malloc(size); </FONT></P>
6 W6 d# v" a; Y! E3 N<><FONT color=#0000ff>/* grab the image */
% ~' X, Q; R5 \% h$ }; Qgetimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow); </FONT></P>  A$ R% d# Q( v$ ~, Z" M9 A" U  b% K. [
<><FONT color=#0000ff>/* repeat until a key is pressed */
* N! B- X9 {4 [5 mwhile (!kbhit()) 7 G; l; c2 x- p
{ : G& l# R, R0 m) R9 s8 t4 X
/* erase old image */ - J* h3 F6 ?! B# l
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); </FONT></P>$ ]/ }5 h# L' N$ G, l- u
<><FONT color=#0000ff>x += ARROW_SIZE;
( F: N! `$ N+ D* j- Oif (x &gt;= maxx) # T! x6 k* o& I0 d  `1 k
x = 0; </FONT></P>6 ?8 c3 ^0 T$ L- r) U/ s1 s
<><FONT color=#0000ff>/* plot new image */
3 t+ c4 S  f/ \2 Q8 Pputimage(x, y-ARROW_SIZE, arrow, XOR_PUT); , A8 @. u- \  U; O. @
} </FONT></P>
$ \: w* y# y% }7 W) r% u( m<><FONT color=#0000ff>/* clean up */ 1 \: O  r& [4 X+ W0 t' X+ ]3 C
free(arrow);
* U% `2 w2 K* Z, Xclosegraph(); ! Q  i8 u. O2 I6 U
return 0;
1 G, e2 D: B3 k" [} </FONT></P>
* }" E) ^9 q* Y1 g9 U! u( `<><FONT color=#0000ff>void draw_arrow(int x, int y) * k$ Y. T, I/ I6 G4 g) e- p
{ : H$ _9 |* \& z
/* draw an arrow on the screen */
' s: p+ W; p0 ?; Z" fmoveto(x, y); 6 o' v$ s3 f2 D& j! D6 ?
linerel(4*ARROW_SIZE, 0);
5 d/ ~0 q( P- h- x6 _- B% G7 U* alinerel(-2*ARROW_SIZE, -1*ARROW_SIZE);
* t. q5 ]  N) L0 A9 L" |linerel(0, 2*ARROW_SIZE);
. Y% }% Q" g/ R% A+ R- k5 Flinerel(2*ARROW_SIZE, -1*ARROW_SIZE);
# ]# ]9 N4 X. L" z8 R( q} * }$ f, g$ B! l. ?, o7 z, T: w0 \
4 r. I6 ^" [$ ~' \2 R0 B
3 Y  E  p/ Y$ x; E
</FONT></P>7 Q5 o( S+ j' o4 D: ?: ^9 W
<><FONT color=#ff0000>函数名: initgraph </FONT><FONT color=#0000ff>
/ `8 Z  ~3 Q  |" \! Y% I<FONT color=#000000>功 能: 初始化图形系统
  s/ h, y# I+ q6 w9 ]$ M  c0 O1 I用 法: void far initgraph(int far *graphdriver, int far *graphmode, " \4 v# m7 t  N, E
char far *pathtodriver); + P' B1 @( q& n, b
程序例: </FONT></FONT></P>* k. l3 s4 `3 |
<><FONT color=#0000ff>#include <GRAPHICS.H>
: q+ R1 E. w) s8 @- n! t( p0 G#include <STDLIB.H>9 X& a: B+ T$ s. p* g  C& X$ y
#include <STDIO.H>
3 x, n+ q" B+ z' j; e#include <CONIO.H></FONT></P>; m: j8 E7 r: v/ I
<><FONT color=#0000ff>int main(void)
3 O: k+ H8 X4 O( t{
  W: g) m3 T5 S/ [, T3 R# {/* request auto detection */
8 {4 Y8 F8 g& S' Bint gdriver = DETECT, gmode, errorcode; </FONT></P>
* E7 O% Q; p% M" J9 v8 Z1 _<><FONT color=#0000ff>/* initialize graphics mode */
% _5 c: ?1 |3 iinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>: N; M* e1 V* S) o! Y
<><FONT color=#0000ff>/* read result of initialization */
1 _. e4 u; {# a! ?3 Z3 Yerrorcode = graphresult(); </FONT></P>( f  I3 X4 r7 [7 M4 ^7 _7 H
<><FONT color=#0000ff>if (errorcode != grOk) /* an error occurred */ # I- Y9 }4 f5 k. K
{ 5 V0 R2 O- ?+ ~2 {$ U# D* R, @- x
printf("Graphics error: %s\n", grapherrormsg(errorcode)); # `# w) k9 H# T  F6 r  P
printf("ress any key to halt:"); & _- \: e$ [) S( }. g
getch(); & R- x, L4 x/ N/ d7 _3 w
exit(1); /* return with error code */ # Y. ?1 Z- X' L( o4 K
} </FONT></P>$ i+ Q- T+ ]+ k' @; i1 Q
<><FONT color=#0000ff>/* draw a line */ / S! a6 c' S$ s, U% c
line(0, 0, getmaxx(), getmaxy()); </FONT></P>/ x( k7 e( {8 u  |/ d! F) Y
<><FONT color=#0000ff>/* clean up */
& |1 u. E; B4 D  |, W" }getch();
5 Q# g# M4 v7 f' c; W7 Yclosegraph(); % ]- B" v8 y4 U* @
return 0; ( v- M* ^6 u9 ~' M. M
} </FONT>0 v* d% K4 R; Z5 Z* L

1 q6 b6 _' I- S! }7 x9 G</P>
. q% L, V; _% s<><FONT color=#ff0000>函数名: inport </FONT>+ e1 e$ h- _2 K" k) z3 F" l" M
功 能: 从硬件端口中输入 8 p( @0 z: U7 F& ^4 z7 a: c' h
用 法: int inp(int protid);
! O  z$ n1 G+ S0 b; y$ q: j程序例: </P>" I& r" }) ?7 T* {7 P: W; Z
<><FONT color=#0000ff>#include <STDIO.H>
2 q2 B) V1 D! c; C#include <DOS.H></FONT></P>. u( H3 c  U7 q$ N' _* K9 d1 @
<P><FONT color=#0000ff>int main(void) 3 J3 w% P8 i8 k7 I$ s7 r% Y
{ ; c" d: T/ a3 o
int result; : E' _# }0 o! N% w* U4 }. [' U) S' d
int port = 0; /* serial port 0 */ </FONT></P>
. W2 g% y6 A0 v<P><FONT color=#0000ff>result = inport(port); : C, x/ P& W5 c, j% i
printf("Word read from port %d = 0x%X\n", port, result); 6 |) ~; y; e" @
return 0;
( F4 j* h' D+ d$ p}
0 t" s) j/ @4 }1 d% R
/ G; ^/ Q# x# [8 ]. q3 R</FONT></P>2 g' c4 }2 N! S9 U4 l' i
<P><FONT color=#ff0000>函数名: insline </FONT>
) L! _! M; Z: o2 R) ~2 i) q  I9 M8 |( V功 能: 在文本窗口中插入一个空行 / E( F( y2 m* P1 }7 {" {
用 法: void insline(void);
, c) m5 R6 ]! ~! J, @7 l- o8 D* k  j程序例: </P>: w$ P% T/ ]; D4 N2 g! l9 N
<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>
' H) q/ {1 c% a% U3 u# t- d& w: P<P><FONT color=#0000ff>int main(void) 6 W4 O* n$ u- X9 T! Z
{ 6 T& {6 h& K* O" `0 g0 }$ @( W
clrscr();
" O6 f, V3 R+ Z# O0 J6 E; Ycprintf("INSLINE inserts an empty line in the text window\r\n");
# A: A$ T- x5 s; Ucprintf("at the cursor position using the current text\r\n");
1 l3 d0 Y( l: P8 S: v' Fcprintf("background color. All lines below the empty one\r\n"); ! m: [+ X& |% ]  l. K
cprintf("move down one line and the bottom line scrolls\r\n"); , z0 A, i6 H  a8 `
cprintf("off the bottom of the window.\r\n"); " Q/ g" j0 }8 w$ Y" B2 R+ P
cprintf("\r\nPress any key to continue:"); 5 ~, g, ?% Y  O* F7 Z' I
gotoxy(1, 3);
0 Y0 t# R4 U& W6 T" s- Fgetch();
/ S0 |1 F; d3 n$ ainsline(); : v2 }  W2 o3 j, d. Q  e2 k$ F
getch();
; e5 `6 c% p! r1 ]# Lreturn 0;
$ [% n) d, v( R& Y3 j1 A}
& {& L3 f% D2 l' w</FONT>
# _2 A# v3 C( E9 s
. b" L* `, o/ \! f6 ^. c# L6 ?</P>4 l" e/ |) ?( d7 T* C3 I8 b5 U
<P><FONT color=#ff0000>函数名: installuserdriver </FONT>
- `: k0 ^: W- R功 能: 安装设备驱动程序到BGI设备驱动程序表中
" [7 n/ f9 M* c- ^, u% X/ S$ C; Q1 E用 法: int far installuserdriver(char far *name, int (*detect)(void));
/ A- t- y, e! p$ ~* W. @2 ]1 A程序例: </P>3 H1 x* Z# Y) ~3 o0 I
<P><FONT color=#0000ff>#include <GRAPHICS.H>
2 j& G3 x5 v6 A9 S( q8 n( l! b#include <STDLIB.H>
2 r* n. V$ y% E9 v4 f! `5 y#include <STDIO.H>' K3 R& `: O2 D6 U0 b9 W
#include <CONIO.H></FONT></P>  C" r6 N" |$ }. [% a
<P><FONT color=#0000ff>/* function prototypes */ $ x: @6 z% u3 g6 X
int huge detectEGA(void); % I+ V. c! C- i% G1 P7 A8 B: d- d
void checkerrors(void); </FONT></P>' D+ y. {6 `6 p( a1 L
<P><FONT color=#0000ff>int main(void)
/ e/ t1 z! U+ T" a: J{ 1 @( z+ [/ {9 N1 v5 ?8 _
int gdriver, gmode; </FONT></P>$ p( Y( \* ]" T3 u( }
<P><FONT color=#0000ff>/* install a user written device driver */
; C0 C: V& b4 g/ Kgdriver = installuserdriver("EGA", detectEGA); </FONT></P>/ l3 A/ c" \( H! ^+ v
<P><FONT color=#0000ff>/* must force use of detection routine */
8 g+ E7 y1 p, x% e4 p& y0 W7 K: agdriver = DETECT; </FONT></P># V8 o# |$ z# ^0 C; R
<P><FONT color=#0000ff>/* check for any installation errors */ 1 _  f! q0 u& T7 a' N
checkerrors(); </FONT></P>
; b, P+ I& W' S8 \5 B- L: f<P><FONT color=#0000ff>/* initialize graphics and local variables */
0 f- M) ]9 M$ Q# uinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
) s7 F2 n4 p# V' N& {/ i- b<P><FONT color=#0000ff>/* check for any initialization errors */ ) y2 i7 z8 B1 K% R" v1 K
checkerrors(); </FONT></P>  q' a* Y" g) s9 u3 U) K
<P><FONT color=#0000ff>/* draw a line */
8 T# z2 V% z* O: u9 m( sline(0, 0, getmaxx(), getmaxy()); </FONT></P>, \+ R4 `1 r* B# g: n8 V
<P><FONT color=#0000ff>/* clean up */
" t. M( h8 i- jgetch();   |* O8 J) X+ r+ k6 c' @# Q4 e
closegraph();
+ h1 x9 I5 H! |% hreturn 0; - N* q2 {) ?% \) _
} </FONT></P>( J) s" p1 d' c" |; I- b1 D! Z+ w
<P><FONT color=#0000ff>/* detects EGA or VGA cards */
* H# J  c3 g" E4 Z, @  Eint huge detectEGA(void)
" \) X% m3 w4 i1 R/ w( g* P{
. H% J* s! x! `% k+ d, Cint driver, mode, sugmode = 0; </FONT></P>
. u1 D+ x9 t& S8 ?1 E<P><FONT color=#0000ff>detectgraph(&amp;driver, &amp;mode);
4 H; n. U  i4 {. d0 Sif ((driver == EGA) || (driver == VGA))
# v' |5 _, ^9 W" j4 s/* return suggested video mode number */
/ i# p- O7 c) Y, S  nreturn sugmode;
2 A) u+ |1 F0 X) delse 6 J$ {& K9 Q+ k( T9 r4 Y/ L5 |
/* return an error code */
# h& l1 P4 c; ~return grError;
9 B0 w* U% i2 @0 }3 U& w3 d6 p} </FONT></P>) ]: D$ M( J; K2 @4 y# h; s
<P><FONT color=#0000ff>/* check for and report any graphics errors */ ! }4 z  a5 S2 ?( X& V. W* N1 ?1 w+ Z( ^5 S
void checkerrors(void) $ g) {; X( T4 d3 R
{
+ Q- x3 y2 e  [2 F' C3 p/ N3 ~int errorcode; </FONT></P>. j; s% w# ]& L% I8 j
<P><FONT color=#0000ff>/* read result of last graphics operation */
& ~8 w, W, X: ~& ]errorcode = graphresult(); ) X; L* [& c5 q( O
if (errorcode != grOk)
) z) n5 v2 _4 ~2 |- a/ x{
9 K. f4 j, m) \% _  y' oprintf("Graphics error: %s\n", grapherrormsg(errorcode));
0 X+ _1 k1 g# T% x3 z/ x2 {/ g  K; Hprintf("Press any key to halt:");
( s6 j4 C$ n  M1 j0 Cgetch();
7 a4 Q2 g' t# T- S8 x. p' Q8 @8 _! Mexit(1);
+ D* _# v$ [7 C2 a  e}
" ~: R* [9 n- j3 Q% N& @} </FONT></P>
$ G0 o0 p( Z' U5 r4 B<P><FONT color=#ff0000>函数名: installuserfont </FONT>0 |% o1 B2 D6 G
功 能: 安装未嵌入BGI系统的字体文件(CHR)
' T" L, ]; f" s$ ^# V' `5 s2 S$ }用 法: int far installuserfont(char far *name);
* E/ q' g1 H* V0 w& l7 H程序例: </P>$ r8 {$ \% D. t# w4 F
<P><FONT color=#0000ff>#include <GRAPHICS.H>* u" z/ g# ~# J2 T$ \4 S! i: Q8 @
#include <STDLIB.H>
% J7 u5 ~" u$ u#include <STDIO.H>/ l& `% \: j0 g" }6 J
#include <CONIO.H></FONT></P>/ D+ Y& T4 ~1 Z% a& x" k* \
<P><FONT color=#0000ff>/* function prototype */
3 R# O9 }' Z9 k+ F* _8 q: k7 d- b  Hvoid checkerrors(void); </FONT></P>
  y$ F  |' T- |  _<P><FONT color=#0000ff>int main(void)
' B' h5 u5 \: n! [6 E8 `{ & q( P. ~* m  c0 I" R7 w
/* request auto detection */
$ V" \) q  i  ]7 l# `int gdriver = DETECT, gmode;
8 A6 G7 m3 q! `: i  Q# ]( Zint userfont; . [$ K5 c5 _2 R4 Y
int midx, midy; </FONT></P>+ z/ N+ [$ L6 L8 ~  d
<P><FONT color=#0000ff>/* initialize graphics and local variables */ 9 p8 ^7 x, ^! d" f
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
) i  M' _& ]% ^* c- e, s( F<P><FONT color=#0000ff>midx = getmaxx() / 2;
+ \7 ?6 r& I# T* }midy = getmaxy() / 2; </FONT></P>( D. {0 d5 g$ F; s, Z2 ?! e2 [4 n
<P><FONT color=#0000ff>/* check for any initialization errors */ % m" \1 F/ A& k) n+ o
checkerrors(); </FONT></P>
# G+ r" ^+ `5 J: C<P><FONT color=#0000ff>/* install a user defined font file */ $ ^* z- r" I& y/ `* N
userfont = installuserfont("USER.CHR"); </FONT></P>  l0 N& [7 h6 Q2 M# M0 ?7 X
<P><FONT color=#0000ff>/* check for any installation errors */ - }& U4 W) f0 }4 o7 l8 Y
checkerrors(); </FONT></P>
. f9 w5 u) E" t, P<P><FONT color=#0000ff>/* select the user font */ 8 m1 g' a8 f! I$ H$ r
settextstyle(userfont, HORIZ_DIR, 4); </FONT></P>
# e' D8 y3 ]# l, |3 P<P><FONT color=#0000ff>/* output some text */
% I- H- n) W8 F3 T& ~outtextxy(midx, midy, "Testing!"); </FONT></P>
8 F- z  ]! h/ h; O<P><FONT color=#0000ff>/* clean up */ 9 Z+ ?- M/ Q4 D7 g! x$ C+ h9 b2 ]
getch(); ) O' u. i/ u8 K6 U. q- }
closegraph(); % L+ N8 r8 N. {# T6 p: _" u, G
return 0;
$ u) H8 I: v: h( b( j4 E4 o} </FONT></P>% f3 }$ E% t" l
<P><FONT color=#0000ff>/* check for and report any graphics errors */
* N% P  |* H" t7 P2 W' Ivoid checkerrors(void) 0 {# P) U% n% x: T! _
{
0 S0 a  B& m9 B) K! o9 z+ Kint errorcode; </FONT></P>
6 l4 o+ H, `! ?  K/ g<P><FONT color=#0000ff>/* read result of last graphics operation */ ( y* Y. c+ R! Y) ~
errorcode = graphresult();
9 \% ^! @+ n9 f7 z, jif (errorcode != grOk)
5 e1 M7 K7 V; O6 }) w{ : f, H" ~" L  R1 Q/ i2 t; R8 g
printf("Graphics error: %s\n", grapherrormsg(errorcode));
% f6 X" k5 I. A8 ~' R4 @+ m/ tprintf("Press any key to halt:"); + ~0 \' B+ ^& Q$ ]8 i9 l
getch();
3 o  Y# |2 u6 G( P  Jexit(1); - ?1 d: B! Z3 T( j1 Y
}
  W& r  o6 O5 w  [) e6 i} </FONT>
1 e! X7 y& B# E' j, Y* Z  v# W7 ^. R9 X0 `  Q
- V/ F8 e: A! [6 i
</P>
" M, I! \; N/ A- |* N  @<P><FONT color=#ff0000>函数名: int86 </FONT>) @. a$ X% ~: ?  ]
功 能: 通用8086软中断接口 8 r' j7 |% c- t/ ?8 r2 Z
用 法: int int86(int intr_num, union REGS *inregs, union REGS *outregs); . E1 e6 S- }( c$ A
程序例: </P>0 `$ R4 B) V4 B1 a& ]0 g
<P><FONT color=#0000ff>#include <STDIO.H>
/ ]/ I& C8 E& }- x9 }2 c2 C#include <CONIO.H>$ C" g8 E( t& ~2 S/ Z8 k9 z' y
#include <DOS.H></FONT></P>9 ?) l2 n5 q1 o( T* P# n6 p/ y
<P><FONT color=#0000ff>#define VIDEO 0x10 </FONT></P>1 @% P+ W( F+ r; x  h2 C1 l& i
<P><FONT color=#0000ff>void movetoxy(int x, int y) $ ?/ x# n1 c, t; V1 Z6 _: E1 N
{ $ p7 B7 v9 [  A. C+ x  _+ a. R
union REGS regs; </FONT></P>3 ?( B0 R- ?, E/ \
<P><FONT color=#0000ff>regs.h.ah = 2; /* set cursor postion */ ; Q7 T4 {; s/ D2 K% |; T$ c& l7 n9 t7 q
regs.h.dh = y; . e0 l" F  d7 W- o
regs.h.dl = x;
! d. K' V9 Z3 D0 iregs.h.bh = 0; /* video page 0 */
8 N; ?! S7 B5 y. ~' _int86(VIDEO, &reg;s, &reg;s);
4 ~, z. q7 ^7 H' t} </FONT></P>5 |  q. k5 |# a# H' L" V6 d
<P><FONT color=#0000ff>int main(void)
* c# I% s9 v0 q/ Y& U{ ! p1 w3 C: e" e
clrscr();
2 V* a" c) q4 g! z5 [6 Amovetoxy(35, 10); : T$ }6 o% e" z. x+ W; D
printf("Hello\n"); % P- x& u' f7 i  C9 R4 Y
return 0; , T: e1 K' @* Q% U
} </FONT>9 J% t/ Y/ ^% h' Q9 Y' v
; a5 d$ f0 d7 g8 |- N
</P>0 x( i* v8 h  x  {3 W( L2 Q% J
<P><FONT color=#ff0000>函数名: int86x </FONT>  X6 O" H6 }7 {5 b9 z6 x2 A
功 能: 通用8086软中断接口 8 a/ [! ?0 [1 z9 n6 h
用 法: int int86x(int intr_num, union REGS *insegs, union REGS *outregs, 0 ?0 X+ ?( I2 l# R' P
struct SREGS *segregs); " t7 s! f3 v3 x
程序例: </P># L% w4 U+ O' }2 J
<P><FONT color=#0000ff>#include <DOS.H>
, ~9 R. q3 h/ S- f$ J#include <PROCESS.H>
5 b& e" t7 A4 e* G, H- e: J#include <STDIO.H></FONT></P>
' ]3 E9 @8 M) H" J& v' n<P><FONT color=#0000ff>int main(void) 4 D( B$ V8 l' Z" k
{
* q. u6 C( g+ o- ], A+ i& ]char filename[80];
8 B' J* I3 C; M  R  E4 B0 P/ ^' t4 ?union REGS inregs, outregs; 0 n8 d$ `* J8 Q/ q6 Z, B" W
struct SREGS segregs; </FONT></P>
6 O& \3 D1 G  G/ A<P><FONT color=#0000ff>printf("Enter filename: "); . F& n5 i( A. R1 P2 W- P3 G
gets(filename);
) h2 z3 q* p3 z) ~7 g/ j9 f8 A; Yinregs.h.ah = 0x43; 3 T5 \; f4 @+ r- x6 m3 L
inregs.h.al = 0x21;
, r" i* `! A0 A/ ?6 c; }# p4 v5 B. Qinregs.x.dx = FP_OFF(filename); + g3 J9 z, C, D6 r$ x& G0 T  x  B
segregs.ds = FP_SEG(filename); 0 [+ R4 Q( f, `! Z4 [: o. ~
int86x(0x21, &amp;inregs, &amp;outregs, &amp;segregs);
" N' b0 `* s) l  w0 r7 g; Eprintf("File attribute: %X\n", outregs.x.cx); 6 |8 ^+ p7 C1 [# k
return 0; 1 f4 A% F* P# P1 i
}
8 V/ C1 H& N9 C% g" e- t, k4 t/ y* J& I" h5 v
</FONT>9 _* F8 S6 z( c  ]
</P>
  R3 k, u* r- T" ^+ n/ `<P><FONT color=#ff0000>函数名: intdos </FONT>
. j" o+ c. P6 d, J6 K功 能: 通用DOS接口 : r/ h7 T* @$ {$ w) ?3 [
用 法: int intdos(union REGS *inregs, union REGS *outregs); ( l: _. u- K! b+ K
程序例: </P>
" q2 G% i$ w5 N& G& _; X0 s<P><FONT color=#0000ff>#include <STDIO.H>( D% E/ p2 o5 T# f3 t
#include <DOS.H></FONT></P>
$ d0 P# z! {+ F; ?6 j6 Y' _! I. M<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */ . K* G( \/ M1 u$ J6 c
int delete_file(char near *filename) ( g  n  O- b1 X4 W
{
+ K, A8 ~8 m% j7 J, `: runion REGS regs; 8 y' f9 E% r1 c5 k! @& P. t# r
int ret;
* w3 s5 ?, t. k8 [  ]. n* E" pregs.h.ah = 0x41; /* delete file */ 7 ^% Q4 g$ `* V
regs.x.dx = (unsigned) filename;
; g  P7 a- R  x: p4 V7 C8 uret = intdos(&reg;s, &reg;s); </FONT></P>+ @5 V: \, |; ]/ m$ P
<P><FONT color=#0000ff>/* if carry flag is set, there was an error */
5 x- O) p' R6 ^return(regs.x.cflag ? ret : 0);
+ b2 ~6 }3 b# |; X} </FONT></P>% n6 W! k' V& Q! F9 t( X) e( Y+ x
<P><FONT color=#0000ff>int main(void)
. ^9 V( L3 ~1 Z" z! `) `{ ( c# Q& A- s: n, W
int err; / O2 @! X  @, M3 C& A, F2 J1 j
err = delete_file("NOTEXIST.$$$"); 2 w+ {8 r$ ?2 ~  U
if (!err)
/ @2 R% D) L$ U4 Bprintf("Able to delete NOTEXIST.$$$\n"); 4 L( [  u  g$ e3 a
else
2 e0 l2 J; S) o* ~% K3 C1 a3 q, Iprintf("Not Able to delete NOTEXIST.$$$\n"); $ ~5 z1 `( D- k! r0 U  U
return 0; / i  L: R% b* N: m" ]. k6 J8 Z
}
1 y: j5 q3 `' Z; S
: W% E  ~$ R5 _) U  P</FONT>
8 J$ K# D) `0 Z5 }1 d+ o& e$ m</P>
; @. c. A; e: x3 _% ^7 t# l2 T<P><FONT color=#ff0000>函数名: intdosx </FONT>. ], A1 ^8 |' [, ~
功 能: 通用DOS中断接口 , [/ L- V6 Q$ ~$ T) i& f  n
用 法: int intdosx(union REGS *inregs, union REGS *outregs, . S6 D; E$ `5 y, H
struct SREGS *segregs); 8 y/ {% ]% B# s0 K$ c* F
程序例: </P>. j7 x' M& M' M. h
<P><FONT color=#0000ff>#include <STDIO.H>
+ h; `. ^' H% P4 n" u3 t" |9 t#include <DOS.H></FONT></P>
- @- S$ m3 s; f' |- w% |9 A2 N<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */
$ o. Q% A3 D; ]4 ?9 uint delete_file(char far *filename)
+ r  b0 x( h% `( E$ a0 \, \{
' T# \: L7 l! p6 i/ v2 S! m6 p8 Runion REGS regs; struct SREGS sregs;
: U' L/ Y9 R% a3 {0 Kint ret; , U' }" S; s; ?: [- l* r# X9 v
regs.h.ah = 0x41; /* delete file */ 7 M# e( x; P0 g/ @
regs.x.dx = FP_OFF(filename); 1 Z* A* t3 ^' O: c; C5 S
sregs.ds = FP_SEG(filename);
4 l0 @) j# c" j- W$ `ret = intdosx(&reg;s, &reg;s, &amp;sregs); </FONT></P>" B: f$ V0 H4 E+ I2 N" Q
<P><FONT color=#0000ff>/* if carry flag is set, there was an error */
; o1 d0 i9 S6 a& W! Z. Q4 Hreturn(regs.x.cflag ? ret : 0); - _+ y. Y: j( N( ^! U2 D
} </FONT></P>
/ ^  A5 y0 [, R2 z) }: l/ R  n  [<P><FONT color=#0000ff>int main(void)
2 V3 K5 n$ m( U# T{
1 Z3 f' @1 o' A; dint err;
+ p8 q$ S% n/ {) H; w. herr = delete_file("NOTEXIST.$$$");
" L5 k& ~$ e/ I" |0 S  uif (!err)
3 j1 l$ a5 k, A( Tprintf("Able to delete NOTEXIST.$$$\n");
+ |& v  J3 A6 \- relse 6 e% Z2 j' I( J. s
printf("Not Able to delete NOTEXIST.$$$\n"); 8 Z) d  g% c" H9 I5 `* s
return 0; 3 P9 [  C0 n6 e( f4 @+ P8 L
} 9 d6 o# z/ _, b7 y
</FONT>
3 u2 b7 a* ^& w: f4 R4 k, i</P>3 `; ?1 d) j* J7 B  n, Y
<P><FONT color=#ff0000>函数名: intr </FONT>
( |* ~" v- v; Y) i4 g1 W6 L( }功 能: 改变软中断接口 4 z( B: @6 ]1 Q7 l: s2 G' E) M
用 法: void intr(int intr_num, struct REGPACK *preg);
+ i7 S: B( V/ q6 w7 g; F程序例: </P>
( ?4 B, e! W- T: \( F& ^- h<P><FONT color=#0000ff>#include <STDIO.H>
8 U' f# v; f' ~  B+ O, P#include <STRING.H>
: _8 v  [" h" o1 f#include <DIR.H>
6 @$ V; r) R6 ?  U+ z( g* H! E#include <DOS.H></FONT></P>5 m7 B, i7 \1 D) I
<P><FONT color=#0000ff>#define CF 1 /* Carry flag */ </FONT></P>
1 G4 @3 x* R3 u# }5 D6 \" Y2 \- i0 C<P><FONT color=#0000ff>int main(void) , [: W  d: H8 ?4 e$ d% G( F& n
{ 3 [/ `* i2 I3 ?0 y4 w7 k: N3 G
char directory[80]; / ]$ r' o. ?$ I. Z* }' @
struct REGPACK reg; </FONT></P>
9 g) I$ i5 M" V. u- v* d<P><FONT color=#0000ff>printf("Enter directory to change t ");
+ E8 p/ b& b( P9 J/ Q( z% Hgets(directory);
; Y% M- }0 h' Preg.r_ax = 0x3B &lt;&lt; 8; /* shift 3Bh into AH */ 6 y7 w4 w9 e; E4 N6 o
reg.r_dx = FP_OFF(directory); 7 Z$ v  |& g3 e" n8 K8 u# b+ X2 o
reg.r_ds = FP_SEG(directory);
- K. E; d# X8 D/ J( Kintr(0x21, &reg;); 2 w+ s' _4 O! N4 L+ z2 |" y! i' ~9 w& H
if (reg.r_flags &amp; CF)
* X3 q: b7 k6 W1 Cprintf("Directory change failed\n"); : e8 t) W5 {, c9 ]/ K
getcwd(directory, 80); 2 U$ Y( }& u/ X3 N3 }2 U5 O5 f9 {
printf("The current directory is: %s\n", directory); - c: J% s4 s& C$ R; ]
return 0; - ?- j& ^7 x; Z
} : {+ `3 O) M' j, r) x
</FONT>1 C( ]. m/ Q& K( E
</P>
, B* S# S2 c  `2 W( p9 m" t( L: P<P><FONT color=#ff0000>函数名: ioctl </FONT>9 s3 o+ |$ Q% c1 a
功 能: 控制I/O设备 : `; l, c) m' E# K' E" d+ |" x$ F
用 法: int ioctl(int handle, int cmd[,int *argdx, int argcx]); * z2 v' O" j+ S9 {
程序例: </P>, e! B3 V' A5 M; _' w  o5 x7 C
<P><FONT color=#0000ff>#include <STDIO.H>
/ T( F0 L0 n4 {9 N3 |  O3 Q#include <DIR.H>
9 Q7 H, _- ]9 H#include <IO.H></FONT></P>
( o5 a' q$ b8 F. D<P><FONT color=#0000ff>int main(void)
2 w1 C2 X9 {1 `* s8 b: L% s{
; H1 r6 z3 U+ @) jint stat; </FONT></P>: H& A4 c% Q$ s% W8 o' }
<P><FONT color=#0000ff>/* use func 8 to determine if the default drive is removable */
. M9 P1 ^( q2 E3 q3 X: p- ystat = ioctl(0, 8, 0, 0);
  Z- g" [. b% k: Hif (!stat) 7 g* H' }( W8 a" ?( ]5 a8 {2 @
printf("Drive %c is removable.\n", getdisk() + 'A');
# L6 d$ _$ ~" g8 ~  T% T5 H4 |; a! f4 Celse + g, ]# u& o; x' |7 d. r: @
printf("Drive %c is not removable.\n", getdisk() + 'A'); , N" a& i, K- Z0 }) {
return 0;
$ @3 j8 _, M1 }: q. y1 b} - h( t5 ]. R9 t+ t5 ^+ z' D( R

7 v4 f2 F: h! e</FONT>- c6 T& r& a+ X, O5 |
</P>
$ a9 X: u0 S# y/ G7 N( G<P><FONT color=#ff0000>函数名: isatty </FONT>3 V( o/ G. c% F, M/ }
功 能: 检查设备类型 5 o7 f& H; x4 T8 p
用 法: int isatty(int handle); 1 ?, @) ]9 Z$ ?3 X* I
程序例: </P>
3 C$ y/ R' C, N, j9 v<P><FONT color=#0000ff>#include <STDIO.H>
: R# x, H9 x! g; D" ^#include <IO.H></FONT></P>
3 _, y: f9 ~4 r<P><FONT color=#0000ff>int main(void)
, S5 x- c4 Y/ }  e{ 8 l! {7 w& e4 K. v/ x5 @
int handle; </FONT></P>
- k4 |( E7 e( \; g5 O1 l* T<P><FONT color=#0000ff>handle = fileno(stdprn); 7 @: P1 Y7 ]9 V3 N
if (isatty(handle))   O% S* J! ^6 U' U2 j! Y; X
printf("Handle %d is a device type\n", handle);
/ Z4 W5 a8 ]( I. e$ F/ J, Selse 6 T2 g7 m* S8 a& e
printf("Handle %d isn't a device type\n", handle);
! [% ~3 g3 Y+ y: T' s# [return 0;
( T* P* X% Q& w} 7 U7 C) e8 X! u. u! |

4 R  p: q; r; t% I7 S8 _</FONT>1 b. X1 F1 \. B* _. P) r: {% i
</P>0 A1 `! ~4 C7 m$ E
<P><FONT color=#ff0000>函数名: itoa </FONT>7 ^3 d9 V: R) D& Z4 l7 M
功 能: 把一整数转换为字符串
( }5 ^$ a; y% o& ?  `4 {5 F用 法: char *itoa(int value, char *string, int radix);
* U) r3 @6 H5 M* r, F$ l( |1 |程序例: </P>6 r7 c7 b1 v. f
<P><FONT color=#0000ff>#include <STDLIB.H>: R( A3 J( v2 O4 i
#include <STDIO.H></FONT></P>; o# `5 ^+ }3 K$ r8 T5 y2 e- {
<P><FONT color=#0000ff>int main(void) ( n9 G3 ^4 M+ d9 v, _; s0 f
{
4 P2 y5 d5 R$ f( T5 ^5 mint number = 12345;
# C! y/ ?2 V" Y& h6 ochar string[25]; </FONT></P>! A: q# l5 v) Z( C+ W( J' ^4 D
<P><FONT color=#0000ff>itoa(number, string, 10); : Y- u7 v( |' [: ~' q. N
printf("integer = %d string = %s\n", number, string);
* W) u  d8 B) v) h# m8 n( y: Dreturn 0;
, [$ l8 b' f+ M) }} </FONT><FONT color=#0000ff>) N7 B& `4 k% }
</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-7-21 02:48 , Processed in 0.478052 second(s), 52 queries .

回顶部