QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2425|回复: 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>
! r# L% ~# N+ _0 v% \. d< align=left><FONT color=#ff0000>函数名: imagesize</FONT> 9 M9 S8 Z1 }; y: x: u6 Z
功 能: 返回保存位图像所需的字节数 1 e/ f! W; q1 m, R
用 法: unsigned far imagesize(int left, int top, int right, int bottom);
! ~; R3 w& M9 k( J! ]1 t' r& _程序例: </P>, ^& t6 t1 M% n
<><FONT color=#0000ff>#include <GRAPHICS.H>) J8 A1 }& q6 r& v) @
#include <STDLIB.H>- Q. o0 ^; f1 X
#include <STDIO.H>
/ U* Q; G* v5 a#include <CONIO.H></FONT></P>8 q1 t3 y3 h7 d1 l) ?' p3 M6 T4 n
<><FONT color=#0000ff>#define ARROW_SIZE 10 </FONT></P>& H1 I1 M! M: P
<><FONT color=#0000ff>void draw_arrow(int x, int y); </FONT></P>9 S8 C8 J) {& j1 r) q
<><FONT color=#0000ff>int main(void)
- b. F4 t: A9 Q5 _9 J3 v: ^: a% r{
7 t7 s6 c7 w1 _, j" {! k  p; ]/* request autodetection */ 0 r# x$ H  e2 c! ?9 p( k
int gdriver = DETECT, gmode, errorcode;
$ m. Z! m. @7 w5 u- a7 u# ?3 }, Q- ?7 Qvoid *arrow; - r0 u# i* e) q3 m1 O9 V4 I
int x, y, maxx; * u6 O6 B! I2 W$ r! H
unsigned int size; </FONT></P>
  X0 ]+ b1 Z6 U0 P<><FONT color=#0000ff>/* initialize graphics and local variables */ . d! Q1 I5 ~+ _
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
8 E8 m* s  _7 p# ^6 _0 T<><FONT color=#0000ff>/* read result of initialization */
1 S5 ?* L; f2 P+ r" G+ Aerrorcode = graphresult();
1 C6 s8 \8 k- C5 T# g, ^! a" f8 Q6 zif (errorcode != grOk) /* an error occurred */
' `8 c: [6 T7 |& D{
# Y1 B2 p5 {: w' O& Hprintf("Graphics error: %s\n", grapherrormsg(errorcode));
* H& N3 [6 b& M( o5 uprintf("ress any key to halt:");
6 ?2 h) b. z# a  D$ F/ f2 Sgetch();
. g. E8 W3 K+ T- `: R4 e% T6 v! _exit(1); /* terminate with an error code */ 7 c/ Y9 u1 n0 d5 G1 o) i' C. [
} </FONT></P>
$ N$ L2 T. f/ ~* ]( t/ s% X<><FONT color=#0000ff>maxx = getmaxx();
  z$ d  z) E1 h( N! p! hx = 0; ) C% a, j. i& P8 w: a* n
y = getmaxy() / 2; </FONT></P>
& ?: _1 Q( Y+ M, n<><FONT color=#0000ff>/* draw the image to be grabbed */
$ c5 u/ c9 a6 ^draw_arrow(x, y); </FONT></P>3 Z4 I) h; i" L
<><FONT color=#0000ff>/* calculate the size of the image */
4 K" X4 J5 G) H8 U! tsize = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE); </FONT></P>
; N/ Q& o: w' g<><FONT color=#0000ff>/* allocate memory to hold the image */ + O9 l" b# Q+ N8 r& R9 Y: b" V' D
arrow = malloc(size); </FONT></P>/ f" a6 i- X, m! Z+ C1 m
<><FONT color=#0000ff>/* grab the image */
8 T; _8 [- ^- [4 K" _/ Agetimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow); </FONT></P>
. ]/ n) U& e6 |/ J4 p, Y<><FONT color=#0000ff>/* repeat until a key is pressed */ . S  K; M7 c& u/ q- F
while (!kbhit())
  q. t2 ~! l3 l# h2 F) ^; z# q{
2 K4 r" \) l9 t9 |/* erase old image */ - R" v! L* B! X& d. B' o% H# @
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); </FONT></P>
+ d1 s) f" I. ]; E: Y& j4 e<><FONT color=#0000ff>x += ARROW_SIZE; # c( N8 }* q( U
if (x &gt;= maxx)
; o3 k7 }  d" A! C2 y: T" |x = 0; </FONT></P>
# S% f" A- i( E' U( G2 Y<><FONT color=#0000ff>/* plot new image */ # N. M/ q& {1 ]5 h! k* }: e
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);
5 i. K, `+ j. w) B/ L+ B1 a8 e( D: [} </FONT></P>' L7 s) N$ N8 B+ U6 @- n! y* b
<><FONT color=#0000ff>/* clean up */
& @* i, @0 C) |. pfree(arrow);
$ m1 J5 Q/ _7 q0 [& J$ F7 s4 ~closegraph();
- ?* ~- H* t" b# D, ^% M" qreturn 0;
4 Y9 J4 K( H* a! E6 H} </FONT></P>( T; k% R! G. `9 ]( X$ W9 J+ V4 I
<><FONT color=#0000ff>void draw_arrow(int x, int y) , U9 o9 ~+ N% S# y2 X
{ 1 u- B+ O* _: I
/* draw an arrow on the screen */
- I& h$ c7 i6 _0 [; g$ T# H7 V/ emoveto(x, y);
  ]9 ?4 U! D" t+ `$ Y) p4 hlinerel(4*ARROW_SIZE, 0); - v) Z: p8 M! V2 G( O/ F: a% U7 t
linerel(-2*ARROW_SIZE, -1*ARROW_SIZE); ( j9 d. R& c% d. S$ N
linerel(0, 2*ARROW_SIZE); 0 b8 b0 H$ k# p5 @8 J
linerel(2*ARROW_SIZE, -1*ARROW_SIZE);
% I: I: {2 R+ ^  T9 H} : s; S) ^; N6 W. j4 l$ D$ H7 Q' e( A

( c# P3 U. k3 d! o  d2 W: a* x5 ^* G- s
7 b- {) j0 e* _</FONT></P>
7 Z: [3 t0 [# e& \+ F* K<><FONT color=#ff0000>函数名: initgraph </FONT><FONT color=#0000ff>. [% ~9 G( T- z1 ^1 ^" v3 P0 Y0 _
<FONT color=#000000>功 能: 初始化图形系统 3 o9 \3 W7 m) V6 b* `: U
用 法: void far initgraph(int far *graphdriver, int far *graphmode,
. x. n" ~9 L3 _$ B9 _char far *pathtodriver);
4 w" R; V+ s9 w& U- ^" t程序例: </FONT></FONT></P>
, q9 R9 [- F  Y, B* Y) u<><FONT color=#0000ff>#include <GRAPHICS.H>( w" ^+ Q5 a/ [- t( A: R
#include <STDLIB.H>
; L! I$ p$ U7 x$ w( _2 y: A#include <STDIO.H>% G4 z5 [4 W" L/ R) u
#include <CONIO.H></FONT></P>6 k2 o9 v% _3 A% o. J! `) @+ a+ Q5 B
<><FONT color=#0000ff>int main(void) 9 @& H6 J/ E8 s
{
( [/ y( F" B, t/* request auto detection */
4 p2 b& f9 M/ O1 _0 L0 L  g) Vint gdriver = DETECT, gmode, errorcode; </FONT></P>
0 V# x4 c' W( P& X1 q, \( v<><FONT color=#0000ff>/* initialize graphics mode */
; T7 n1 f, C& g! t1 o, ?initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>; n8 n/ n) ]# G9 Y6 R, H* A
<><FONT color=#0000ff>/* read result of initialization */
* p# S' [/ l. u  Nerrorcode = graphresult(); </FONT></P>
" p! f4 B) ~6 e( D8 b2 t<><FONT color=#0000ff>if (errorcode != grOk) /* an error occurred */
4 i3 }5 W5 K3 I$ F2 d2 K{ 4 A9 o$ Q: \# M- N% V
printf("Graphics error: %s\n", grapherrormsg(errorcode));
( w7 v7 J" _: ?8 Iprintf("ress any key to halt:"); ; s; m8 ?4 x3 h* O0 _
getch(); 6 K7 E+ L" P0 T5 N" E) t3 ^" W
exit(1); /* return with error code */
( z4 B" }$ O8 f2 ^6 m1 |} </FONT></P>7 A* r9 \1 t4 L+ T; Y- K
<><FONT color=#0000ff>/* draw a line */ % ~6 d% x$ @/ z4 h* y5 g: h9 t
line(0, 0, getmaxx(), getmaxy()); </FONT></P>
2 S4 @( ~8 u% R. H, F<><FONT color=#0000ff>/* clean up */ : K4 l: K" S* ]! [) _; b( `
getch();
/ ^$ y  _0 A+ lclosegraph(); 9 A' @! U4 _+ j- G  W/ G3 M
return 0; ! N. E: d8 p& L. m
} </FONT>2 J& ~3 }; |6 o
- b  i2 ^5 ~) H' q  `+ W
</P>4 T* |! O  `7 @1 m1 N
<><FONT color=#ff0000>函数名: inport </FONT>5 \0 P" _' _$ b. \8 Q7 F, O7 n
功 能: 从硬件端口中输入
2 U1 H- B6 V1 K用 法: int inp(int protid);   s0 h- b0 i( M; Q; s
程序例: </P>1 I( v6 C- w0 ^' G) R& {4 f) F
<><FONT color=#0000ff>#include <STDIO.H>  n& u( H; e  y( K; Q
#include <DOS.H></FONT></P>. d7 _  @5 x9 O
<P><FONT color=#0000ff>int main(void)
1 m7 A& i- j+ x) A1 s: n{
0 h* ~: A+ L. q% M" eint result; 8 ^& F" K( t  `3 ^0 f$ c5 f+ q
int port = 0; /* serial port 0 */ </FONT></P>
" G+ Z( F0 T8 u' K! X7 S<P><FONT color=#0000ff>result = inport(port); 0 @' q# g8 x9 a
printf("Word read from port %d = 0x%X\n", port, result); % C6 \2 w8 @& s
return 0;
/ E0 Z3 x' S5 u( y! L, E, _} ) `5 R6 E4 `, _% Y2 R
4 i+ L$ u+ m$ u8 l' K4 F9 _
</FONT></P>
2 E" s# t1 E5 V2 }. Q8 y  v) K<P><FONT color=#ff0000>函数名: insline </FONT>
  \- l* h2 z- c9 i# l9 G  ~功 能: 在文本窗口中插入一个空行
* {3 {- P1 o7 q# S3 r用 法: void insline(void); 9 J" }0 `. |- R; _2 F, T7 G
程序例: </P>% U' ~) F. f, T6 B/ Q" G  R: h
<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>4 E2 u5 |4 N" {( \* @
<P><FONT color=#0000ff>int main(void)
% W- W- V/ v- y( A* d0 V{   H7 L* _( F! g. {; u
clrscr(); 9 Z: O. i/ i+ A+ Y* V
cprintf("INSLINE inserts an empty line in the text window\r\n"); % x6 N2 r$ t( t0 v- p
cprintf("at the cursor position using the current text\r\n"); 8 o1 D7 E- f; N$ u+ C5 }9 J8 D
cprintf("background color. All lines below the empty one\r\n");
" t2 q$ }+ }/ G4 Vcprintf("move down one line and the bottom line scrolls\r\n"); 5 {9 U- J0 H/ m$ N0 v
cprintf("off the bottom of the window.\r\n");
3 t0 b0 S9 L+ Y$ r! @' ^cprintf("\r\nPress any key to continue:");
) N9 z& u6 q1 W6 ]( Vgotoxy(1, 3); 6 u$ h( d- f! r# L# j
getch();
9 V2 T7 G8 s1 ]. W  F- X9 {3 iinsline(); " y3 a1 n! e% X. j9 y( O  G
getch(); ) l, l4 L* X+ O; K" H" i
return 0;
% U% E1 m) D  f' [1 s; j0 e0 U8 ^0 ~} ! `, y+ x3 g( R
</FONT>4 B) G. S" b" j
( c0 h9 c; g2 w$ c( s0 _' c( d2 |
</P>( N2 E: X- N( p! d( C; \0 B
<P><FONT color=#ff0000>函数名: installuserdriver </FONT>
' |) H  O, J, w. B1 ^! g功 能: 安装设备驱动程序到BGI设备驱动程序表中
' c7 N# L  K: O! z用 法: int far installuserdriver(char far *name, int (*detect)(void)); ) M2 G! Z) F# E/ V1 N9 H
程序例: </P>
/ D# ?% s$ f9 W8 N0 v; J5 j6 K<P><FONT color=#0000ff>#include <GRAPHICS.H>2 o* e; `7 r' G- T% q+ o: w
#include <STDLIB.H>6 i7 U6 `* {  n2 ~4 e7 e
#include <STDIO.H>
& z1 g2 e/ s0 N" E; x1 N9 {6 l#include <CONIO.H></FONT></P>0 q9 d4 o% }, j; M' Z; h
<P><FONT color=#0000ff>/* function prototypes */
1 ~9 ~; V- r9 e4 w2 Eint huge detectEGA(void);
' ~8 F( k. g# @% ]$ z' Yvoid checkerrors(void); </FONT></P>
; E7 M! `6 e3 R7 R<P><FONT color=#0000ff>int main(void) / v1 _+ |" F# ~4 T" k3 f% o+ [, h
{ ( w8 U( q7 }: c" j
int gdriver, gmode; </FONT></P>
  C! v( b& i# O! H2 q* p<P><FONT color=#0000ff>/* install a user written device driver */
) s; D! r* ^, n" Rgdriver = installuserdriver("EGA", detectEGA); </FONT></P>
( z: v- l$ g: G<P><FONT color=#0000ff>/* must force use of detection routine */ & X2 s7 i6 v( f% ]7 V
gdriver = DETECT; </FONT></P>
: F+ s. Y& ?& M; E8 o- `( h3 _( I<P><FONT color=#0000ff>/* check for any installation errors */
1 z& k  w. s4 ]7 }checkerrors(); </FONT></P>
6 `9 q: t) [* h<P><FONT color=#0000ff>/* initialize graphics and local variables */ , ]; M( P* x& E" p+ f0 \2 K
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>) Z7 |& }2 U" n" q
<P><FONT color=#0000ff>/* check for any initialization errors */
, \& F7 l3 |% r# i5 xcheckerrors(); </FONT></P>
/ P7 K& h* M1 Y! `' x( A<P><FONT color=#0000ff>/* draw a line */ & b5 [0 v# y2 ?  [3 R
line(0, 0, getmaxx(), getmaxy()); </FONT></P>4 q# D9 ]7 C8 ~5 s- N2 J. d
<P><FONT color=#0000ff>/* clean up */ " ?9 q. D9 p7 j% ~
getch();   K$ Q# p8 p3 E: q; D) V
closegraph();   J! n/ [' s6 Q3 \: S
return 0;
' E1 y8 |9 X* d  R4 M+ y} </FONT></P>  c- B- Y* @( [$ I  r! i: L
<P><FONT color=#0000ff>/* detects EGA or VGA cards */
4 v6 ?# }6 @/ b2 J$ Dint huge detectEGA(void)
& _- }5 [7 j  y2 z3 s{ / D* N0 r" }# d7 C  _% I" z! X/ Z1 N
int driver, mode, sugmode = 0; </FONT></P>
7 M# i. d8 H* i' r7 H# z6 k, T0 @<P><FONT color=#0000ff>detectgraph(&amp;driver, &amp;mode); 7 d4 I0 ]8 d) s1 u8 W0 m/ B
if ((driver == EGA) || (driver == VGA))
1 N% [4 P# A' w2 w9 M7 R/* return suggested video mode number */
8 X  k. K) l5 Ireturn sugmode;
1 L7 `: A' m# F6 pelse 6 F: E9 Z* J& P( v
/* return an error code */
6 h/ c! `9 _# Preturn grError;   C2 _* D; _' F) ]  d
} </FONT></P>
$ S$ ]" @; p* o$ |<P><FONT color=#0000ff>/* check for and report any graphics errors */
; H, R  p( c9 c+ @, u- Kvoid checkerrors(void)
% E& M  @# _1 S) t& Q1 E9 i{
: m# K6 P' }1 A0 X# U6 Aint errorcode; </FONT></P>
) W6 \% O3 f1 L, U, }<P><FONT color=#0000ff>/* read result of last graphics operation */
( j1 v* o( F6 t% [errorcode = graphresult(); ( ?3 r+ X( h. P6 g" V
if (errorcode != grOk)
( k: v9 f! M3 Z+ E9 ?{
+ p% A4 T4 s# P9 b* n4 w! @) @printf("Graphics error: %s\n", grapherrormsg(errorcode)); 6 I% I1 `$ v$ h  N0 x- b: O9 v
printf("Press any key to halt:");
! a  M' \3 k4 m6 ogetch();
7 d! I. i! S' S1 L% R3 h' fexit(1);
; _. G# l: p$ x; a, a+ T}
7 c0 H% l, r: p  O( ~  h' O4 c7 q4 c} </FONT></P>9 F0 v8 X! |$ O7 T# c  I
<P><FONT color=#ff0000>函数名: installuserfont </FONT>
7 \$ m1 \: c2 l5 w- y1 ?功 能: 安装未嵌入BGI系统的字体文件(CHR)
% N8 p; L6 {- k1 O: X用 法: int far installuserfont(char far *name);
6 A1 C9 v" y1 N8 T程序例: </P># `% _! X1 ]$ t
<P><FONT color=#0000ff>#include <GRAPHICS.H>
3 i- [1 Y) f; ~7 A: y% F#include <STDLIB.H>
5 J# c0 I/ [5 i$ x6 R6 a#include <STDIO.H>
$ _' s$ K: n: `  F#include <CONIO.H></FONT></P>, S/ L7 ?6 \! X1 U; Q5 |
<P><FONT color=#0000ff>/* function prototype */ 7 t& o, {; F7 `3 l$ T" ~
void checkerrors(void); </FONT></P>
$ k- E- y$ p- i$ r8 @2 |5 I* o<P><FONT color=#0000ff>int main(void)
9 C+ N, l' l  ]) ?) r1 g+ b+ J{ . e0 P. k' x  c& t4 U9 \
/* request auto detection */
# h' w- y3 Z# yint gdriver = DETECT, gmode; . Y# F, |* K) y% M
int userfont; - G0 X/ a1 f; b2 J9 S! ]
int midx, midy; </FONT></P>" o# }% b$ l+ k! \; R1 |7 j0 i
<P><FONT color=#0000ff>/* initialize graphics and local variables */
( T+ x0 p4 }, b( p, Ginitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
0 T  |& U% G4 X7 U1 S/ q2 Q<P><FONT color=#0000ff>midx = getmaxx() / 2; $ T$ @! H3 x" v% y% `
midy = getmaxy() / 2; </FONT></P>/ C3 i3 l9 Z" N6 |' C$ b+ t
<P><FONT color=#0000ff>/* check for any initialization errors */
% f6 ~9 C1 O( M& c7 k" m4 ycheckerrors(); </FONT></P>1 j( r1 F. T* O. o8 F7 ~9 d5 x6 T
<P><FONT color=#0000ff>/* install a user defined font file */ 4 w' U. z6 Z2 G* W: x9 Y6 z# N; V
userfont = installuserfont("USER.CHR"); </FONT></P>; _5 S) s' ^9 {
<P><FONT color=#0000ff>/* check for any installation errors */ / t; D) E1 A4 j
checkerrors(); </FONT></P>: n; v2 |" R2 k% X! S
<P><FONT color=#0000ff>/* select the user font */ " s' P4 V1 K6 g1 Z: v
settextstyle(userfont, HORIZ_DIR, 4); </FONT></P>
( s3 n9 b1 ~7 W+ \% C- y: p<P><FONT color=#0000ff>/* output some text */ / s: \, _8 Z9 v1 u& L* I% t
outtextxy(midx, midy, "Testing!"); </FONT></P>
+ n7 G# I2 I$ e& S<P><FONT color=#0000ff>/* clean up */
& l$ f9 S6 `$ \5 H+ O7 l( hgetch(); ! r: b% ^. Q# f) {7 J& Z
closegraph();
* g. g3 J2 o0 e. preturn 0;
3 P4 G4 c6 L$ r} </FONT></P>  a, x1 m1 w5 b
<P><FONT color=#0000ff>/* check for and report any graphics errors */
' D' D& q6 n/ @void checkerrors(void)
" z  M" |+ T- Y6 S# z6 H{
6 ?* `6 p8 W9 Uint errorcode; </FONT></P>
" ^( a  g/ A4 r& z6 T<P><FONT color=#0000ff>/* read result of last graphics operation */ ; L. D) R/ e+ _2 e- b2 t
errorcode = graphresult(); 5 \8 _: W2 V  R( n
if (errorcode != grOk) 6 z3 F. z# ?& Q$ u" `+ P% E: [
{ 0 m' ]  e9 m# F4 f9 @  Q/ G$ s  `
printf("Graphics error: %s\n", grapherrormsg(errorcode));
% V! V1 U9 h9 [0 sprintf("Press any key to halt:");
' `$ C- j) Y1 J1 I$ @% r7 zgetch();
' z& U4 h1 D! M1 u$ K; N+ G5 Nexit(1); 0 W0 N1 y" V; i/ g; ]
}
$ G) n: ~5 }% n7 Y* w} </FONT>! I, ^: \3 v" L9 E

  R5 s/ J( F" G' I4 t+ R( B4 `" j4 @$ \
</P>
% G/ T/ c; T/ ?<P><FONT color=#ff0000>函数名: int86 </FONT>
, X  \( V4 }5 I9 J- ~功 能: 通用8086软中断接口
" C- {' w+ [; N, {( G& |用 法: int int86(int intr_num, union REGS *inregs, union REGS *outregs); # f; l- e! p1 D/ |" l) E
程序例: </P>
. a: ^3 k7 ~$ b4 S<P><FONT color=#0000ff>#include <STDIO.H>+ A& {: V1 j+ Y8 z& Y
#include <CONIO.H>
3 e! o) @3 n) A, |& x! S#include <DOS.H></FONT></P>
4 }; \1 I; H" z" _. g" R' v( Q<P><FONT color=#0000ff>#define VIDEO 0x10 </FONT></P>
! J" d5 K& s6 D7 o<P><FONT color=#0000ff>void movetoxy(int x, int y)
+ \: O1 ^3 o8 T{
. y, Z* }7 W0 l1 k+ ^( Yunion REGS regs; </FONT></P>
  Q# k' [( `  L/ M9 |<P><FONT color=#0000ff>regs.h.ah = 2; /* set cursor postion */
5 d7 y# S' X: p/ ~' Dregs.h.dh = y;
. U  d2 X3 _7 _+ R7 `regs.h.dl = x; " n9 |8 C  L2 n" ?: P2 r
regs.h.bh = 0; /* video page 0 */ 3 B: T  T8 k4 `6 F1 k) R
int86(VIDEO, &reg;s, &reg;s);
# x  Z5 R: M) _! ?1 t' E} </FONT></P>
- k* y$ {) L& }# r6 z: @/ k) Z<P><FONT color=#0000ff>int main(void) " f* i) e3 s, u& a9 r
{
" K( S6 H3 W* T' c% S( [8 Vclrscr();
6 S; H3 L/ u2 T' A( ?movetoxy(35, 10);
. n  X! [8 m. c% S( Dprintf("Hello\n"); . i+ N7 o8 L& P1 ]- @1 q
return 0; 5 m. S# U, m) i5 w
} </FONT>8 q5 C3 [& O8 R/ l

1 j' y8 o% Z* ~' u2 a+ M</P>; o2 C$ H5 J% I5 S. B
<P><FONT color=#ff0000>函数名: int86x </FONT>6 n0 J- J- e  s6 u( H
功 能: 通用8086软中断接口
9 L/ k4 L; h. s6 _' s$ X5 p! e用 法: int int86x(int intr_num, union REGS *insegs, union REGS *outregs, # |! I1 G1 x9 d- F
struct SREGS *segregs);
( a2 y2 U' |7 e+ t* v程序例: </P>
6 u2 t) r% z" S5 _4 ?6 K# J  D/ `6 @<P><FONT color=#0000ff>#include <DOS.H>; B: N/ r  n7 r. t4 E
#include <PROCESS.H>
1 B0 L( W# l( \0 p! q/ I#include <STDIO.H></FONT></P>
/ W: D' W2 n. ^; A6 {9 S<P><FONT color=#0000ff>int main(void)   n( U( }" r! a& n# ?6 S
{
+ l3 p2 w* X/ E) X1 Y$ C. Kchar filename[80];
' ~; X% {( |1 K) {union REGS inregs, outregs;
. `" L( u! u/ S6 D7 f5 ?struct SREGS segregs; </FONT></P>
5 M& {. \* W* H5 y6 N% Q<P><FONT color=#0000ff>printf("Enter filename: ");
7 e4 d3 h  ?! ogets(filename); " |7 Z& w% n1 ]7 J
inregs.h.ah = 0x43;
7 ~- ~6 O  }/ v9 ?& {2 {inregs.h.al = 0x21; 1 ^4 y! ~# h6 Y% ?6 Q+ B! Z
inregs.x.dx = FP_OFF(filename); 3 ~) G$ ~* j3 y5 ]' h+ W7 a( u
segregs.ds = FP_SEG(filename);
# a/ w( F3 d' r9 oint86x(0x21, &amp;inregs, &amp;outregs, &amp;segregs);
& P8 g0 d6 v4 }- k! tprintf("File attribute: %X\n", outregs.x.cx); * g2 z$ b- M/ T) Q5 G; A9 X0 t
return 0; 0 n# J9 \8 K9 C& P$ N+ j
}
. L; E' ?+ B: x3 W3 b% i9 i+ A$ m1 i4 F- D9 Z2 m( ^
</FONT>
4 N0 ]0 T4 s) L  G8 F* v+ O; N</P>; S# J3 N# ^3 ~+ p
<P><FONT color=#ff0000>函数名: intdos </FONT>( u4 f$ C6 f9 C
功 能: 通用DOS接口
5 G& X& D0 T" P( _" w/ t. h% e用 法: int intdos(union REGS *inregs, union REGS *outregs);
% I5 z8 r, _5 I+ E  L1 \* {* n; @/ u程序例: </P>
5 m1 _' B+ D6 q, d6 g! u$ {! U<P><FONT color=#0000ff>#include <STDIO.H>
) P. K  g1 Y; A; O#include <DOS.H></FONT></P>
8 ]9 ]4 P: I9 _9 L9 r" x- G4 C7 {<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */   |; C. a7 c8 G) t5 k: s4 K
int delete_file(char near *filename)
3 d  W, B) e4 I% J4 @{
, n1 X2 o5 I4 M. n2 S7 q# Yunion REGS regs; $ Q7 }& r  a3 [& J9 P
int ret;
* J0 M3 {% {/ wregs.h.ah = 0x41; /* delete file */
: v1 z& j4 n5 I. w: }0 N5 @regs.x.dx = (unsigned) filename; . a! S7 e+ W+ t7 i; \
ret = intdos(&reg;s, &reg;s); </FONT></P>
' x* Z4 C0 l8 c) ?* b( w) \<P><FONT color=#0000ff>/* if carry flag is set, there was an error */
# r& M! B' c8 [* k' Vreturn(regs.x.cflag ? ret : 0); + `9 t" w. m& a; V+ ~
} </FONT></P>
! l/ s; \; a8 g. u' ?- ]<P><FONT color=#0000ff>int main(void)
- T. \! ^4 o% I# E7 ?{ 8 i. b; T) v+ M: L7 w
int err;
4 G% J$ l4 u5 ~/ g9 s" U6 T  jerr = delete_file("NOTEXIST.$$$");
1 k, ^+ ]! \/ y0 c0 c5 x" `( V: t8 ]if (!err) % Z2 x: h. ]5 |5 e! b% Q
printf("Able to delete NOTEXIST.$$$\n");
) H, ]& D$ _0 [2 L' O  Relse
& G$ b+ J* {8 w# k' O% ~& `% E$ oprintf("Not Able to delete NOTEXIST.$$$\n");
5 v/ {# F( q2 }# l/ W8 H. f! w! K6 rreturn 0; + }* j4 P0 `4 v, ]+ ~! i  v% `% k
}
" }+ f  s/ V$ J, t6 C/ g
, X3 `0 s% q% m</FONT>. w) |; e2 @$ _% B
</P>8 ?& r0 I! W( e  m& \  z
<P><FONT color=#ff0000>函数名: intdosx </FONT>* s0 _  |8 s9 E1 l* S
功 能: 通用DOS中断接口 # F( ~$ j* D: m! y- ~
用 法: int intdosx(union REGS *inregs, union REGS *outregs,
% ?  z: [' ?1 Z* Z! ~struct SREGS *segregs);
# ]; j: h* {) q' i8 N9 N9 g程序例: </P>1 a, K- a# ]/ v2 ]
<P><FONT color=#0000ff>#include <STDIO.H>
7 i  X' Y5 c: W; s#include <DOS.H></FONT></P>( B- S  Y- V% L) ^" \) t. p
<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */ : Y, |+ i# T: l
int delete_file(char far *filename)
) W1 r* Y2 g+ |( l* A2 g{ 8 B4 ^, J0 L# s) N3 @
union REGS regs; struct SREGS sregs; 1 ?+ ]$ l$ _0 Z, G0 D: Q
int ret; . A$ `8 @7 O) [8 s  u7 x
regs.h.ah = 0x41; /* delete file */ , p- d7 @$ v( \  Q% `
regs.x.dx = FP_OFF(filename); , n, R4 B5 x7 N  D9 X, ^; p
sregs.ds = FP_SEG(filename);
+ [& v& Z9 z; Mret = intdosx(&reg;s, &reg;s, &amp;sregs); </FONT></P>1 j0 x6 [5 B) U6 O$ b
<P><FONT color=#0000ff>/* if carry flag is set, there was an error */ 8 R" _$ ~: q; o' Q
return(regs.x.cflag ? ret : 0); ) e2 V, l6 M; ~( f1 t8 x- A
} </FONT></P>
( j" P' S( y. p5 X+ Y0 O<P><FONT color=#0000ff>int main(void) # ?: ]. x% _2 H9 p: L
{
9 V4 U2 f1 |* i! x, A; Xint err; 4 d1 z/ e+ H/ R) g) j
err = delete_file("NOTEXIST.$$$");
8 b; `" p6 [7 L1 P8 gif (!err) 6 J7 H7 s, ?! X
printf("Able to delete NOTEXIST.$$$\n"); ' R$ z1 Q! W, Y" S5 {
else 3 \& ]; h2 P1 \0 N2 Z% W# \) O
printf("Not Able to delete NOTEXIST.$$$\n");
) \$ z( U4 E7 i; q% f$ n$ Yreturn 0; & q: w/ g3 E3 X% z
}
* }+ v# Z; Y( Y% J: d/ v* y</FONT>; [! {( h: O5 L
</P>
  @6 l8 c- b* g5 Q! D<P><FONT color=#ff0000>函数名: intr </FONT>
+ w9 R  k/ q% u0 a9 S. y功 能: 改变软中断接口
2 D7 z" @& P+ A/ i6 D6 i" z用 法: void intr(int intr_num, struct REGPACK *preg);
1 [% @$ f& h" Q# m! D; C程序例: </P>
# I# r0 Q# p$ T. N: {% z; e<P><FONT color=#0000ff>#include <STDIO.H>
3 b" u  w# p/ \7 g8 u' ]3 ]8 F8 A#include <STRING.H>/ q/ _& {6 D. Z  m- q
#include <DIR.H>
' I$ j2 V! k2 k$ B. G. H4 S+ W1 P#include <DOS.H></FONT></P>
) n: \+ H. i1 a, n7 e<P><FONT color=#0000ff>#define CF 1 /* Carry flag */ </FONT></P>3 X  Q' H4 M% J
<P><FONT color=#0000ff>int main(void) # s/ c/ a6 l  C6 C0 Q
{ 5 P: Y9 e/ @8 I1 q
char directory[80];
- J1 P; u9 x* B+ b: O2 gstruct REGPACK reg; </FONT></P>0 ~0 i, B4 e6 d  d
<P><FONT color=#0000ff>printf("Enter directory to change t "); 8 I6 w. f4 {, i9 [( y. U# Y
gets(directory); / {5 H  H* J0 G4 i! Y& l
reg.r_ax = 0x3B &lt;&lt; 8; /* shift 3Bh into AH */
3 L- O, v1 h8 f9 p: mreg.r_dx = FP_OFF(directory);
$ z% Q) D! T+ Q. z5 Zreg.r_ds = FP_SEG(directory);
7 R6 q) ?% _/ h) Yintr(0x21, &reg;);
( m% f# r( @# t4 h8 wif (reg.r_flags &amp; CF) ' A4 G/ ^' d, B1 t! Z% C4 U
printf("Directory change failed\n"); + G9 W# D' x" ?7 h. Q' S7 V! A1 v% ^
getcwd(directory, 80);
3 l' q6 q6 d  kprintf("The current directory is: %s\n", directory); # ?+ m. e* _7 X7 w: C9 ^) B
return 0; / `% H( T; Q; a2 Y0 d/ Y" \
} & ~3 L, n$ `* r. ^( ^4 ]$ A
</FONT>; [# T$ D4 K+ u" x6 Y% w
</P>
# b1 E# X2 i. o<P><FONT color=#ff0000>函数名: ioctl </FONT>: ^! j- i" A" H
功 能: 控制I/O设备
+ Q8 b1 b6 G7 u# O用 法: int ioctl(int handle, int cmd[,int *argdx, int argcx]); * D% P* S, Z7 g9 i+ a* M' t
程序例: </P>( }8 V( u$ l& v# Y% _% `
<P><FONT color=#0000ff>#include <STDIO.H>' }5 x- y4 `2 I+ T& r
#include <DIR.H>
4 W$ L$ \; b7 |, X#include <IO.H></FONT></P>
: i- I( p# I$ ^! R8 N; [% D" S<P><FONT color=#0000ff>int main(void)
2 N6 d1 A0 D, v0 t9 |{ 5 ^' l1 R. x- I: g5 a
int stat; </FONT></P>; K8 \3 K* f2 t6 s) H8 r
<P><FONT color=#0000ff>/* use func 8 to determine if the default drive is removable */
9 ~- s) t( u; m, P* @( gstat = ioctl(0, 8, 0, 0);
4 B% }; g9 L7 uif (!stat) 6 {1 @7 j2 P0 T% i* ?+ K: r
printf("Drive %c is removable.\n", getdisk() + 'A');
& p! H2 B: d# d4 ~) \+ _else
  Q$ {2 u" L! T0 e( Jprintf("Drive %c is not removable.\n", getdisk() + 'A');   f, o" A$ c# [9 G# s4 {& Q
return 0;
: g3 U6 l& f' z6 r}
5 j0 G: |) L8 w- j$ R& G5 H3 A* c7 O
% Y- ~& K. ^) @/ s4 q; h& v</FONT>
+ A9 ~$ P" p* \# r( e0 o  P4 `</P>
9 E2 k. V! ?% K% }2 V7 L7 }' G% G0 d<P><FONT color=#ff0000>函数名: isatty </FONT>
6 h' I, {4 o+ i; H功 能: 检查设备类型 $ o3 d5 s: w- U- ~) t% _
用 法: int isatty(int handle); 0 X( Q) W- {- H; R
程序例: </P>
, h, l3 ~% ], U1 v7 S<P><FONT color=#0000ff>#include <STDIO.H>0 d& @9 y: G% M% N# p
#include <IO.H></FONT></P>
0 D4 ~" P. q( y9 t0 W$ G/ {<P><FONT color=#0000ff>int main(void) 8 n8 O' @8 I$ ~+ |$ C
{ - C1 u2 i# ?0 i0 T9 x
int handle; </FONT></P>  A$ R6 U5 Q2 x, {* g+ _
<P><FONT color=#0000ff>handle = fileno(stdprn);
! Z* b/ G7 V* O6 P+ Z1 @; b4 l/ N/ Nif (isatty(handle)) 7 d& [6 a) Y/ Y, ?* u* r+ o: G
printf("Handle %d is a device type\n", handle); " ?  o: ~) m. K/ b# @! e" M; v& n9 j
else & L1 Z8 t1 e9 \8 t/ B- x
printf("Handle %d isn't a device type\n", handle); - L+ ~) ~/ P- M! u5 g' }
return 0;
' ^$ t3 _/ ^& C+ {+ ~/ T7 ]$ l$ P0 H9 ]} 1 A3 f7 x, w' n5 M0 ]( `3 V

' f- c4 h9 x9 j</FONT>: T9 h7 k+ P7 W/ Y" y# ^+ ^
</P>' a) O4 z0 H0 N5 n
<P><FONT color=#ff0000>函数名: itoa </FONT>
  ~7 w0 @+ U5 G7 F0 `& u功 能: 把一整数转换为字符串
5 E  Z7 b; S4 o! l8 V- F  I用 法: char *itoa(int value, char *string, int radix);
$ u8 J% C" l3 p! s2 l: e- V程序例: </P>
/ z% a, m3 _8 I1 }7 _8 ~5 J$ j# P<P><FONT color=#0000ff>#include <STDLIB.H>7 _0 F% E+ w' u
#include <STDIO.H></FONT></P>
3 U9 _* O9 \7 y<P><FONT color=#0000ff>int main(void)
, E  E6 \. V, `0 L+ d; z: c0 A{ 3 Y0 A; K9 O& ^2 b
int number = 12345; ! s& q# E$ n& [& v( X- Y+ ]% ~$ b
char string[25]; </FONT></P>6 T$ e; b  n: |: S% f4 k% r) C
<P><FONT color=#0000ff>itoa(number, string, 10); : P+ N8 P. I' U1 _1 i( h) @: M; [# {
printf("integer = %d string = %s\n", number, string); ( ^9 y( r1 V/ D
return 0; " K! C1 z; ?2 b" _3 L3 E4 b4 n' E8 Z
} </FONT><FONT color=#0000ff>& c* I% ]- h( D8 i/ u
</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-10-24 07:59 , Processed in 0.434076 second(s), 51 queries .

回顶部