Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

I need help in trying to check whether a printer is connected to the PC before sending my print job.

 

Currently, when my C# application sends a print job, the windows print spooler will just accept it regardless of whether the printer is actually connected to the PC or not. (Pls note: the printer is a parallel port printer)

 

I've tried using WMI (Win32_Printer, Win32_PrintJob) to get the status, however they don't reflect the "real" status of the printer or the print job.

 

I am aware that there is Win API functions to send the print data directly to the printer, however, in my case, I'm using a Crysal Report Print Function which combines my .rpt, .xml and .xsd files before sending the print job to the printer.

 

Thanks for all help!

  • *Experts*
Posted

Can you use something as simple as Printer.IsValid()?

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • *Experts*
Posted

It's a static method on the Printer object, part of the framework. I use it to verify that a string ("\\server\printer name") is a valid printer name before I pass it onto some 3rd party software. I get the strings from a database table and you can't ever trust your users to cut and paste things right :)

 

I know it works to locate a printer, but I don't think it will give you any kind of status. I also don't know of any way to determine if the printer is locally connected or not. I would guess you could, just never had the need.

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...