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 AddPrinterDrive r(string strServerName)
{
try
{
strServerName = "";
PrintMasterClas s oPrinterMaster = new PrintMasterClas s();
object oRefDriver = strServerName;
object oDrivers;
oDrivers = oPrinterMaster. get_Drivers(ref oRefDriver);
DriverCollectio n oDriverCollecti on = (DriverCollecti on)oDrivers;
foreach (Driver oDriver in oDriverCollecti on)
{
System.Windows. Forms.MessageBo x.Show(oDriver. MonitorName);
System.Windows. Forms.MessageBo x.Show(oDriver. ConfigFile);
System.Windows. Forms.MessageBo x.Show(oDriver. DataFile);
System.Windows. Forms.MessageBo x.Show(oDriver. DriverVersion);
System.Windows. Forms.MessageBo x.Show(oDriver. DriverArchitect ure);
System.Windows. Forms.MessageBo x.Show(oDriver. Environment);
System.Windows. Forms.MessageBo x.Show(oDriver. HelpFile);
System.Windows. Forms.MessageBo x.Show(oDriver. InfFile);
System.Windows. Forms.MessageBo x.Show(oDriver. ModelName);
System.Windows. Forms.MessageBo x.Show(oDriver. Path);
System.Windows. Forms.MessageBo x.Show(oDriver. ServerName);
System.Windows. Forms.MessageBo x.Show(oDriver. Version.ToStrin g());
}
return true;
}
catch (Exception err)
{
System.Windows. Forms.MessageBo x.Show(err.Mess age.ToString() + " | " +
err.ToString() + "|" + err.Source.ToSt ring());
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 AddPrinterDrive r(string strServerName)
{
try
{
strServerName = "";
PrintMasterClas s oPrinterMaster = new PrintMasterClas s();
object oRefDriver = strServerName;
object oDrivers;
oDrivers = oPrinterMaster. get_Drivers(ref oRefDriver);
DriverCollectio n oDriverCollecti on = (DriverCollecti on)oDrivers;
foreach (Driver oDriver in oDriverCollecti on)
{
System.Windows. Forms.MessageBo x.Show(oDriver. MonitorName);
System.Windows. Forms.MessageBo x.Show(oDriver. ConfigFile);
System.Windows. Forms.MessageBo x.Show(oDriver. DataFile);
System.Windows. Forms.MessageBo x.Show(oDriver. DriverVersion);
System.Windows. Forms.MessageBo x.Show(oDriver. DriverArchitect ure);
System.Windows. Forms.MessageBo x.Show(oDriver. Environment);
System.Windows. Forms.MessageBo x.Show(oDriver. HelpFile);
System.Windows. Forms.MessageBo x.Show(oDriver. InfFile);
System.Windows. Forms.MessageBo x.Show(oDriver. ModelName);
System.Windows. Forms.MessageBo x.Show(oDriver. Path);
System.Windows. Forms.MessageBo x.Show(oDriver. ServerName);
System.Windows. Forms.MessageBo x.Show(oDriver. Version.ToStrin g());
}
return true;
}
catch (Exception err)
{
System.Windows. Forms.MessageBo x.Show(err.Mess age.ToString() + " | " +
err.ToString() + "|" + err.Source.ToSt ring());
return false;
}
}
Comment