QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2339|回复: 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>
  t* {& ?1 j% N- G- D" y< align=left><FONT color=#ff0000>函数名: imagesize</FONT> 0 n2 \  Q- a2 f$ r7 p
功 能: 返回保存位图像所需的字节数 8 g$ i/ Q3 _$ b: d* G7 F7 q
用 法: unsigned far imagesize(int left, int top, int right, int bottom); 4 `0 W& l! N" F
程序例: </P>0 q. t% X) a5 Z, Q) I7 M
<><FONT color=#0000ff>#include <GRAPHICS.H>
% R3 L4 W5 \0 _3 s#include <STDLIB.H>
. {  x: {9 H# @0 ^9 Z#include <STDIO.H>" |/ K* V& J7 k9 i! a) Q! W
#include <CONIO.H></FONT></P>
$ x9 T5 b# g# u0 G. t7 t* B<><FONT color=#0000ff>#define ARROW_SIZE 10 </FONT></P>
$ h4 S# g  ?( a! ]  t) E# C, q<><FONT color=#0000ff>void draw_arrow(int x, int y); </FONT></P>- U) G& u7 G; T
<><FONT color=#0000ff>int main(void) 1 H+ h. x8 s' j
{
' j7 b& G: v- G/ d9 s: b  K) c! V/* request autodetection */ 4 m3 {+ \2 _5 t. K
int gdriver = DETECT, gmode, errorcode; 1 W, W; d; Q) B, c# `; [
void *arrow; " l6 `  u  O+ @  U8 o5 w
int x, y, maxx;   M- {' ?8 K( \* m6 z  Q4 c
unsigned int size; </FONT></P>
7 f, i9 {! [, i( I  T<><FONT color=#0000ff>/* initialize graphics and local variables */
2 @" u  c0 i, T4 q; ?initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
& M+ p; ?- @# y<><FONT color=#0000ff>/* read result of initialization */ 8 Q0 j6 Z  _( A$ ~' o9 Y) y+ S- m
errorcode = graphresult(); . V1 H' K# N1 G  w! X
if (errorcode != grOk) /* an error occurred */
( Y# Y, U) }, U- [& V{ ; X. n  B) x; Y' ~: N* [! p
printf("Graphics error: %s\n", grapherrormsg(errorcode));
1 u% y" E. ^. v0 W. Jprintf("ress any key to halt:"); 0 k- C& W$ @" T5 e& r0 G
getch();
/ N% D+ u7 ~; o- ~; zexit(1); /* terminate with an error code */
: `: F- k$ o( T& ?/ z% ~1 q} </FONT></P>
- X# G( W5 t4 [# H* |<><FONT color=#0000ff>maxx = getmaxx();
& h& `0 u( a4 C  \1 }0 m. i' x/ P) [x = 0;
7 R+ @* Z; B" I+ {5 Wy = getmaxy() / 2; </FONT></P>$ Z$ K! \- l5 d0 c' T
<><FONT color=#0000ff>/* draw the image to be grabbed */ 9 {; R$ [$ }! \
draw_arrow(x, y); </FONT></P># ?2 p, g1 ?" q  V' g
<><FONT color=#0000ff>/* calculate the size of the image */
# Q! J3 ~* @( c; M2 @5 R7 J& jsize = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE); </FONT></P>3 U- ]8 f, ~3 y0 s" U6 H1 o
<><FONT color=#0000ff>/* allocate memory to hold the image */
) }7 D1 ~( i( W  F0 |1 Qarrow = malloc(size); </FONT></P>$ G2 a$ l' e5 T
<><FONT color=#0000ff>/* grab the image */ 4 B0 f. g% _/ Z8 ?0 {+ l
getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow); </FONT></P>9 ?* z& g- G8 y( x) t
<><FONT color=#0000ff>/* repeat until a key is pressed */
  E: `3 T( P  G, awhile (!kbhit()) % c3 M' _, z7 b
{
4 P; r4 c7 h8 A/* erase old image */
" R2 g. F, U$ u. g3 Tputimage(x, y-ARROW_SIZE, arrow, XOR_PUT); </FONT></P>, t. |. w# ], G  l; h" q" R% n  Y
<><FONT color=#0000ff>x += ARROW_SIZE;
2 W3 `8 s4 E1 x: Zif (x &gt;= maxx)
! K; H, H- s3 {9 l( Fx = 0; </FONT></P>
3 S* g- z+ x( x9 c0 w( s<><FONT color=#0000ff>/* plot new image */ , G$ A6 S, \( r- e$ s" L
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); " Z, X( _9 l8 O
} </FONT></P>- ~4 e, X4 L) t) Z, A9 s
<><FONT color=#0000ff>/* clean up */ * `& b. `3 j2 n6 t0 N" u' n2 v
free(arrow);
6 H' S2 [' V) u8 [' m( P* Cclosegraph(); 4 }: g9 _- K7 y. B
return 0; 0 L/ S* ^+ M  S/ o2 M* [! D3 I
} </FONT></P>7 J# @& e% L+ W4 Q
<><FONT color=#0000ff>void draw_arrow(int x, int y) 0 T( g  H0 d! H5 q# c
{ + P0 B( O9 \" Z% `1 q
/* draw an arrow on the screen */ ! I( T9 O7 D0 j" x8 a& \
moveto(x, y);
, ~2 s  X8 m& s5 G/ v8 E% u! c9 Blinerel(4*ARROW_SIZE, 0); 2 L7 S7 @5 z% q0 _
linerel(-2*ARROW_SIZE, -1*ARROW_SIZE);
9 u! c  }7 t! y$ klinerel(0, 2*ARROW_SIZE);
; c+ I$ r2 e: g7 K6 J& L+ Nlinerel(2*ARROW_SIZE, -1*ARROW_SIZE);
) X* f+ P2 J( Y, J# [} 6 i% n, T4 Q0 F

; N) y6 }) _8 N6 q' ~) P5 S  C
" W9 i1 h% V" g3 ~5 b# g, F</FONT></P># Y) u9 S. X' y1 }, x2 k
<><FONT color=#ff0000>函数名: initgraph </FONT><FONT color=#0000ff>* U6 o7 A- k( N/ Z3 ]; a& n7 s
<FONT color=#000000>功 能: 初始化图形系统
; I1 V+ A, d2 B4 G+ K用 法: void far initgraph(int far *graphdriver, int far *graphmode,
6 _3 p2 A+ P6 Ochar far *pathtodriver); ' u( k9 X% X" n
程序例: </FONT></FONT></P>' x# l. V; J9 s) r' X
<><FONT color=#0000ff>#include <GRAPHICS.H>0 k. {7 m7 j* K5 r* f
#include <STDLIB.H>
& V" M# E: d% a/ M5 e#include <STDIO.H>
  x! s% |. M. F( Y) v& I" ~#include <CONIO.H></FONT></P>
* p$ V& Z% n, V0 O7 g: u1 g<><FONT color=#0000ff>int main(void) 6 _6 h/ R7 o. K0 C
{
% U- e3 S0 @1 B( @; v* C0 b/* request auto detection */
6 i; E3 M& v' c' q, j; Cint gdriver = DETECT, gmode, errorcode; </FONT></P>
+ T& @9 F/ }8 ?% H/ s7 O! T( `- E<><FONT color=#0000ff>/* initialize graphics mode */ & \* Y, H/ `: c, V8 P0 K
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P># q- ]1 @2 a) K( f: p% Z9 L
<><FONT color=#0000ff>/* read result of initialization */
' y& L  P1 Z" u3 R5 W& gerrorcode = graphresult(); </FONT></P>
3 Z+ X7 V0 d! }1 j9 k; o. m/ E<><FONT color=#0000ff>if (errorcode != grOk) /* an error occurred */
1 K! ~7 p5 m! S{
0 `4 N1 G) k# K  qprintf("Graphics error: %s\n", grapherrormsg(errorcode));
- F1 ^8 l( b& B0 n  |printf("ress any key to halt:");
6 u) g. L$ c4 T4 M7 c( S2 w4 xgetch(); 0 R5 Z4 ^/ {1 D5 L
exit(1); /* return with error code */ 2 a8 p5 O8 y; `
} </FONT></P>  E) i3 O9 B1 }# \2 @
<><FONT color=#0000ff>/* draw a line */
" |5 C# K: d2 H  j- T7 _: e2 Rline(0, 0, getmaxx(), getmaxy()); </FONT></P>
% I% k7 U; W) e<><FONT color=#0000ff>/* clean up */ + u5 y, H+ x% w2 c: Y) m
getch(); - l  }. ~+ A& m& x8 s
closegraph(); 5 u( q0 L/ d! {9 O6 ~# v/ _; \
return 0;
, h9 C) n) b0 {5 Q7 D4 Q} </FONT>( ^( C" U. g7 J, V8 M; {
0 i# B: Y' h) i3 u" f6 a5 y% ]% I
</P>
+ c) F$ R% g: J! a<><FONT color=#ff0000>函数名: inport </FONT>
) y6 B' @$ k; Y% A2 x$ |. a. b7 p功 能: 从硬件端口中输入
% P* {* G4 E) C8 B) L用 法: int inp(int protid);
# z% `2 H& O; W, e3 b3 J; Y程序例: </P>
% U$ j1 I- r) |7 c: x* n; j<><FONT color=#0000ff>#include <STDIO.H>0 Z  z2 @4 L+ Z% E5 [7 F. M7 {
#include <DOS.H></FONT></P>4 M5 D- n0 ^0 J
<P><FONT color=#0000ff>int main(void) ! M2 [1 y. b3 U: j& S  `( @, A
{ % U# K2 Q, v" ]/ a( K
int result; ' i, r* m6 q  Q( x7 ]6 O
int port = 0; /* serial port 0 */ </FONT></P>
2 o) X/ {& S6 O! o: k<P><FONT color=#0000ff>result = inport(port);
1 {/ T: z, l3 @& T. R5 Jprintf("Word read from port %d = 0x%X\n", port, result);
6 W6 u1 e  }2 A/ g9 |2 ]5 O3 X% Zreturn 0; - B$ x& o! E" @" U6 V% Z% \
}
; K7 F) g; h3 [7 ^: u, {$ `3 M( u# X" @7 @* k! S! z# T
</FONT></P>( ?4 G) M! P8 N+ L# b- B  }! E
<P><FONT color=#ff0000>函数名: insline </FONT>9 o, ^, B5 M& r3 u' S1 q  W. |/ v
功 能: 在文本窗口中插入一个空行 ! M5 V- k# J4 {7 P# d
用 法: void insline(void);
6 x- T, Z2 o1 G% f程序例: </P>
! [, ?* e8 `8 I' O+ e8 }<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>
$ t6 B- e  J5 N  L2 M<P><FONT color=#0000ff>int main(void)
- i: u3 t8 P7 T{
3 [/ T& d1 G% p3 o' s) o3 P3 \clrscr(); / Z+ k9 c0 e$ M/ a4 B
cprintf("INSLINE inserts an empty line in the text window\r\n"); ' r  x2 d( |9 H5 C
cprintf("at the cursor position using the current text\r\n");
. U* E4 K3 J+ n# {) dcprintf("background color. All lines below the empty one\r\n"); " X2 W4 h& k1 l
cprintf("move down one line and the bottom line scrolls\r\n"); : u' I: Y$ f$ @& @) C7 M' n3 J
cprintf("off the bottom of the window.\r\n");
6 b6 ]# }* Q1 f% R; j0 E$ f' C: ^cprintf("\r\nPress any key to continue:"); 8 k* S8 _+ u2 P+ m: ?! Z
gotoxy(1, 3); 5 h7 q& S5 t  n( t3 q: I  N
getch(); ; E+ Q  C* G# p' y# w, {2 ^
insline(); * I: \" Z% N' p" a: F. A$ Z
getch();
3 z8 k6 E. U# |/ d: c- F/ freturn 0;
% z4 x0 v5 T, {& [7 R} - Z6 I8 K" u! S/ [9 g3 e
</FONT>) B$ d/ x: N; z; x+ B5 }

! v/ g( f) m, `( B7 B9 p8 C  L</P>
2 U  F4 t; S3 M) X) i5 t3 t& `7 w<P><FONT color=#ff0000>函数名: installuserdriver </FONT>& T' M2 v! T2 g! e
功 能: 安装设备驱动程序到BGI设备驱动程序表中 - B. f7 w% T2 ?! @7 r
用 法: int far installuserdriver(char far *name, int (*detect)(void));
( b9 {6 z! N! F% W8 n3 Y程序例: </P>, B. P# a& R  N1 T. [
<P><FONT color=#0000ff>#include <GRAPHICS.H>0 C( F# b7 D4 |
#include <STDLIB.H>
# v6 ^6 b& P5 C0 H( i2 y! c. T/ v7 _" I#include <STDIO.H>6 v9 f8 U( |2 j- {5 T1 }3 `  p
#include <CONIO.H></FONT></P>
& n: d. T2 [9 ]& K* c6 A<P><FONT color=#0000ff>/* function prototypes */ ) k- ~4 N* Y( s. U
int huge detectEGA(void);
/ q9 r  b0 ?" H! bvoid checkerrors(void); </FONT></P>
4 f' i" Y( h9 s# m$ P  U; R<P><FONT color=#0000ff>int main(void)
6 W* s7 c. t9 ?$ V$ [; Z6 }8 s{
0 ~' H6 @; D* L1 O, D+ j5 Gint gdriver, gmode; </FONT></P>7 \- }( |9 t$ [  {
<P><FONT color=#0000ff>/* install a user written device driver */
1 A/ B0 y% G) kgdriver = installuserdriver("EGA", detectEGA); </FONT></P>$ j: v, W6 q; a& [2 b. H- |
<P><FONT color=#0000ff>/* must force use of detection routine */
7 C9 e9 F& X( l3 f. ~. Igdriver = DETECT; </FONT></P>% U' H4 I! q) l3 [2 ^! {: _0 M
<P><FONT color=#0000ff>/* check for any installation errors */
, G6 T/ I* R. jcheckerrors(); </FONT></P>
# \! ^4 i' D9 ]$ J4 }+ s6 ]<P><FONT color=#0000ff>/* initialize graphics and local variables */ $ n' x( M0 S- n- {* B  O! r, `; C( B% C5 _
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>2 L- X. \4 |' p0 ~
<P><FONT color=#0000ff>/* check for any initialization errors */
3 J& i. Q* b1 R$ u7 Q" xcheckerrors(); </FONT></P>
4 J. O9 B6 p0 a# j' Y<P><FONT color=#0000ff>/* draw a line */ 5 ^! u2 A- [# j8 Q3 ~8 U% ]. _
line(0, 0, getmaxx(), getmaxy()); </FONT></P>
; Y& {7 G1 X3 R" F<P><FONT color=#0000ff>/* clean up */
3 S4 q1 P. q. L5 \getch();
3 S$ M! ~* T4 y, l' ]# tclosegraph();
9 g7 e1 d1 `, D/ d3 }/ sreturn 0;
/ Z2 {9 h8 G# G} </FONT></P>
7 Z0 v; O  B) |' `& I3 G<P><FONT color=#0000ff>/* detects EGA or VGA cards */
; [1 G# p) E7 ]( [int huge detectEGA(void) & F5 u+ d9 o2 D; I5 k. @( p
{ $ P0 w5 k6 H( Q- G4 D
int driver, mode, sugmode = 0; </FONT></P>
- M7 D, ~" w6 V8 Y, p1 J' X<P><FONT color=#0000ff>detectgraph(&amp;driver, &amp;mode);
# v1 y" {8 V' N% D9 l  i( bif ((driver == EGA) || (driver == VGA))
. r+ c' Y  D, M/* return suggested video mode number */ ! h1 ?  W, Z3 }; B' n; `' Z
return sugmode; ' ?" v# H, q/ @
else
" f* k9 q8 h! l7 h2 @/* return an error code */
: f# L3 b' i6 w! Z$ ~- h, Xreturn grError;
: T) I  ^$ E4 s% Z8 ?4 Y9 t0 A7 U} </FONT></P>& X% ~% s5 ^+ ]- M# l/ d
<P><FONT color=#0000ff>/* check for and report any graphics errors */
! x' }8 M+ s. @* W: J7 p' ]+ uvoid checkerrors(void)
4 _- x* o, J. K: t0 e6 r{ 2 p! u4 R5 N9 w+ A5 J& _
int errorcode; </FONT></P>
+ L$ o* i/ `1 C0 z3 Z* [( W<P><FONT color=#0000ff>/* read result of last graphics operation */
" J- ~; S. r8 C3 [" Perrorcode = graphresult(); 2 ?' C5 W: b: l
if (errorcode != grOk)
9 I2 y% ?' I, [0 o4 y{ . Z2 v" K9 _6 Y9 u
printf("Graphics error: %s\n", grapherrormsg(errorcode)); 3 W4 }6 G, c# q3 R' j7 A! J& S7 ?% ~" @
printf("Press any key to halt:");
* G  R. Y) b4 s* F7 y: e+ Tgetch(); 7 m( e& A6 Y5 K; j, t8 ?% d% E& |
exit(1); . K) z2 d3 C+ t" v6 ~* e% p
} ! M) W& X, L  R8 R- \* T
} </FONT></P>5 }: `- D- {4 x
<P><FONT color=#ff0000>函数名: installuserfont </FONT>9 F* s4 O' d0 h# }3 T9 p
功 能: 安装未嵌入BGI系统的字体文件(CHR) ' d, Q2 Z; V8 }
用 法: int far installuserfont(char far *name);
4 ~! l7 A' K, N( h程序例: </P>
8 u3 F3 c8 I( Y<P><FONT color=#0000ff>#include <GRAPHICS.H>
% a$ {: K8 n" s, q#include <STDLIB.H>
  k, a# C7 R. G& T5 m9 `- R#include <STDIO.H>3 f* r. m3 `$ ^
#include <CONIO.H></FONT></P>
- W/ f4 K. d- _% a9 V: a<P><FONT color=#0000ff>/* function prototype */
0 `6 v; ]8 ]7 {void checkerrors(void); </FONT></P>
1 ?+ p1 x" l7 }<P><FONT color=#0000ff>int main(void)
8 ~# P& k5 x8 G{
6 r6 B- ]9 ~  T/* request auto detection */
" m7 D) O; m$ C6 `; hint gdriver = DETECT, gmode; 7 ?% S  T' ^- i) }" n$ @
int userfont;
5 {7 X* t/ [  @5 [, p, d% }; c0 Tint midx, midy; </FONT></P>
% W- O4 W7 x! h+ k# m/ P<P><FONT color=#0000ff>/* initialize graphics and local variables */
' p" }7 N0 Q( [( Y3 _7 f4 |initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
' r9 C# N7 z  P# v# b0 v; b& f9 J% _<P><FONT color=#0000ff>midx = getmaxx() / 2;
, `5 {3 H+ s* `% ]: W4 q9 Hmidy = getmaxy() / 2; </FONT></P>; T- s4 n4 D5 t7 [' E
<P><FONT color=#0000ff>/* check for any initialization errors */ ( C6 e8 w5 H; g
checkerrors(); </FONT></P>' h- c! C6 i: x8 J# ^1 z
<P><FONT color=#0000ff>/* install a user defined font file */ : ~9 O4 V  _: x& n  T. D  `
userfont = installuserfont("USER.CHR"); </FONT></P>  Q5 _, F( F$ }7 f
<P><FONT color=#0000ff>/* check for any installation errors */ 0 N1 T7 J+ o3 a+ \0 d! Q3 w+ r: U
checkerrors(); </FONT></P>
  C& a  Q( l- O- ]! ]" Y<P><FONT color=#0000ff>/* select the user font */
* c7 ~' z/ V* r/ ~: s# v" H5 p: ]+ msettextstyle(userfont, HORIZ_DIR, 4); </FONT></P>4 v$ {' @3 D3 v4 E" d
<P><FONT color=#0000ff>/* output some text */ * Y6 B7 W# E* }( [) ~
outtextxy(midx, midy, "Testing!"); </FONT></P>; H9 w5 j: s- U: y
<P><FONT color=#0000ff>/* clean up */
! S# b/ p3 h% Q# d8 {5 Vgetch();
! ?3 ]' p/ O6 F" m7 j( K  Lclosegraph();
7 j3 \* ~2 L  ]2 |3 F3 Mreturn 0; + B2 m8 |% S$ j# Y# f7 ~
} </FONT></P>
: M' L4 Q7 Y/ w<P><FONT color=#0000ff>/* check for and report any graphics errors */
4 J8 J2 z  Z5 K. k; `void checkerrors(void)
* b3 W0 o' O; R3 z{
$ ]4 o6 U$ X" M. @8 sint errorcode; </FONT></P>
* Y! ^2 E3 v& X; l7 ^% H9 X<P><FONT color=#0000ff>/* read result of last graphics operation */ 3 i0 K0 k6 z6 B5 L) m- a
errorcode = graphresult(); 1 y1 J4 p1 Y; \% ?" {8 @
if (errorcode != grOk)
! b. y' j$ z5 X! M: l8 p$ m" L{
/ `0 e: U* z( jprintf("Graphics error: %s\n", grapherrormsg(errorcode));
9 j7 t: T3 ]0 p+ X9 f7 ]6 k& Bprintf("Press any key to halt:");
) V7 B) P! H1 a" egetch(); 5 \9 R6 _. p! d: b4 p; q
exit(1); ; k3 ^% t' Y' b+ c0 Q
} / N. y. a* \% }- {% f' \
} </FONT># \6 r4 S3 c4 O  c  d
& \6 m- l# W3 d0 v8 y
" W8 i3 u  o6 `+ E
</P>
1 F/ \; |! B: v' I0 b<P><FONT color=#ff0000>函数名: int86 </FONT>0 i  _4 |2 [: o/ e6 R
功 能: 通用8086软中断接口 9 o- L3 h3 D3 _, B4 S  I: A# f1 ]) M3 U
用 法: int int86(int intr_num, union REGS *inregs, union REGS *outregs); " R2 i6 R8 G" e+ X
程序例: </P>
, v8 h" D' N3 V: _<P><FONT color=#0000ff>#include <STDIO.H>
2 p" H' i. H: i& ^$ E#include <CONIO.H>! g% c# D6 c0 g. |- V6 {" P
#include <DOS.H></FONT></P>; H' Y( d- n# O2 N" g- T
<P><FONT color=#0000ff>#define VIDEO 0x10 </FONT></P>
6 g- n( V% O/ j8 L<P><FONT color=#0000ff>void movetoxy(int x, int y)
0 k) @) o1 S9 I0 p  v{ . i) m* y( [4 Q8 \( z) s
union REGS regs; </FONT></P>5 ~1 O3 Q" W( Z$ X
<P><FONT color=#0000ff>regs.h.ah = 2; /* set cursor postion */ ' L' C! R) i8 Z8 h0 a$ f5 X/ I& _
regs.h.dh = y;
- n; s# @1 `2 C% L# }0 Z0 c! iregs.h.dl = x;
0 q, @6 F) B3 P. p9 H' ^regs.h.bh = 0; /* video page 0 */
; Q$ j6 e' \* J2 w0 R4 w& }1 X$ Y) kint86(VIDEO, &reg;s, &reg;s);
' P" T: q2 r9 m8 _. \} </FONT></P>) S: J; `7 F, k
<P><FONT color=#0000ff>int main(void) & \$ H, z6 \7 E
{
, q8 j3 E/ U- A% h) sclrscr(); ( S& ?( P! e$ ?+ ]4 R/ x  W
movetoxy(35, 10);
* v  I$ S$ a2 Bprintf("Hello\n");
0 B7 E. M: v, f" freturn 0; ! m+ L1 c4 w: M9 o1 ]
} </FONT>/ Q& X8 u( E- @* N& J" D5 E

* e% Q3 ]6 m5 `</P>! k9 z0 O, e# R$ r/ ?5 t
<P><FONT color=#ff0000>函数名: int86x </FONT>
3 q0 g4 i/ F& s) n功 能: 通用8086软中断接口
2 P/ P7 a4 J( _* M6 d; i: Q用 法: int int86x(int intr_num, union REGS *insegs, union REGS *outregs, 0 Z1 E; \$ l9 V
struct SREGS *segregs); & \3 A8 {. I- I+ P8 e+ E
程序例: </P>* g; v. c' C5 f* i
<P><FONT color=#0000ff>#include <DOS.H>( c! T( G3 {) o0 B  r3 k
#include <PROCESS.H>
  C7 U4 u* y# Y% m4 N" ]' D5 J#include <STDIO.H></FONT></P>0 [$ ~4 s" ~% h
<P><FONT color=#0000ff>int main(void)
3 a! R1 q0 ^& r+ U- `' M4 w{
! J- l9 o: J. m, X0 h, s# Y) Rchar filename[80]; 6 V* L2 T& z+ X/ Y
union REGS inregs, outregs; + p  j  u$ w) H$ H; K: }/ U
struct SREGS segregs; </FONT></P>: X6 q+ n( }% v
<P><FONT color=#0000ff>printf("Enter filename: ");
" z! c- K/ b( a$ U- m  @. Z! Mgets(filename); $ E2 W- i/ H! `) ~' j: E1 U
inregs.h.ah = 0x43; 7 @/ z, W/ T0 r
inregs.h.al = 0x21; . M' Z. ]3 ?+ L; U7 g/ ^1 X7 s
inregs.x.dx = FP_OFF(filename); , K2 M  p+ ^( B+ M- O# o: I
segregs.ds = FP_SEG(filename);
3 o% u) x$ Y6 z, Y* F& Gint86x(0x21, &amp;inregs, &amp;outregs, &amp;segregs); 8 L  u( a4 f# F& ]- \( \! P
printf("File attribute: %X\n", outregs.x.cx);
7 }$ M( L& q' j- kreturn 0; / r4 b- {+ K- k0 s4 L
}
5 ^. i* r, i* `& P9 |! ]
9 J7 b" Y( [: N3 s/ s+ V</FONT>
& h. h, @* m' Y) p/ u</P>
( Z' r+ V: u- b, d( `$ r<P><FONT color=#ff0000>函数名: intdos </FONT>3 @/ @$ x* g  P9 R3 ~- B  j7 p* }0 x+ {
功 能: 通用DOS接口 $ z" x. Z7 v3 I1 B- Z7 G
用 法: int intdos(union REGS *inregs, union REGS *outregs);
5 a+ E: ~% R5 ^, q0 e程序例: </P>0 N7 W; w0 I. E; V" u
<P><FONT color=#0000ff>#include <STDIO.H>3 q6 |& _; F$ i  C" }/ ~
#include <DOS.H></FONT></P>, r7 w" H) t3 u
<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */
5 A, R: ]; e$ ^/ b4 L1 }/ Uint delete_file(char near *filename)
+ Q/ q% r5 I, G( ?* b' w& z{ / m7 R6 L. Q  i: y3 p
union REGS regs;
- v+ [! L; r9 V+ ^. @" }int ret;
" L. x- f2 r. u' g! t9 }regs.h.ah = 0x41; /* delete file */ 1 |6 Y. H/ u; X& D+ i5 I# g
regs.x.dx = (unsigned) filename; * b% F3 y& y! |5 {- p
ret = intdos(&reg;s, &reg;s); </FONT></P>
. }  v5 a' q/ ]+ O& g+ b<P><FONT color=#0000ff>/* if carry flag is set, there was an error */
. F$ j5 S& O0 _  q  f! a& rreturn(regs.x.cflag ? ret : 0);
; n8 `# f1 I! X# I2 |/ J) x$ T$ b} </FONT></P>
/ e3 y& t" n: L* f3 v<P><FONT color=#0000ff>int main(void) 2 K) \# c4 C$ }% Y3 f( p& u# f
{
" o: b! @- ?4 n3 G$ u/ O" Uint err;
- h4 }) g: K# J, @7 {err = delete_file("NOTEXIST.$$$");
3 n( @& k5 k$ w: R6 l0 mif (!err)
! K/ P+ h$ f+ Hprintf("Able to delete NOTEXIST.$$$\n"); 7 b. N! X0 ?$ c6 z) d- Z6 W1 |
else 2 z6 h+ ^( S. a. s8 H
printf("Not Able to delete NOTEXIST.$$$\n"); " v' u5 Q* v: U% N
return 0;
# x: y2 w0 L" ?9 O  a/ b, v) h) Q}
4 r$ r4 q/ _. A3 \; Y) R; i. V7 K4 [
</FONT>
. g3 |  m3 L1 R! I" h</P>. y$ L0 w% A; b/ p- \2 }) R  r
<P><FONT color=#ff0000>函数名: intdosx </FONT>* r2 T3 W- j  O* T: W
功 能: 通用DOS中断接口   h# h' ?0 n" J+ e3 a3 S
用 法: int intdosx(union REGS *inregs, union REGS *outregs, & W0 z' y/ N- R5 ]: t
struct SREGS *segregs); % h- l1 M, {% r! M7 |/ n
程序例: </P>
" M, o2 `6 ?6 S<P><FONT color=#0000ff>#include <STDIO.H>
$ z0 j- O, A' _/ _6 b* V; u% G6 x# p#include <DOS.H></FONT></P>
  i6 Q8 R, T* v) Z9 o7 w* E# |<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */
$ \) u! @5 V, a* S5 E( Dint delete_file(char far *filename) ; q) h1 g$ O& Z$ Y
{ # p8 m. h- p* q* ^- D/ |4 V
union REGS regs; struct SREGS sregs; # i* m% a, B1 v$ K
int ret;
( s8 v/ g' \: q  F% ?; m- Dregs.h.ah = 0x41; /* delete file */
3 L4 W; {  t0 Sregs.x.dx = FP_OFF(filename); . ~+ P& Z$ Q4 n+ e
sregs.ds = FP_SEG(filename); 3 y0 o) N; G; C' x8 `: W7 O
ret = intdosx(&reg;s, &reg;s, &amp;sregs); </FONT></P>3 y* U- s2 R2 C9 j/ `4 k  |1 d
<P><FONT color=#0000ff>/* if carry flag is set, there was an error */ 7 X) E- M8 V/ ^1 ^
return(regs.x.cflag ? ret : 0);
" e! }" w8 c6 A$ R" j/ y} </FONT></P>" u/ n5 P8 U' z& P$ @7 f0 k: E  ^" S, |
<P><FONT color=#0000ff>int main(void)
+ y6 b% w/ o" {9 M! y# I# M{ & Z0 h, b+ L, L
int err; + A! T/ B/ `: L5 q
err = delete_file("NOTEXIST.$$$");
7 n0 ]6 O' H6 cif (!err)
3 H% Q: v9 I1 V4 b2 O1 lprintf("Able to delete NOTEXIST.$$$\n"); 6 d8 ?. a% }% D  x" z; j1 k" Z
else
$ E8 E1 S. j% F, ^printf("Not Able to delete NOTEXIST.$$$\n");
, Y& {5 }3 @2 R, Vreturn 0;
& B% o% p: f8 B6 N0 d0 P; e}
& {1 K1 g5 y/ G9 c& L; ]4 ?5 T3 H% r0 R</FONT>4 w6 J% Z* v; q
</P>- \' ^0 T  P# T" _  j0 q
<P><FONT color=#ff0000>函数名: intr </FONT>9 _; h0 f  i4 F
功 能: 改变软中断接口
8 c! V& t1 P9 e3 r) X用 法: void intr(int intr_num, struct REGPACK *preg);
5 `; `( V9 z9 p- }) k程序例: </P>
  J4 Z# m' J0 T. @<P><FONT color=#0000ff>#include <STDIO.H>
7 |2 \2 S. g4 K$ s3 V#include <STRING.H>6 w0 C) G. M, |( f" c# }7 E
#include <DIR.H>
- _) v. x) n3 b8 p4 d9 I4 R#include <DOS.H></FONT></P>4 g: {# W" _7 M3 v
<P><FONT color=#0000ff>#define CF 1 /* Carry flag */ </FONT></P>/ G- i; m8 Q) j
<P><FONT color=#0000ff>int main(void) ' p! r4 _% |* k4 V9 e) n
{ 2 ]% y, F) v: P$ h
char directory[80]; 7 w  f' i+ d% {9 V+ q  {
struct REGPACK reg; </FONT></P>
( W5 S. h9 r, f5 s<P><FONT color=#0000ff>printf("Enter directory to change t "); ! K( p. h9 q0 }" p0 w
gets(directory);
9 V4 H4 g9 n, n- v# I  ^reg.r_ax = 0x3B &lt;&lt; 8; /* shift 3Bh into AH */
, a2 X! g/ s, O! @$ Q" o: Jreg.r_dx = FP_OFF(directory); 4 y, c' Q* t4 W1 L( Y+ w: T2 P
reg.r_ds = FP_SEG(directory); * b6 X" E8 z8 m6 v" ~0 ~
intr(0x21, &reg;);
! e7 W6 y; X$ V4 @if (reg.r_flags &amp; CF) 0 d3 v1 y( C6 d6 g, Z5 H+ [
printf("Directory change failed\n"); ; V: [# Y: E1 J$ U! M6 y; p1 n
getcwd(directory, 80); + D2 g; S( g( x8 U
printf("The current directory is: %s\n", directory);
$ D. u, O' }' {1 ]9 U- w  ?8 Mreturn 0;
5 K. X. J0 f# ]- G}
: ~& f6 o: H  L) U7 @</FONT>- I- v8 y4 P* A+ n
</P>( L: A: H- I: @+ o
<P><FONT color=#ff0000>函数名: ioctl </FONT>2 ]% C: W: L! S8 w  r2 ^' `9 n
功 能: 控制I/O设备
; s, X; a4 Y, W0 p/ G) k9 B* O用 法: int ioctl(int handle, int cmd[,int *argdx, int argcx]);
4 C4 @% s( q! w程序例: </P>
3 c9 N; r' n4 A<P><FONT color=#0000ff>#include <STDIO.H>
+ V3 [, ~! Z/ q' r7 m3 n  a#include <DIR.H>
' o  Y/ g, g1 K6 H6 l8 z#include <IO.H></FONT></P>: ^: d9 _. z9 G  S1 s
<P><FONT color=#0000ff>int main(void) : y* g! ~# Y8 A' I
{
$ D5 ~) Z7 R$ P. `# p2 z' f9 l; iint stat; </FONT></P>
) W1 H" l! ~8 o# o: |, H% i<P><FONT color=#0000ff>/* use func 8 to determine if the default drive is removable */ 3 i+ Y/ M8 u7 I# K0 x: N
stat = ioctl(0, 8, 0, 0);
7 J) J& a* D( r2 a% O! l* uif (!stat)
2 Y; D! |7 P  W1 yprintf("Drive %c is removable.\n", getdisk() + 'A');
" Y) z$ |* _& Z# ^" x# Y8 |) L' Jelse 5 O9 V. M/ `# \  h0 T, Q$ y0 [5 Q
printf("Drive %c is not removable.\n", getdisk() + 'A'); . [; R0 r5 x& [: E* N) E1 q
return 0; ( Y: w  g$ a% R
}
1 C: a+ x$ N( b. m( q+ w- n2 U* q9 D( r. n& v( l; e$ l
</FONT>/ w; ^8 `5 p: Z/ L% x" N
</P>
+ H* \! \$ `9 o5 K5 v* E, `: Z& q<P><FONT color=#ff0000>函数名: isatty </FONT>
+ O0 ?" S! [0 {4 h1 E5 O功 能: 检查设备类型   S: W: B5 ]% u. d8 B! i7 `# ~" T4 L
用 法: int isatty(int handle); # D0 V5 _" L6 I' h
程序例: </P>3 r9 \! S) _% [4 e. k$ E
<P><FONT color=#0000ff>#include <STDIO.H>
7 k  |* Z+ W$ I#include <IO.H></FONT></P>
$ ?# W% v& C+ u# v: h<P><FONT color=#0000ff>int main(void) 1 D$ b- L; ?) \  f+ [# i! i; E
{ # @; z- T; a4 e7 f& c$ l
int handle; </FONT></P>
' w2 }9 P. ?9 o) O/ ]7 g<P><FONT color=#0000ff>handle = fileno(stdprn);
& i. H4 ]' ]: F5 i/ Kif (isatty(handle))
7 ^4 V: P0 H6 t& W# ~6 Zprintf("Handle %d is a device type\n", handle); 3 z: P- z" O: a) i. Z/ [0 w
else
+ g5 W. y4 }$ }6 t3 L; _% ?printf("Handle %d isn't a device type\n", handle);
6 h. `" k% j9 @$ }# A* O& {return 0;
% Z% }4 ^6 Z9 Z  e, [! i}
- w  W& u9 M# M
5 U. C7 B$ ]0 l" V% i( ]</FONT>& f# o0 X% e; [/ h0 H
</P>* y# U# ]7 R# x7 a2 o4 ~% S
<P><FONT color=#ff0000>函数名: itoa </FONT>
, ^5 O/ R4 B$ [' w, c: F1 h功 能: 把一整数转换为字符串 6 _8 g" k, V* z% O
用 法: char *itoa(int value, char *string, int radix);
9 A6 o  b9 K0 n程序例: </P>$ m3 E, G  V1 d# _( _
<P><FONT color=#0000ff>#include <STDLIB.H>* m3 @, N1 [! F3 |  t, `2 D& V
#include <STDIO.H></FONT></P>
5 D/ }9 d/ J; D; d<P><FONT color=#0000ff>int main(void)
) }. g# w4 |- Z* E- ~& U. h. F{ 1 @# `3 B1 L- i: a
int number = 12345; ; {% g* f& w# c. _4 X7 g. k8 v
char string[25]; </FONT></P>) Y6 H- [+ D- A; t
<P><FONT color=#0000ff>itoa(number, string, 10); 6 Z4 j, g* a  g6 l
printf("integer = %d string = %s\n", number, string); 1 o, a2 G/ ^3 {7 H( y, q
return 0;
0 R! i8 [! n% k3 v1 q} </FONT><FONT color=#0000ff>
" g9 I- o% _) k+ J6 \! f6 S. ~</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-21 06:37 , Processed in 0.500220 second(s), 51 queries .

回顶部