开发者

get a list of local and network printers with c#

开发者 https://www.devze.com 2022-12-15 23:29 出处:网络
I have a web application with asp.net 2.0 and I want to create a dropdown menu showing the printers installed on the client machine? How is that possible?

I have a web application with asp.net 2.0 and I want to create a dropdown menu showing the printers installed on the client machine? How is that possible?

I tried the following code

foreach (string strPrinter in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
{
   // add to list
}

but it shows only the local printers attached with the server, not the client m开发者_如何学JAVAachine.


You can't get it in ASP.NET because that's running on your server. You can't get it in Javascript either. It's just not available; see, for example, http://javascript.about.com/od/events/a/print_3.htm.

The only solution I can think of is to build an ActiveX control, and you then you could use the C# you have in the question, except running on the client. Of course, that limits you to IE.


if you want to show the installed printers on client machine, then you might have to use the javascript as the code you have written will be executed on server side.

0

精彩评论

暂无评论...
验证码 换一张
取 消