本文介绍了使用_outp()时出现未处理的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用_outp(0x378,0xAA)在Windows 7中以C语言在计算机的并行端口中写入数据,它已编译,但在运行时给出了以下错误,
"Parallel_Port.exe中0x00d413c5处未处理的异常:0xC0000096:特权指令"
谁能建议我该怎么做.
谢谢&问候
Mohan
Hi,
I''m using _outp(0x378,0xAA) for writing data in the parallel port of the computer in C language in Windows 7, it gets compiled but it gives the below error at run time,
"Unhandled exception at 0x00d413c5 in Parallel_Port.exe: 0xC0000096: Privileged instruction"
Can anyone suggest me what I have to do.
Thanks & Regards
Mohan
推荐答案
#include <windows.h>
#include <stdio.h>
void main(void)
{
HANDLE hPort = CreateFile("LPT1",GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
if(hPort != INVALID_HANDLE_VALUE){
char buffer[5] = {''h'',''e'',''l'',''l'',''o''};
unsigned long count;
if(WriteFile(hPort, buffer, 5, &count, 0))
printf("Write succesful.\n");
else
printf("Write failed\n");
CloseHandle(hPort);
}
else
printf("Unable to access LPT1.");
}
这篇关于使用_outp()时出现未处理的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!