tags:

views:

240

answers:

3

While I can't get my desktop, running Win7 64, to connect to our network printer, I'd like to be able to paste files, using Input Director, into a share on my laptop. There I'd like a FileSystemWatcher to pick them up and print, then delete them. How can I do thi? I assume I need to hook into the shell somehow, meaning my app can't be a service, but I'm really clueless here.

I've installed Input Director, so I can move my cursor off my desktop desktop screen onto my laptop desktop, and just right click the file to print. However, I am still interested in learning ways to do the printing.

A: 

System.Drawing.Printing will help you do what you want. No need to hook into the shell, so you could do this as a service. Whenever you detect a new file, just ship it off to the printer.

For more involved types (Word documents and such), you can use the Interop libraries to use Word itself to print the document. For example, here is the Interop.Word PrintOut method.

toast
I'm assuming (I know... :-)) that the OP is talking about printing documents from 3rd party applications (Word, Excel, PDF, etc.) in which case I don't think those classes will help.
WaldenL
That's exactly the situation the Interop libraries were created for. I've added a link to the PrintOut method to further demonstrate what I mean.
toast
This would, however, mean my having to find a lookup table to give me the object and print method depending on the registered file type.
ProfK
A: 

Given your requirement (a non-production, non-server solution) why not just have a command-line app that starts on your laptop and does the FileSystemWatcher hook and prints them? Or you could write an app that "lived" in the icon tray.

As for how to print them, that's app by app specific, but for many apps you can let the shell figure it out and use the ShellExecute API with the print operation.

WaldenL
+1  A: 

I suppose it would depend on what you are trying to print, since the app is responsible for rendering a document to the print device, not the shell itself.

Isn't this just the long way round to finding correct drivers for your printer?

Dan
Finding the driver is the long way round. I've installed Input Director, so I can just move my mouse pointer over to the laptop and print. This question is becoming more academic than practical.
ProfK