1,221
社区成员
发帖
与我相关
我的任务
分享
/*
//从并行端口读取打印机状态
function GetPrinterStatus:byte;
asm
MOV DX,$379;
IN AL,DX;
end;
//获取打印机是否出错
function CheckPrinter:boolean;
var
temp:byte;
begin
temp:=GetPrinterStatus;
Result:=not ( ((temp and $80)=0) //打印机忙
or ((temp and $20)<>0) //打印机缺纸
or ((temp and $10)=0) //打印机未联机
or ((temp and $08)=0) ); //打印机出错;
end;
*/
unsigned char GetPrinterStatus()
{
asm
{
MOV DX,0x379
}
}
bool LptPrint(char prtdata[],int prtlen,int timeout)
{
HANDLE h;
DWORD n;
COMMTIMEOUTS t;
bool result=true;
h = CreateFile("lpt1", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
if (h == INVALID_HANDLE_VALUE){
//AfxMessageBox("Can not open lpt1");
return false;
}
t.ReadIntervalTimeout = 0;
t.ReadTotalTimeoutMultiplier = 0;
t.ReadTotalTimeoutConstant = 0;
t.WriteTotalTimeoutMultiplier = timeout * 1000 / prtlen;
t.WriteTotalTimeoutConstant = 0;
if (!SetCommTimeouts(h,&t)){
//AfxMessageBox("SetCommTimeout error");
return false;
}
result = true;
/* if (!WriteFile(h,prtdata,prtlen,&n,NULL)){
//AfxMessageBox("Print error");
result = false;
}
*/
CloseHandle(h);
return result;
}