DosDevIOCtl() Category 5 Subfunction 66H Fails with C 6.00 API

ID Number: Q61872

6.00 6.00a 6.00ax | 6.00 6.00a

MS-DOS | OS/2

buglist6.00 buglist6.00a buglist6.00ax

Summary:

The DOS version of DosDevIOCtl() Category 5 Subfunction 66H, found in

the API.LIB shipped with Microsoft C versions 6.00, 6.00a, and 6.00ax,

fails in native DOS. The failure consists of returning an invalid

printer status byte, regardless of the printer's current status.

More Information:

The DosDevIOCtl() function is used to determine printer status.

Although the function seems to work correctly when used from either

OS/2 or the DOS compatibility box of OS/2, it fails when run from

native DOS. When called, this function sets the value pointed to by

its first parameter to a status byte whose bits have the following

significance.

Bit(s) Significance (If Set)

------ ---------------------

0 Timed Out

1-2 Reserved

3 I/O error

4 Printer selected

5 Out of paper

6 Acknowledge

7 Printer not busy

The failure of this function results in a status byte value of 2 being

returned from the function regardless of the printer's status. This is

particularly bad because 2 is not even a valid return value for this

function. If the Microsoft C version 5.10 API.LIB is used, the

function works correctly, returning a status of 144 if the printer is

ready and 24 if the printer is off line. The only known workaround is

to use the earlier version of the library for this function call.

To reproduce the problem, create a bound version of the sample program

below using the C 6.00 API.LIB and run it on a computer physically

connected to a printer under native DOS.

Microsoft has confirmed this to be a problem in C versions 6.00,

6.00a, and 6.00ax. We are researching this problem and will post new

information here as it becomes available.

Sample Code

-----------

#define INCL_DOSDEVICES

#define INCL_DOSFILEMGR

#include<os2.h>

#include<stdio.h>

void main(void)

{

int handle;

unsigned char pfstat,x=0;

unsigned short actiontaken;

unsigned short p;

p=DosOpen("lpt1",&handle,&actiontaken,0l,0,0x0001,0x0041,0l);

p=DosDevIOCtl(&pfstat,&x,0x0066,0x0005,handle);

printf("pfstat=%d \n",(int)pfstat);

}