QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2354|回复: 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>
! E3 {) B, \1 m+ p0 T< align=left><FONT color=#ff0000>函数名: imagesize</FONT>
( `& Z. Q7 x+ ^6 s3 o+ p+ s功 能: 返回保存位图像所需的字节数
/ H  w. U+ g# L: g# r! X. l3 i8 M; R6 t用 法: unsigned far imagesize(int left, int top, int right, int bottom);
8 D, T5 Q/ K% n- Z* k程序例: </P>
0 X1 M9 v; \; n& b<><FONT color=#0000ff>#include <GRAPHICS.H>: O+ ]+ Q, O* g7 d
#include <STDLIB.H>3 F8 v$ W+ Q8 z4 J
#include <STDIO.H>2 q& u+ W- d0 i* e; \5 M1 ]
#include <CONIO.H></FONT></P>
6 E( B. Z7 n8 C" w6 @- R) ~<><FONT color=#0000ff>#define ARROW_SIZE 10 </FONT></P>- t! k& |, C+ m+ b+ W! q  L1 b, g: B
<><FONT color=#0000ff>void draw_arrow(int x, int y); </FONT></P>
# Q1 l/ r$ i) k8 W<><FONT color=#0000ff>int main(void)
6 v4 A( K, P" Q* @{
3 i1 k9 u8 o+ {7 s2 y+ @2 U: l- j/* request autodetection */
, |' P% n. x6 d9 S2 gint gdriver = DETECT, gmode, errorcode; ' \* y: `6 h5 ^5 ~
void *arrow; 9 x0 A4 L0 M7 C2 c: \( Z$ K5 a
int x, y, maxx; : {; n, {. R% c
unsigned int size; </FONT></P>
+ x; f: g, C3 e<><FONT color=#0000ff>/* initialize graphics and local variables */ + E# I0 Z1 Z0 T% a- [- A
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>& C7 U+ r8 P! b3 b" h
<><FONT color=#0000ff>/* read result of initialization */
+ t& ]: i3 H# Z, C* M) b% ierrorcode = graphresult();
7 ~) Z7 K8 Q6 F) s; m" q/ Qif (errorcode != grOk) /* an error occurred */
8 V- J) s. F; [  `7 o5 [{ 7 M8 v8 N- u+ n! F6 m2 @& Y- d
printf("Graphics error: %s\n", grapherrormsg(errorcode));
; [9 u. r$ m8 C+ Q2 ]$ Iprintf("ress any key to halt:");
  W. i7 R' g% Egetch(); $ r$ ]4 w6 L0 W$ _/ n
exit(1); /* terminate with an error code */
* x& `% |. [, ]7 s} </FONT></P>
! T1 h1 W5 m" n! Q/ E" v1 L$ n<><FONT color=#0000ff>maxx = getmaxx(); 3 l. F9 m6 a+ d' ]- W; U* }7 ^
x = 0;
2 @" ?- a5 C, l; Q& z% [' o" M( c# Ry = getmaxy() / 2; </FONT></P>
$ I& C  p2 l% h4 [+ X0 ^<><FONT color=#0000ff>/* draw the image to be grabbed */
* D" Z% ~8 Z. k) @draw_arrow(x, y); </FONT></P>9 e1 Z" I1 u# ]
<><FONT color=#0000ff>/* calculate the size of the image */
0 M9 t, `7 {3 Q! Q* o7 csize = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE); </FONT></P>
" ?) I, g* T5 j3 l' O+ Y<><FONT color=#0000ff>/* allocate memory to hold the image */
$ C" [/ ?) W9 l- x5 Q$ q$ uarrow = malloc(size); </FONT></P>
" K" r( v9 X* P4 ^<><FONT color=#0000ff>/* grab the image */
3 j+ `5 B( J/ H* ugetimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow); </FONT></P>
" Y% k3 G& n  n1 X- V<><FONT color=#0000ff>/* repeat until a key is pressed */
8 C" P) n5 u3 }% H$ Rwhile (!kbhit())
- B4 c: ?) @2 ]+ @{ ) E  g" V6 J- Y  E# c
/* erase old image */
4 M& Q, y5 w3 |# [1 [0 p" i$ eputimage(x, y-ARROW_SIZE, arrow, XOR_PUT); </FONT></P>( @* M# O* Y  }' }: ]) K
<><FONT color=#0000ff>x += ARROW_SIZE;
' K1 \& V1 P; p- Q9 X0 {- {if (x &gt;= maxx)
- S$ j7 }& j4 n' i+ qx = 0; </FONT></P>
% K' P' G7 b# l" N: n<><FONT color=#0000ff>/* plot new image */ - d! O5 R. Y7 O" u2 M7 e
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); : h, ~% K' s% P
} </FONT></P>* [4 [/ U8 s- W
<><FONT color=#0000ff>/* clean up */
& [! E  A  j5 o$ Tfree(arrow);
5 R+ A2 [& v" n' I! Kclosegraph(); ( \" L( G' t% p1 n, M
return 0; & k% L2 ]% }, T' @" k
} </FONT></P># G8 G4 z$ ~: `0 Q7 x( L; K4 G
<><FONT color=#0000ff>void draw_arrow(int x, int y) 5 N( ?% `+ q4 `0 A
{ " g4 f1 b2 X- T* l
/* draw an arrow on the screen */
, S2 ?; u  D+ X+ Xmoveto(x, y);
4 }2 X1 ]+ U2 zlinerel(4*ARROW_SIZE, 0);
  e0 f) U% }5 llinerel(-2*ARROW_SIZE, -1*ARROW_SIZE); % S5 Z9 U8 I  O# |0 Y) O: u: s
linerel(0, 2*ARROW_SIZE);
% H' C2 W1 B# h" [( q8 g' Slinerel(2*ARROW_SIZE, -1*ARROW_SIZE);   q( R  Q7 f' T% H2 j1 }
}
1 h; A# o% I7 J" ]& |
: ~3 T& n2 N; }- V8 X0 I# t# m+ m2 b! ^7 `! r3 i7 I
</FONT></P>& V! J0 p5 P/ L3 o8 M0 @
<><FONT color=#ff0000>函数名: initgraph </FONT><FONT color=#0000ff>7 E  S+ J7 U; O$ @, x- U; W
<FONT color=#000000>功 能: 初始化图形系统 6 O1 l3 k( q5 G4 b/ Z. ?0 k
用 法: void far initgraph(int far *graphdriver, int far *graphmode,
- P& N$ `0 n6 w0 Cchar far *pathtodriver);
& |1 ?  y# i3 ^程序例: </FONT></FONT></P>( y4 d. E: C0 x- ^1 P+ n8 P0 ~
<><FONT color=#0000ff>#include <GRAPHICS.H>
. Q9 |  ?/ v8 @9 {#include <STDLIB.H>2 F5 B) e# X% r' o
#include <STDIO.H>
) U- M; C( H9 v#include <CONIO.H></FONT></P>6 t" |1 B+ w6 T8 g: C
<><FONT color=#0000ff>int main(void) 5 C0 r/ a1 }2 @" [1 X1 D9 `8 W# k9 B
{
9 A+ @: @5 F" U) o* J  k* C% {8 Y/* request auto detection */
6 x9 y- k. n/ q8 {int gdriver = DETECT, gmode, errorcode; </FONT></P>" X5 P8 [3 Y8 w+ C$ u& t
<><FONT color=#0000ff>/* initialize graphics mode */ : j4 F, V0 _0 C* {0 v! S
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>/ O  Z- n2 d  r, V2 c+ D
<><FONT color=#0000ff>/* read result of initialization */ 2 \( v5 @; J. b8 F4 x# s
errorcode = graphresult(); </FONT></P>2 q$ A+ v3 h. ]& |
<><FONT color=#0000ff>if (errorcode != grOk) /* an error occurred */
/ H6 J- x  T* ]% i2 V9 g{
! Q( n- ~3 X7 Q: S* v) ]printf("Graphics error: %s\n", grapherrormsg(errorcode));
1 U. V+ W9 h, \( Y- [printf("ress any key to halt:");
1 m6 T8 H8 S4 V6 L0 Dgetch();
  J4 r8 U' l, k8 A+ w( S1 B% s+ |exit(1); /* return with error code */
" L1 X  x7 v, r# c4 ?" s  E+ M} </FONT></P>9 u8 y! f6 C" L( a$ n! s
<><FONT color=#0000ff>/* draw a line */ 6 @) n8 `. d  ^
line(0, 0, getmaxx(), getmaxy()); </FONT></P>1 X) c: K( h( h8 M
<><FONT color=#0000ff>/* clean up */
1 m# I( r+ {% o0 mgetch();
. v9 Q- D9 y  Rclosegraph(); 2 A: ]& A* n7 k% x
return 0;
* i6 O$ E2 `7 r' q2 a/ z* C} </FONT>2 x; T( X3 }" K* G' G  T  _
, m/ c, B' L# ^) P" w
</P>4 k/ u) ]; V9 A' y! r
<><FONT color=#ff0000>函数名: inport </FONT>
9 u' F4 t6 {5 F功 能: 从硬件端口中输入 # m! J. p7 v" B! N: t) ?" |
用 法: int inp(int protid); ' t7 F8 d) M) f, C/ e9 w9 f# [
程序例: </P>
8 x/ c' W: q6 q<><FONT color=#0000ff>#include <STDIO.H>2 N$ M! j5 E0 f
#include <DOS.H></FONT></P>- A8 ], Z! o+ }3 w: x
<P><FONT color=#0000ff>int main(void)
/ z" M9 `# C( ?5 h{
  Q. z3 T3 ]9 fint result; 8 s: y1 G1 W7 b4 s
int port = 0; /* serial port 0 */ </FONT></P>$ }6 D& X" ?3 r- q6 z9 C
<P><FONT color=#0000ff>result = inport(port); 1 k" ^, @% e; t  ?6 j! g2 V, H
printf("Word read from port %d = 0x%X\n", port, result);
: A7 \9 ^  l" i4 Sreturn 0; $ x# I3 y+ S) z/ V7 z
}
$ v% o  j5 X4 D1 x
% T8 j7 z* ^, G  n& V9 w</FONT></P>$ \6 V3 i2 _2 F" Q  G. X
<P><FONT color=#ff0000>函数名: insline </FONT>  s- _/ u7 D0 b
功 能: 在文本窗口中插入一个空行   g/ i% f2 u6 n7 Y) o) l1 l) J' @# |
用 法: void insline(void);
) s- M/ }2 K) E1 w; X7 J1 o; p程序例: </P>
1 n0 x& s/ H% ?& a; f2 @<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>1 Z3 N7 H, Q5 k* C5 Y
<P><FONT color=#0000ff>int main(void)
2 q0 x- ]2 L1 [{ : i9 @) Y+ G$ j8 B, {" x) o8 L
clrscr(); 9 F, R5 O' x5 P8 M6 b4 @, E  E
cprintf("INSLINE inserts an empty line in the text window\r\n"); 1 S. Y" ~3 }  X6 `, M, x  {3 r
cprintf("at the cursor position using the current text\r\n"); ( v$ l2 n& b, B' y
cprintf("background color. All lines below the empty one\r\n");
8 L' ?# e  @. d! u+ c% ^# ycprintf("move down one line and the bottom line scrolls\r\n"); # g" w% L! _% M" K9 I
cprintf("off the bottom of the window.\r\n"); # u8 t/ G  r3 _% A3 _" S
cprintf("\r\nPress any key to continue:"); 9 t" T; W7 A" F2 Q7 w- D
gotoxy(1, 3); . a6 U' L7 ?- a
getch(); . T* v: o) S. W
insline();
4 \, n+ U- J& s+ Zgetch();
4 {! I9 \8 S5 \  ?6 {, ~+ W  Oreturn 0;
: |0 ?8 }$ B3 t) Y: c1 b} - ?  w8 p5 j! d4 a
</FONT>
7 R4 L2 s4 Q' n3 ?6 K; ^  H  N8 T
9 D8 e0 h% ^6 o</P>
0 V* a. o. v4 x% s3 `( l<P><FONT color=#ff0000>函数名: installuserdriver </FONT>4 _# X7 j9 o0 y: w7 I
功 能: 安装设备驱动程序到BGI设备驱动程序表中
& ^3 l% J  j# S% |9 R, h用 法: int far installuserdriver(char far *name, int (*detect)(void));
* G5 |1 R' C- L" c& ^/ h$ I程序例: </P>/ D- D! u9 ]. l* ^( N
<P><FONT color=#0000ff>#include <GRAPHICS.H>
; `2 R4 ]3 q9 t$ K8 d#include <STDLIB.H>) K' b8 H! @1 m- t  s! E0 d& I5 U
#include <STDIO.H>
5 H) _' _* Q) K% p  z" s#include <CONIO.H></FONT></P>
/ X# ^$ l7 a8 z. L<P><FONT color=#0000ff>/* function prototypes */
& ?6 @4 u2 K' S; ]int huge detectEGA(void); 6 ~7 a# t! s1 S1 \( V! a" h
void checkerrors(void); </FONT></P>
9 v$ k5 c1 o7 v4 F8 l, }) U- Z<P><FONT color=#0000ff>int main(void)
# k: M- h) e9 d, R# j{ 7 i2 ~2 w0 u9 N2 a; C
int gdriver, gmode; </FONT></P>
9 Q# s: `! ]! J3 d$ f/ R' v<P><FONT color=#0000ff>/* install a user written device driver */ , V3 M1 `' }# t2 V$ O
gdriver = installuserdriver("EGA", detectEGA); </FONT></P>
/ S4 _: M; P+ ]0 W<P><FONT color=#0000ff>/* must force use of detection routine */ - J2 s7 b4 ]. R( P0 U: l
gdriver = DETECT; </FONT></P>3 Q" q7 t  w  A6 x' g/ w+ |
<P><FONT color=#0000ff>/* check for any installation errors */
! j" M2 T, C) ~6 h! Q+ Wcheckerrors(); </FONT></P>+ {- F2 G1 e7 B" y
<P><FONT color=#0000ff>/* initialize graphics and local variables */
- v1 ~" d3 u5 k! e; V9 xinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>6 l; |4 g" x  Z8 [
<P><FONT color=#0000ff>/* check for any initialization errors */
$ i1 B, r4 c  Y6 f7 Scheckerrors(); </FONT></P>
/ S* ]3 m7 H4 m<P><FONT color=#0000ff>/* draw a line */
7 j: h) Y5 M1 H, i4 A& v+ _! uline(0, 0, getmaxx(), getmaxy()); </FONT></P>
0 L! o( @( L' S  y1 w3 X5 r<P><FONT color=#0000ff>/* clean up */ 5 d4 O  w, E0 y1 O+ y- K  {! J  t
getch();
6 w0 y$ z& v9 ]' r! F0 Xclosegraph(); 5 e0 C8 i. Y  d' |* h. X
return 0; 5 T" B5 q" K4 A  W" l
} </FONT></P>$ E# d0 e8 ^# ]4 R4 r
<P><FONT color=#0000ff>/* detects EGA or VGA cards */ , F5 Z2 ?5 o: f) E2 `2 T0 H1 H
int huge detectEGA(void)
6 G7 `& ~3 _* Z, F1 [+ O9 {{
5 U/ H* ~; |  S1 ]9 t; d. }int driver, mode, sugmode = 0; </FONT></P>$ r8 L+ S+ x6 W" {+ V, z$ u* A
<P><FONT color=#0000ff>detectgraph(&amp;driver, &amp;mode); 5 L2 v5 ?+ S2 r; |" e5 [* T  I
if ((driver == EGA) || (driver == VGA)) # {2 l  L: s6 ~2 l
/* return suggested video mode number */
6 c2 Q: l( \0 V4 V  y; {! v: I3 yreturn sugmode; 7 \& `' Q- S3 c3 Q3 B4 o
else
* _; U+ [$ r' f5 |( N8 g/* return an error code */
+ ]" j! u7 o; J) g1 m9 Vreturn grError; $ ~% p8 a7 M2 x, v2 K- J
} </FONT></P>
) W* Q( ~: ^' h! n% Q<P><FONT color=#0000ff>/* check for and report any graphics errors */
6 R! I) [7 F1 o8 j9 A" v  O. |void checkerrors(void)
* P/ }4 j2 E7 s% z5 J2 J{
# \8 c+ x( O3 F0 T( f( [! R$ i; n& rint errorcode; </FONT></P>
+ Q# ]' r* c4 F) ]& R<P><FONT color=#0000ff>/* read result of last graphics operation */ * E& I& W, O, x# d& a" _/ r: |
errorcode = graphresult();
# l  f) q( n( M; [) X5 g, ]if (errorcode != grOk) . b! a. r+ ^6 _( X6 s2 ~' b
{
% r6 w" x' J1 i7 B+ P& [. Eprintf("Graphics error: %s\n", grapherrormsg(errorcode)); 3 [: d( D& P: d2 U9 S: E5 \
printf("Press any key to halt:"); . }$ D3 z4 j% X& U- O
getch();
9 M* e) H" F4 D) V" ~1 zexit(1);
& f4 L  ?. {2 X2 ^9 z/ s0 N}
3 K$ ?1 u% `# o# H} </FONT></P>
  j6 E  p+ b9 B6 z<P><FONT color=#ff0000>函数名: installuserfont </FONT>
  h! W& [2 e% F8 r; a$ I  n功 能: 安装未嵌入BGI系统的字体文件(CHR)
2 b" g/ A. |  B6 V0 |# d用 法: int far installuserfont(char far *name);
* U4 [% T# l- s: U5 W程序例: </P>
7 @3 m  Y2 m* o" ]<P><FONT color=#0000ff>#include <GRAPHICS.H>
/ S3 I) i! o; ~# o/ ]9 T9 }3 M#include <STDLIB.H># h" F* X( P3 e) o8 I. w  P9 D
#include <STDIO.H>8 U' X$ k- \4 t3 P* q9 f4 Z
#include <CONIO.H></FONT></P>
+ c3 Y/ s: W7 b<P><FONT color=#0000ff>/* function prototype */   w+ Q/ L& q# w! e, h8 H
void checkerrors(void); </FONT></P>
* ?. h( `' E: _- f% U6 z& ]# B4 P<P><FONT color=#0000ff>int main(void)
) \- M/ T4 s7 z; N9 Y7 F/ y{
% l7 K% A3 F3 X9 P4 c" X2 j8 |; p/* request auto detection */
, _, l, H8 R2 i" i# t. h4 Vint gdriver = DETECT, gmode; , d; V& F1 [6 v, ?8 c
int userfont;
" D$ ]1 X, }0 I9 e. O5 i. _int midx, midy; </FONT></P>9 `; m% E( o% A7 z+ h; W, {
<P><FONT color=#0000ff>/* initialize graphics and local variables */
& b- X6 K- i$ e; C0 H: ~initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>3 R4 b: e; S6 G
<P><FONT color=#0000ff>midx = getmaxx() / 2; & W) B8 j$ S! {1 A7 H, Y! h! l
midy = getmaxy() / 2; </FONT></P>
& G; |2 c. ~! }# E$ Y' Y$ o& t<P><FONT color=#0000ff>/* check for any initialization errors */
0 s: c  e  s/ ]0 z* G! m- scheckerrors(); </FONT></P>
/ _/ C  d4 k% V- H4 J; W<P><FONT color=#0000ff>/* install a user defined font file */
# }' v  \* M2 v( @# z- Q/ Ruserfont = installuserfont("USER.CHR"); </FONT></P>( _3 O9 q! N- H; Y$ n0 p; W$ W
<P><FONT color=#0000ff>/* check for any installation errors */
' D  S' h/ g' m  e/ Y/ w7 Echeckerrors(); </FONT></P>
- `/ D7 k5 n1 Q! l<P><FONT color=#0000ff>/* select the user font */ + \( f7 g! n+ ~! g1 V3 `; {
settextstyle(userfont, HORIZ_DIR, 4); </FONT></P>9 f; N% C$ j4 l9 K7 Z; }
<P><FONT color=#0000ff>/* output some text */
3 c. v9 Y4 D; n8 ~4 qouttextxy(midx, midy, "Testing!"); </FONT></P>
! d$ w' x  X7 k# P<P><FONT color=#0000ff>/* clean up */ ( U6 D4 f8 [0 @
getch();
7 w: n% W& o- x1 Oclosegraph();
9 C% T# a. W+ b) @return 0; , D2 u8 b, p% c# A# _2 v4 ?5 r' Z
} </FONT></P>0 U7 A+ Q  \8 N
<P><FONT color=#0000ff>/* check for and report any graphics errors */   f) V5 i2 x5 m7 t( b
void checkerrors(void) ' T* W5 J' o8 y# L
{ 2 b. }* s4 K- y% R3 N: R4 t
int errorcode; </FONT></P>
* y! w: {( Z1 b<P><FONT color=#0000ff>/* read result of last graphics operation */
3 \/ w& x# e( O) N) S: werrorcode = graphresult(); & u( ~8 D' L1 ^/ g0 r4 C
if (errorcode != grOk)
4 w& d$ t$ x$ \+ }9 _{
. z3 ~3 L- f3 h7 Nprintf("Graphics error: %s\n", grapherrormsg(errorcode)); 4 o6 y2 b' ^3 i* Q1 y/ O
printf("Press any key to halt:"); - I- P5 R- z. v% u' c: F
getch(); / m: @. A" q" R% [7 _
exit(1); 3 m" ~, C& l+ C% b$ y' v
} ; @; p8 D1 e7 M9 Q& r3 V
} </FONT>3 J5 ?: }/ }3 y# ?. H2 e

/ L, `- c+ y. }* K
1 O- i' m0 C! I* x5 G</P>8 `% P9 k( x  `: |: d
<P><FONT color=#ff0000>函数名: int86 </FONT>) z, Y( @9 b7 G
功 能: 通用8086软中断接口   {" |" C; t, [2 k" x- m
用 法: int int86(int intr_num, union REGS *inregs, union REGS *outregs); : e! ?. j% N  u  c1 V' a
程序例: </P>
) O: S1 x* s# B<P><FONT color=#0000ff>#include <STDIO.H>
8 E' c) \# O( D7 S- p#include <CONIO.H>
6 c; j( X% I/ w+ Y& Q#include <DOS.H></FONT></P>
5 O* M9 X) U4 e2 @<P><FONT color=#0000ff>#define VIDEO 0x10 </FONT></P>
+ A: m/ w6 r* S4 y: I3 z$ W<P><FONT color=#0000ff>void movetoxy(int x, int y)
2 b8 q6 V6 ~: `{ / K& j+ G9 M9 s1 i4 r- C
union REGS regs; </FONT></P>
( D! i, V1 k/ f+ \  a! w& l<P><FONT color=#0000ff>regs.h.ah = 2; /* set cursor postion */ 0 l- J8 t1 ]5 P" b7 j/ e
regs.h.dh = y;   e6 Z2 |2 i. \1 r/ c6 G, S* s# g
regs.h.dl = x; ( F& y+ Y# I' O% f. ]
regs.h.bh = 0; /* video page 0 */
+ u  c# E9 l3 dint86(VIDEO, &reg;s, &reg;s); & x1 p$ o8 u- P/ g
} </FONT></P>' x! R/ ]8 P! r3 W
<P><FONT color=#0000ff>int main(void) ( W. i- k% x; A: B0 l( I' N
{
7 J$ p8 E" u' B4 aclrscr(); $ a. K* ?1 E5 K+ L. w# A& j: Z! @
movetoxy(35, 10);
3 v- w# Z% s1 k& _printf("Hello\n"); 0 }; Y4 K* E" U# z2 X
return 0; / M3 c: Z7 d7 ^+ U
} </FONT>8 b4 l3 p8 q+ W" a1 N2 ^

" @6 q; h# L1 s5 ~+ w</P>" j8 ]* L+ q7 t8 ^5 Z7 U' t$ u
<P><FONT color=#ff0000>函数名: int86x </FONT>0 T$ k3 q1 @  H" d1 q; k' N7 {. B7 A3 p0 ]
功 能: 通用8086软中断接口 : \% \* Z8 M4 U7 G2 s8 x
用 法: int int86x(int intr_num, union REGS *insegs, union REGS *outregs, # g1 T- ^! t6 o9 B' L
struct SREGS *segregs); ( o3 S. z- K% S7 o7 W# C* o) E+ z
程序例: </P>! c% z: q" y/ k7 O2 j* [/ L) N8 c
<P><FONT color=#0000ff>#include <DOS.H>  r( z( e& ^. s/ r8 s( a1 P% c
#include <PROCESS.H># K' S8 {% }& I7 ?1 S7 D. f
#include <STDIO.H></FONT></P>
# I$ T4 i2 ]0 m9 [" k; K- P$ j<P><FONT color=#0000ff>int main(void) % {' X8 a( x6 h0 A5 `$ [
{ * A) v& j# w/ w) l  R% y) `
char filename[80];
! K+ p. k; i' Z' O( I7 L% u! Lunion REGS inregs, outregs; 6 A' \: Z3 B7 N% B! i# P
struct SREGS segregs; </FONT></P>
9 l* M& G- N( N8 B8 L<P><FONT color=#0000ff>printf("Enter filename: ");
7 V# H, J; J7 N2 cgets(filename);
9 D" \8 l0 M" z/ `inregs.h.ah = 0x43;
' r, [/ {/ d' U- E1 [! Ginregs.h.al = 0x21;
. E5 D! j, X  Xinregs.x.dx = FP_OFF(filename); 5 V# g0 ^, Y" l+ ]& e
segregs.ds = FP_SEG(filename);
0 }4 k9 @1 x& l& F+ c# h; g2 Qint86x(0x21, &amp;inregs, &amp;outregs, &amp;segregs); " A, }' t: Q6 J8 z
printf("File attribute: %X\n", outregs.x.cx);
! {" h4 r, J  D+ C6 t: Jreturn 0; ( n) F7 D: U7 ?$ |
} ( J. z5 y6 v6 h% B

4 n6 [+ ^9 {6 O# ]6 e</FONT>8 H: I2 n  W+ r( M6 T
</P>
: y" U* s9 l6 L<P><FONT color=#ff0000>函数名: intdos </FONT>
! {7 Y3 S4 p/ C# U功 能: 通用DOS接口 % x1 N0 g! n) c9 q; H
用 法: int intdos(union REGS *inregs, union REGS *outregs);
* T3 j3 d1 c' G# ?/ a程序例: </P>$ J. x' s' o8 r$ k& P1 _( A
<P><FONT color=#0000ff>#include <STDIO.H>. M5 |% D5 b" u  [. k4 e
#include <DOS.H></FONT></P>
0 I. ]2 H+ ]) l7 R2 r/ U4 a<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */
+ F+ ?  _) `  Z9 ~7 Bint delete_file(char near *filename)
) W1 \- q. S* S{
% X9 \7 Y0 N! t9 runion REGS regs;
" X) M$ `: ^; K; l* K4 t+ gint ret; 8 p0 P8 q( M3 v3 K. Q7 ]
regs.h.ah = 0x41; /* delete file */ # Q, v$ [4 w: X/ J7 v$ |
regs.x.dx = (unsigned) filename;
/ U$ [( C+ t  [# m0 t% f9 xret = intdos(&reg;s, &reg;s); </FONT></P>5 X% |) E0 r$ |  H, [, E
<P><FONT color=#0000ff>/* if carry flag is set, there was an error */ & Q7 J( H5 w8 U% b
return(regs.x.cflag ? ret : 0);
- G9 y$ ^( D: l0 M6 R( ?  a( u5 ?} </FONT></P>/ W  r, O2 G! d2 h- p- B; n9 k
<P><FONT color=#0000ff>int main(void)
; j' [4 i1 G. p, `& @% j{
% w* |- ~: d, zint err;
; W( v6 g7 X% f* j5 ^) `9 C; werr = delete_file("NOTEXIST.$$$"); ! J0 X, y8 Z* o3 q  s/ T
if (!err) 0 k# x/ e! Q0 h+ q
printf("Able to delete NOTEXIST.$$$\n");
. N. p7 G: Y! Y: k, q/ H4 V$ [else ) c; ~6 S: o7 t3 S) Y, g; J
printf("Not Able to delete NOTEXIST.$$$\n");
+ E" q! T: U9 F  [2 _return 0; , `# k$ g$ ^& O; }4 v+ Z# ]4 U3 q
} 2 d, C4 G2 d( W: O$ j9 M, L3 E
$ X2 z9 A$ o' f) i# B
</FONT>& f* g1 p9 ]% b. @1 D
</P>) B- |$ p4 o: O4 W" Y( n( R
<P><FONT color=#ff0000>函数名: intdosx </FONT>
: @1 B* f0 c+ a+ S3 p功 能: 通用DOS中断接口
: X& k4 m% a- f! B2 x用 法: int intdosx(union REGS *inregs, union REGS *outregs, , f  J* u: m8 s% h( d. E
struct SREGS *segregs);
& H% y3 O- G  u. ]4 ~% n* _程序例: </P>, l+ Q# c7 B1 e" q4 f7 K' c
<P><FONT color=#0000ff>#include <STDIO.H>
: l* f# X' w1 E! H/ c6 o5 Q#include <DOS.H></FONT></P>* I' k0 a# ^  q! s+ a
<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */ ) p% N5 L$ |6 J, w+ i6 v! n
int delete_file(char far *filename) * G. ]2 s0 W% G. C& I
{   x5 \* @9 C5 ~; d, \+ s: @
union REGS regs; struct SREGS sregs;
+ ?3 y: G3 z, hint ret; 8 N( G5 D- |8 s1 r8 Y, {4 B) y( U
regs.h.ah = 0x41; /* delete file */
# E5 c- U" l6 t6 zregs.x.dx = FP_OFF(filename);
5 d4 N" e8 A$ H4 |+ t6 U# Y3 usregs.ds = FP_SEG(filename); $ t  X& X2 n9 l, |% o
ret = intdosx(&reg;s, &reg;s, &amp;sregs); </FONT></P>9 t2 F2 z7 S5 t1 J' z, c+ x4 Y
<P><FONT color=#0000ff>/* if carry flag is set, there was an error */ & O# e1 _' n  n: o
return(regs.x.cflag ? ret : 0); 6 C; n3 G+ {6 l1 N; a7 c
} </FONT></P>
4 h8 |7 M( \- t4 P2 P<P><FONT color=#0000ff>int main(void) 5 E$ Q4 a- }" i3 \
{ ! k  {- p4 \/ _6 t6 K+ [8 p
int err;
4 W" @6 |; B" C; _) ierr = delete_file("NOTEXIST.$$$");
' b. |- T8 t  j  B4 a7 T) nif (!err) : c; i& j. Y, S6 g+ _% k- |
printf("Able to delete NOTEXIST.$$$\n"); # R+ l: z0 A* i) T/ F
else 5 s, B% ^! d! C8 _- b
printf("Not Able to delete NOTEXIST.$$$\n"); ' c4 n8 v" X9 u/ D6 Y) ~
return 0; 5 g4 w$ r) }3 e! d: f
} 7 {$ t( _! R) B4 k5 I" k. O
</FONT>
/ A( n! g9 P+ H0 ?* _- m8 V</P># [2 e5 t" N& J! q
<P><FONT color=#ff0000>函数名: intr </FONT>5 R: l' x1 ^6 i' J" ~6 w( n) z& u8 M
功 能: 改变软中断接口 7 o% D- S' t# W1 [5 [. C. M- u
用 法: void intr(int intr_num, struct REGPACK *preg);
& p# e" F9 d9 u& `% _; p程序例: </P>
3 |7 E  Q0 d! Z<P><FONT color=#0000ff>#include <STDIO.H>9 ?, k5 p) H. Y' _% ~1 R
#include <STRING.H>
* W/ |2 f& d1 ~3 |) X, ]4 X#include <DIR.H>
. R* L6 x; O1 D3 P. n1 L6 q9 S#include <DOS.H></FONT></P>
0 K+ e; M# U0 X<P><FONT color=#0000ff>#define CF 1 /* Carry flag */ </FONT></P>
; q9 T5 k% f* Q4 x<P><FONT color=#0000ff>int main(void)
- v$ O% \  Y+ u" H" H{
9 H0 z( L, T0 X( i# _char directory[80];
8 P8 W! d# k# dstruct REGPACK reg; </FONT></P>* N$ [+ Z" z& d; p, E3 y
<P><FONT color=#0000ff>printf("Enter directory to change t ");
; z3 o2 M' W' A2 y6 Jgets(directory);
9 G2 F, g8 j" _4 R$ \9 Wreg.r_ax = 0x3B &lt;&lt; 8; /* shift 3Bh into AH */
, ?4 W% ]# F: B$ D& B" Jreg.r_dx = FP_OFF(directory); % d) @3 Z) E; h9 Z
reg.r_ds = FP_SEG(directory); , F2 W5 Q3 W" n4 y: F
intr(0x21, &reg;); , N* ~1 g. ^; w$ Y
if (reg.r_flags &amp; CF)
' n( A% l5 K3 l% \) qprintf("Directory change failed\n"); 8 ?8 Z) a3 O, c/ O, f1 w, A1 b
getcwd(directory, 80);
/ l& R* I' e1 H) o8 f& A3 Vprintf("The current directory is: %s\n", directory);
6 Q; B. C: W: D. s5 g- Sreturn 0;
! |( Z2 C  ]. v} ( b+ A! ]7 F3 y5 j
</FONT>
. h7 F1 g. {0 u# S  ^1 q</P>
" f0 Z2 i. G+ J6 I( \<P><FONT color=#ff0000>函数名: ioctl </FONT>
4 R, K8 T, J5 E: h* }功 能: 控制I/O设备 3 ?; u" w# ~0 V
用 法: int ioctl(int handle, int cmd[,int *argdx, int argcx]);
1 a' x6 R# m$ I% `* }3 R7 K) W# D) ~程序例: </P>, t2 R8 A/ P- B" {: t
<P><FONT color=#0000ff>#include <STDIO.H>/ `1 `9 _0 x' h1 V# T5 h
#include <DIR.H>) w! k6 p0 P; q9 i- G6 Z
#include <IO.H></FONT></P>
, G4 @$ \: p7 W, C! _<P><FONT color=#0000ff>int main(void) " y' _4 e% R; h) l7 n$ S& h
{
# W  b9 v; K6 O& y( w6 T# @int stat; </FONT></P>
- E% [* V7 Y. G<P><FONT color=#0000ff>/* use func 8 to determine if the default drive is removable */ - A: J8 L) S; e8 K* ~5 M; c
stat = ioctl(0, 8, 0, 0); - D6 l* w0 k" @; z0 j
if (!stat) ; G4 O0 z; S# w7 U
printf("Drive %c is removable.\n", getdisk() + 'A'); 8 l+ ?0 |' G! m& {- }" p1 r$ l
else
/ l( `: ]4 K2 Z  b# Q0 v( Y' B0 b0 vprintf("Drive %c is not removable.\n", getdisk() + 'A');
1 a& E# g2 t8 z, v% K8 u, a# E, Wreturn 0;
; A* _) _' A# y2 p9 G* P: u+ X} 5 F1 _7 y, D+ t8 I' |% C0 j2 z
0 j( {3 {4 M- M8 G
</FONT>+ {  B% M5 a0 ^& r9 }6 H
</P>; n+ x7 V4 I0 S$ T) M5 q
<P><FONT color=#ff0000>函数名: isatty </FONT>
( O7 C, W8 }0 W6 `功 能: 检查设备类型
7 v8 G+ P. F- X/ d) C. n9 J* ]2 h用 法: int isatty(int handle);
8 U* F, J% R# p$ H1 v程序例: </P>8 S/ z  m% D/ Z# y& ~: V
<P><FONT color=#0000ff>#include <STDIO.H>, [+ ~# K, [/ e  D' \* ?# X8 S, R# L
#include <IO.H></FONT></P>/ M% I2 P3 _) t( r6 S, @: c# U: E
<P><FONT color=#0000ff>int main(void) ' P; E3 l' m: J0 R& P9 n
{ 0 }. T" _' }3 a
int handle; </FONT></P>
" Q! j! ]" s+ t5 f  {7 a<P><FONT color=#0000ff>handle = fileno(stdprn);
1 k* V, c: p, I+ K; oif (isatty(handle))
  h; M) S; A% e' a9 |3 o- E" wprintf("Handle %d is a device type\n", handle); ; [1 W& Q# H$ P. E6 x: [
else ) C7 _8 t% o. P: ]- W
printf("Handle %d isn't a device type\n", handle);
( \: l% [5 z& [, g1 {. Rreturn 0;
* j* K5 k) n/ k( U$ P6 {- V+ a% o. f}
4 f( q" b# g6 ]- |4 [2 u! h5 w
* G% I' M4 {) R3 O# D1 d6 \- v</FONT>4 B. g. Q0 s" H7 ?) k) N$ S. S
</P># a) Z! B5 c5 |9 S
<P><FONT color=#ff0000>函数名: itoa </FONT>; X, a% P: k" d1 H2 C
功 能: 把一整数转换为字符串 0 {% q) f$ d7 J
用 法: char *itoa(int value, char *string, int radix); + e. Q! O+ I$ L; y# s
程序例: </P>
" n  C3 f% s' a  k$ `8 N& b4 ]1 x+ Z<P><FONT color=#0000ff>#include <STDLIB.H>+ w+ x: i8 z  j1 H% k
#include <STDIO.H></FONT></P>- j; ~: I; f7 D7 ~+ `3 h4 ^0 ~- T+ Y
<P><FONT color=#0000ff>int main(void)
  V2 o8 R8 W, U( }  [{
' E- n7 _* ?( d8 M4 [int number = 12345; 0 T) L, y. v4 V: l' u8 P8 n
char string[25]; </FONT></P>  _: ~& d! R+ W7 C$ A8 e
<P><FONT color=#0000ff>itoa(number, string, 10); # W' T# h# S6 K, O5 {
printf("integer = %d string = %s\n", number, string);
3 b. k5 I# }( A3 K; q' S' K7 Preturn 0;
/ b) X0 B0 k6 y3 Q} </FONT><FONT color=#0000ff>) T  G7 R' s4 m  I% [
</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-11 08:43 , Processed in 0.322004 second(s), 52 queries .

回顶部