471,319 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Problem Enumerating Printer Drivers


I need to be able to Enumerate through Printer Drivers, ports, printers
and so fourth. And even add printers, ports, and drivers and setup printers.

Sofar i can do all of the following except anything to do with drivers.

I have added a reference to the PRNADMIN.DLL from MS Windows 2003 Tool
Kit into my project to do all of the above, but when i try to enumerate
printers i received the following error....

The data area passed to a system call is too small.
System.Runtime.InteropServices.ComException (0x8007007A)

Any help please? My code is below. (Basically the same for enumerating
ports - at least that works, even the VB6.0 code given my MS in the
examples throughs the same error)

using PRNADMINLib;

public static bool AddPrinterDriver(string strServerName)
strServerName = "";
PrintMasterClass oPrinterMaster = new PrintMasterClass();
object oRefDriver = strServerName;
object oDrivers;
oDrivers = oPrinterMaster.get_Drivers(ref oRefDriver);
DriverCollection oDriverCollection = (DriverCollection)oDrivers;

foreach (Driver oDriver in oDriverCollection)
System.Windows.Forms.MessageBox.Show(oDriver.Monit orName);
System.Windows.Forms.MessageBox.Show(oDriver.Confi gFile);
System.Windows.Forms.MessageBox.Show(oDriver.DataF ile);
System.Windows.Forms.MessageBox.Show(oDriver.Drive rVersion);
System.Windows.Forms.MessageBox.Show(oDriver.Drive rArchitecture);
System.Windows.Forms.MessageBox.Show(oDriver.Envir onment);
System.Windows.Forms.MessageBox.Show(oDriver.HelpF ile);
System.Windows.Forms.MessageBox.Show(oDriver.InfFi le);
System.Windows.Forms.MessageBox.Show(oDriver.Model Name);
System.Windows.Forms.MessageBox.Show(oDriver.Path) ;
System.Windows.Forms.MessageBox.Show(oDriver.Serve rName);
System.Windows.Forms.MessageBox.Show(oDriver.Versi on.ToString());
return true;
catch (Exception err)
System.Windows.Forms.MessageBox.Show(err.Message.T oString() + " | " +
err.ToString() + "|" + err.Source.ToString());
return false;
Jul 21 '05 #1
0 1234

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Rami | last post: by
1 post views Thread by | last post: by
4 posts views Thread by Brett Mostert | last post: by
4 posts views Thread by Support | last post: by
reply views Thread by Brett Mostert | last post: by
1 post views Thread by pigge79 | last post: by
2 posts views Thread by =?Utf-8?B?Qm9vazIwNDc=?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.