B
Brett Mostert
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;
}
}
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;
}
}