΢ͻӦ
MICROCOMPUTER & ITS APPLICATIONS
2000Vol.19No.6P.58-60




Windows̼߳ʵ
ɼļױ̷
ܿ
ժҪWindows̱̼߳DOSݲɼ򡰰1̣߳ùļݣʵWindowsݲɼļױ̡
ؼʣݲɼ Windows ߳ ļ
WindowsѺ÷ḻͼû桢Ĳ۷˸ҵûҵûҲ⣬WindowsϵͳԷռ¼(Ϣ)ΪҪǿ豸޹Է񣬲ûֱӲ豸ûͼWindows¿ݲɼʹϰDOS̵һûе޴֡Ҳ[1][2][3]һЩܺõĽҪϸߵWindowsض(Visual C)ı̼ϤWindowsڲʱĽܵķҲʧΪһּеķ
ʹDOSµBorland CWindowsµBorland C BuilderгƣʹõDOSµBASICPASCALWindowsµVBVCȣͬԲñܵķҪĽǣ(1)κһϤDOSµIO̼͹ļʹ÷(2)κһϤWindowsй̺߳͹ļӦ÷
1  ԭ
Ĳõķͼ1ʾ

ͼ1  ԭͼ
ݲɼͨDOS IOӿڳ򣬶IOڽждݣDOS IOӿڳWindowsӦó֮ȴͨļݡ仰˵IOֱӲȻDOSWindowsӦóֻǶݲɼӿƣӶܿWindowsܶIOֱӶдơ
ĹؼWindowsӦóʵʱIOڵݲдпƣ̺ͨ߳͹ļһ⡣ν̣֮߳ӦóеĶֻ̣Ǵִ壬䴦ʱɲϵͳƶǳơWindowsӦóмDOS IOӿڳ̶߲߳ڼСDOS IOӿڳͨIOڵֱӶдݲɼԲɼݲϸ²ɼļеݡWindowsӦóͬʱӲɼļжȡݣЧͺIOֱӶȡһΪ˶ļͬʱждļԹʽ2Ӧóͬʱ򿪡ļһ棬ҪDOS߳̽пƻ(ֹ߳л򴫵DAݵ)ʱͬʽٽ1ļСϢݡ
2  
2.1 DOS
PCLS718ݲɼΪʹDOSµBorland C̡òɼ2DA16ADͨIOڻַΪ0x3000x3000x301ΪADͨĸߣλݺͨŶ˿ڵַ0x3040x307Ϊ2DAͨĸߣλݶ˿ڵַ
include stdio.h
include dos.h
include STDLIB.H
include conio.h
include share.h
include io.h
typedef unsigned int word
const int BASE0x300 IOڻַ
void main(){
int statusdtldthadladtcregchviTn
word da10x0da20x0
FILE *fADout*fDAin*fCtrl
fDAinfsopen(DAin.dat壬r壬SHDENYNO)
DAļ
fADoutfsopen(ADout.dat壬w壬SHDENYNO)
ADļ
fCtrlfsopen(Ctrl.dat壬r壬SHDENYNO)
򿪿ƹļ
do {
fseek(fCtrlSEEKSET0)
fscanf(fCtrl壥dn壬Tn)
if(Tn0)DOSӵWindowsֹп
֡0ʱִӦ
{
fclose(fDAin)
fclose(fADout)
fclose(fCtrl)
exit(0)
return
}
fseek(fDAinSEEKSET0)
fscanf(fDAin壥d dn壬da1da2) DA
ļжȡDAda1da2
outportb(BASE4(da10xf4)) дDAͨ1
ݵλֵ
outportb(BASE5da14) дDAͨ1
λֵ
outportb(BASE6)da20xf4) дDAͨ2
ݵλֵ
outportb(BASE7da24) дDAͨ2
λֵ
fseek(fADoutSEEKSET0)
i0
do {
outportb(BASE80)
outportb(BASE0)
do {
statusinport(BASE8)
delay(1)
}while((status  0x10)0)
dtlinportb(BASE) ADͨiݵλ
ֵͨ
dthinportb(BASE1) ADͨi
λֵ
adldtl16
adtdth*16adl ADתֵ
chvdtladl16 ADͨ
fprintf(fADout壥d dn壬chvadt)AD
ͨżתֵдADļ
} while(i15)
}while(i1)
ѭԱ֤ɼһֱУյ
֡0Ž
return
}
ɺγɿִļ(Ϊada.exe)WindowsһļѡԡΪСѡ˳ʱرգʹWindowsӦóø̶߳ʱʹWindowsڱDOSдڵֹóʱرDOSڡ
2.2 Windows
ʹWindowsµBorland C BuilderΪƽ̨0.2sʾ1ADͨ5ĲɼݺͽһDAתΪӦĿĽгơ
Form1Ӧó룭
include vcl.h
pragma hdrstop
include dos.h
include STDLIB.H
include conio.h
include io.h
include fcntl.h
include sysstat.h
include share.h
include stdio.h
include thread1.h
pragma package(smartinit)
pragma resource *.dfm
TForm1 *Form1
TadaThread *adaThread
FILE fADout*fDAin*fCtrl
int chvchtda1da2

fastcall TForm1(TForm1(TComponent* Owner)
TForm(Owner)
{
}
Form1ʱӦ¼
void fastcall TForm1::FormCreate(TObject *Sender)
{
adaThreadnew TadaThread)(false) DOS
IOӿڳ߳
adaThreadResume()
fCtrlfsopen(Ctrl.dat壬w壬SHDENYNO)
ݹļ
fseek(fCtrlSEEKSET0)
fprintf(fCtrl壥dn壬1)дֳֵ1
fDAinfsopen(DAin.dat壬w壬SHDENYNO)
DAݹļ
fADoutfsopen(ADout.dat壬r壬SHDENYNO)
ADݹļ
}
ÿ0.2sһεӦ¼
void fastcall TForm1::Timer1Timer(TObject *Sender)
{
da110
da220
fseek(fDAinSEEKSET0)
fprintf(fDAin壥d dn壬da1da2) DA
дDAļ
fseek(fADoutSEEKSET0)
do {
fscanf(fADout壥d dn壬chvcht)
ADļжȡAD任
if(chv5) ADͨΪ5ʱ
{
ListBox1ItemsAdd(FloatToStr(chv)
String (  )FloatToStr(cht))
ڴForm1ListBox1ʾADͨ
5Ĳɼ
break
}
}while(chv15)
}
Form1رʱӦ¼
void fastcall TForm1::FormClose(TObject*Sender
TCloseAction Action)
{
fseek(fCtrlSEEKSET0)
fprintf(fCtrl壥dn壬0)дֹп֡0
fclose(fDAin)
fclose(fADout)
fclose(fCtrl)
}
߳thread1룭
include vcl.h
pragma hdrstop
include thread1.h
pragma package(smartinit)

fastcall TadaThread::TadaThread(bool CreateSuspended)
TThread(CreateSuspended)
{
}

voidfastcall TadaThread::Execute())
{
system(ada.exe)DOS IOӿӦó
}
Ϊȥ˲ɼĳʼͲֹϵ䣬ΪʵӦʱӦӦġݲɼѳɹӦߵĿУWindowsµӦó򿪷Ҳһοֵ
ܿ(ѧϵ97100081)
(ѧϵ97100081)
ο
1£WindowsҵӦ֣̽ҵƼ1997425
2κݲɼķ΢Ϣ199915227
3Ԭ־£VCдWindowsӲIOӿڳ򣮵 ѧϰ1998624
4Telle MBorland C Builder߼ָϣй ˮ磬1998
ոڣ19991220
