Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / February 2004

Tip: Looking for answers? Try searching our database.

Adding Printer and Printer Ports (report from framework group)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Williams - 12 Feb 2004 01:34 GMT
I have been attempting to find a way to [programmically] add printers to a
server.  This requires that a new port be added.  I have not been able to
find a means to accomplish this.

I did find some *old* posts for using the AddPortEx/AddPrinter APIs from the
winspool.drv, however, while I can get these to run, they do nothing (i.e.
no entries entered in to the registry, and the port and printers are not
found on the control panel.)  I have confirmed that there is no registry
activaty happenning using RegMon.  ClrSpy tells me that I have an incorrect
calling convention, however, I have tried all combinations of calling
conventions to correct this and it did not.

I would think that something so often required (that of adding/deleting
printers and printer ports) would be in the framework.  Can someone point me
in the right direction?

TIA

David
Kit George (MSFT) - 12 Feb 2004 19:57 GMT
David, I know we're not planning on adding any specific support at this
time on the CLR team. However, you might want to redirect your question to
the windosforms newsgroup, to see if they are planning on adding support on
that side.

Regards,
Kit
Willy Denoyette [MVP] - 12 Feb 2004 20:27 GMT
You can do this using The System.Management classes and WMI.

Willy.
>I have been attempting to find a way to [programmically] add printers to a
> server.  This requires that a new port be added.  I have not been able to
[quoted text clipped - 18 lines]
>
> David
David Williams - 13 Feb 2004 00:41 GMT
Not to sound dumb or anything (though I am when it comes to WMI :) ), how
would I do this via WMI?  I can see how to query for information, but I have
not seen anything that would let me add a printer port and printer.  Can you
point me in the right direction for information on this (not that I would
mind if you just told me ;) ).

TIA

David

> You can do this using The System.Management classes and WMI.
>
[quoted text clipped - 21 lines]
> >
> > David
Corina Feuerstein - 25 Feb 2004 18:30 GMT
Did you try using Win32_Printer::AddPrinterConnection method ?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/
addprinterconnection_method_in_class_win32_printer.asp describes the
method, and your .NET code would look something like this (might need some
adjustment :-) ) :

using System.Management;

ManagementClass printerClass = new ManagementClass("Win32_Printer");
object[] printerName = {"\\myServer\printer1"};
object result = printerClass.InvokeMethod ("AddPrinterConnection",
printerName );

Cori

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.