我有一个这样的C程序,#include<dos.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>#define command_8253 0x43
#define timer_8253 0x40void interrupt (*oldproess)();
void interrupt proess();
void modify_8253();
void restore_8253();
double v1=0,v2=0;
int basea=0x280,firstchannel=0,nextchannel=1;void main()
{
FILE *fp;
char str[]={"d:\\user"}; if(chdir(str)==0)
{printf("ok,start collect data\n");}
else
{ system("cd\\");
system("d:");
system("md user");
system("cd user");
}
if((fp=fopen("d:\\user\\2.txt","w"))==NULL)
{exit(0);}
system("cls");
modify_8253();
do{
sleep(1); printf("--------------------------------------\n");
printf("the first data: \t");
printf("%.3f\n",v1);
printf("the second data: \t");
printf("%.3f\n",v2);
fprintf(fp,"%f,%f\n",v2,v1);
}while(!kbhit());
close(fp);
restore_8253();
getch();
}void interrupt proess(void)
{
int i,num1,num2,volt1=0,volt2=0;
disable();
for(i=0;i<20;i++) /*the first*/
{ outportb(basea,firstchannel);
}
do{ }while( !inp(basea+5)&0x80 ) ;
num1=inportb(basea+1);
num2=inportb(basea+2)&0x0f;
volt1=num1+num2*256;
v1=(v1*300+volt1)/301;
/*the second*/
for(i=0;i<20;i++) /*the first*/
{ outportb(basea,nextchannel);
}
do{ }while( !inp(basea+5)&0x80 ) ;
num1=inportb(basea+1);
num2=inportb(basea+2)&0x0f;
volt2=num1+num2*256;
v2=(v2*300+volt2)/301;
outportb(0x20,0x20);
enable();
}void modify_8253()
{
disable();
oldproess=getvect(0x8);
outportb(command_8253,0x36);
outportb(timer_8253,0x51);
outportb(timer_8253,0x09);
setvect(0x8,proess);
enable();
}
void restore_8253()
{
disable();
setvect(0x8,oldproess);
outportb(command_8253,0x36);
outportb(timer_8253,0xff);
outportb(timer_8253,0xff);
enable();
}这是一个数据采集的程序,是用C编的,但是,现在我需要把它在VISUAL C++下通过,我试了几次,都有错误,请问,我如何才能把它在VISUAL C++下通过呢。原程序我已经给出了。如果有必要,请在VISUAL C++下写出来,发到
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>#define command_8253 0x43
#define timer_8253 0x40void interrupt (*oldproess)();
void interrupt proess();
void modify_8253();
void restore_8253();
double v1=0,v2=0;
int basea=0x280,firstchannel=0,nextchannel=1;void main()
{
FILE *fp;
char str[]={"d:\\user"}; if(chdir(str)==0)
{printf("ok,start collect data\n");}
else
{ system("cd\\");
system("d:");
system("md user");
system("cd user");
}
if((fp=fopen("d:\\user\\2.txt","w"))==NULL)
{exit(0);}
system("cls");
modify_8253();
do{
sleep(1); printf("--------------------------------------\n");
printf("the first data: \t");
printf("%.3f\n",v1);
printf("the second data: \t");
printf("%.3f\n",v2);
fprintf(fp,"%f,%f\n",v2,v1);
}while(!kbhit());
close(fp);
restore_8253();
getch();
}void interrupt proess(void)
{
int i,num1,num2,volt1=0,volt2=0;
disable();
for(i=0;i<20;i++) /*the first*/
{ outportb(basea,firstchannel);
}
do{ }while( !inp(basea+5)&0x80 ) ;
num1=inportb(basea+1);
num2=inportb(basea+2)&0x0f;
volt1=num1+num2*256;
v1=(v1*300+volt1)/301;
/*the second*/
for(i=0;i<20;i++) /*the first*/
{ outportb(basea,nextchannel);
}
do{ }while( !inp(basea+5)&0x80 ) ;
num1=inportb(basea+1);
num2=inportb(basea+2)&0x0f;
volt2=num1+num2*256;
v2=(v2*300+volt2)/301;
outportb(0x20,0x20);
enable();
}void modify_8253()
{
disable();
oldproess=getvect(0x8);
outportb(command_8253,0x36);
outportb(timer_8253,0x51);
outportb(timer_8253,0x09);
setvect(0x8,proess);
enable();
}
void restore_8253()
{
disable();
setvect(0x8,oldproess);
outportb(command_8253,0x36);
outportb(timer_8253,0xff);
outportb(timer_8253,0xff);
enable();
}这是一个数据采集的程序,是用C编的,但是,现在我需要把它在VISUAL C++下通过,我试了几次,都有错误,请问,我如何才能把它在VISUAL C++下通过呢。原程序我已经给出了。如果有必要,请在VISUAL C++下写出来,发到
解决方案 »
- 请教一个问题: 我写个软件获取另外一个进程的里Gird的内容
- STL里,如何判断一个iterator是否有效?
- 关于打开和关闭串口的问题!
- 请问在VC里面怎么编译C语言写的绘图的源程序?
- 哪位大侠能帮助我啊,shapefile文件的结构是什么啊,怎么实现他的读取和显示?
- 如何把多幅位图组合成一个位图?
- 如何把CString类型转变成char *类型
- 我在调试程序的时候输出窗口显示:Bad memory block found at 0x0013AB98
- MFC对话框如何设置可用不可用
- 有没有一个将bitmap写成bmp文件的api函数?如有,请说明。
- 关于 插入 ActiveX 控件的问题。
- 怎么做一个线程安全的ACTIVEx控件?
明显是TC的程序,你用TC吧
#include<dos.h>
明显是DOS下的程序
现在VC几乎都是编写WINDOWS程序,你想想要包含DOS,就应该用DOS下编程的工具,比如TC
#include<dos.h>
#include<conio.h>要不你用VC Console建立项目,进行代码Copy即可
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
);只能学习其中的结构,重新写一个