Re: Readfile hangs while trying to read the response from printer
On Jan 11, 10:32 pm, "Sam Hobbs"
<sam...@social.rr.com_change_social_to_socal> wrote:
You can also use asynchronous/overlapped IO and then wait for input, but y=
ou
can do other things in addition to wait.
The printer driver probably has a way to determine if input is available,
but you must refer to the documentation; we don't know what the
documentation for your printer driver says.
"hari" <haricib...@gmail.com> wrote in message
news:722ce690-2dde-4acd-ad74-93b772f9cec7@v46g2000hsv.googlegroups.com...
Hi all,
Im trying to send a comamnd to the printer and read the
response for it thru parallel port(LPT1:). The write file always
succeeds, but in readfile it goes to hanging state. I have given my
code below.
int g;
HANDLE h;
DWORD NumberOfBytesWritten,NumberOfBytesRead;
unsigned char buff1[12];
unsigned char buff_read[30];
h = CreateFile("LPT1:",
GENERIC_READ | GENERIC_WRITE=
,
FILE_SHARE_READ,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL |
FILE_FLAG_SEQUENTIAL_SCAN,
NULL);
if (h == INVALID_HANDLE_VALUE)
{
g= 0;
return 0;
}
else
{
g=1;
buff1[0] = '{';
buff1[1] = 'W';
buff1[2] = 'B';
buff1[3] = '|';
buff1[4] = '}';
i = WriteFile(h,buff1,5,&NumberOfBytesWritten ,NULL);
i =ReadFile(h,buff_read,2,&NumberOfBytesRead,NULL);
CloseHandle(h);
return 400;
}- Hide quoted text -
- Show quoted text -
Th problem is,if the printer driver is installed in LPT1: and if we
are trying to do readfile from other application in LPT1.It goes to
hanging state