Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
More than just getprinter()
Message
De
23/11/1999 04:43:35
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00294127
Message ID:
00294243
Vues:
31
>I have a problema:
>getprint() always returns .t.
>Even if my printer is OFF
>
>A friend of mine sent me the following code:
>
>
>handle=FOPEN('lpt1.dos',11)
>IF FWRITE(handle,CHR(27)+'@') = 0
> FCLOSE(handle)
> MESSAGEBOX('Impressora desligada!',48,'Erro')
>ENDIF
>
>
>However the opposite happens
>it always returns 0
>it means it will say printer is OFF
>even if printer is ON
>
>What's wrong with the code above

The problem is likely that the machine doesn't recognize the device lpt1.dos - for example, my NT box won't recognize the device reference, and if I correct it to make the proper reference to the device for NT, which would be 'lpt1.dos:', it returns a -1 to the FOPEN, so that the FWRITE always fails. If I work with Win98, and address a printer port controlled by the Windows Print Spooler, the FOPEN() and FWRITE() always succeed.

I'm assuming that you meant PRINTSTATUS() rather than GETPRINT() always returns .T. - that's the behavior documented in the Help File. GETPRINT() fires up the Printer dialog and returns the name of a printer.

There is no direct way using just VFP to check the printer port - you need much lower-level device control than is available, since VFP writes via the print spooler, and the device naming conventions vary by operating system. The print status is hidden by the spooler, and it gets worse with network attached pritners, since there are generally two spoolers involved - your local spooler and the spooler on the remote print server.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform