Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!husc6!bloom-beacon!tut.cis.ohio-state.edu!rutgers!att!alberta!lake From: lake@alberta.UUCP (Robert Lake) Newsgroups: comp.sys.ibm.pc Subject: Determining if a printer is available Message-ID: <2165@pembina.UUCP> Date: 26 Mar 89 22:01:19 GMT Organization: U. of Alberta, Edmonton, AB Lines: 30 I am trying to determine if a line printer is attached to my PC. I am using the Lattice C (Version 3.0) compiler and I have code similar to the following: #include main() { FILE *prdev; if ((prdev = fopen("prn", "w")) == NULL) { printf("Cannot open line printer\n"); exit(1); } fprintf(prdev, "This is a test\n"); ... } The problem with the above is that the fopen always succeeds, even if there is no printer attached to my PC. Is there a Lattice C subroutine I have missed which can determine if a printer is attached and on-line? Or what must I do to determine this myself? I have tried using onerror(), but this will suppress the DOS error messages only after I have tried to write data to the printer. I would like to print a suitable error message before I write any data. Thanks in advance for any advice and suggestions. Rob Lake (alberta!lake) University of Alberta