PC Review


Reply
Thread Tools Rate Thread

Problem Enumerating Printer Drivers

 
 
Brett Mostert
Guest
Posts: n/a
 
      24th May 2005
Hi,

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)
{
try
{
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.MonitorName);
System.Windows.Forms.MessageBox.Show(oDriver.ConfigFile);
System.Windows.Forms.MessageBox.Show(oDriver.DataFile);
System.Windows.Forms.MessageBox.Show(oDriver.DriverVersion);
System.Windows.Forms.MessageBox.Show(oDriver.DriverArchitecture);
System.Windows.Forms.MessageBox.Show(oDriver.Environment);
System.Windows.Forms.MessageBox.Show(oDriver.HelpFile);
System.Windows.Forms.MessageBox.Show(oDriver.InfFile);
System.Windows.Forms.MessageBox.Show(oDriver.ModelName);
System.Windows.Forms.MessageBox.Show(oDriver.Path);
System.Windows.Forms.MessageBox.Show(oDriver.ServerName);
System.Windows.Forms.MessageBox.Show(oDriver.Version.ToString());
}
return true;
}
catch (Exception err)
{
System.Windows.Forms.MessageBox.Show(err.Message.ToString() + " | " +
err.ToString() + "|" + err.Source.ToString());
return false;
}
}
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enumerating Printer Drivers Help Please Brett Mostert Microsoft C# .NET 4 25th May 2005 11:27 AM
Problem Enumerating Printer Drivers Brett Mostert Microsoft Dot NET 0 24th May 2005 04:53 PM
Problem Enumerating Printer Drivers Brett Mostert Windows XP Print / Fax 0 24th May 2005 04:53 PM
Enumerating drivers =?Utf-8?B?UGV0ZXIgU2NobWl0eg==?= Microsoft Dot NET 2 20th Apr 2005 11:57 AM
Enumerating drivers =?Utf-8?B?UGV0ZXIgU2NobWl0eg==?= Microsoft Dot NET Framework 2 20th Apr 2005 11:57 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:57 PM.