473,473 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Enumerating Printer Drivers Help Please

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.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;
}
}
Nov 17 '05 #1
4 6980

"Brett Mostert" <br**********@sebrio.com> wrote in message
news:Ov**************@TK2MSFTNGP10.phx.gbl...
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.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;
}
}


IMO this COM server (prnadmin.dll) has not been designed(tested) to be used
from non-scripting languages (VBS or JS), everything else like VB.NET, C#
and C++ fails to set/get some properties.
Unless you need this to run on NT4, I would suggest you to use
System.Management and WMI for this.

Willy.
Nov 17 '05 #2
Willy Denoyette [MVP] wrote:
"Brett Mostert" <br**********@sebrio.com> wrote in message
news:Ov**************@TK2MSFTNGP10.phx.gbl...
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.Mon itorName);
System.Windows.Forms.MessageBox.Show(oDriver.Con figFile);
System.Windows.Forms.MessageBox.Show(oDriver.Dat aFile);
System.Windows.Forms.MessageBox.Show(oDriver.Dri verVersion);
System.Windows.Forms.MessageBox.Show(oDriver.Dri verArchitecture);
System.Windows.Forms.MessageBox.Show(oDriver.Env ironment);
System.Windows.Forms.MessageBox.Show(oDriver.Hel pFile);
System.Windows.Forms.MessageBox.Show(oDriver.Inf File);
System.Windows.Forms.MessageBox.Show(oDriver.Mod elName);
System.Windows.Forms.MessageBox.Show(oDriver.Pat h);
System.Windows.Forms.MessageBox.Show(oDriver.Ser verName);
System.Windows.Forms.MessageBox.Show(oDriver.Ver sion.ToString());
}
return true;
}
catch (Exception err)
{
System.Windows.Forms.MessageBox.Show(err.Message .ToString() + " | " +
err.ToString() + "|" + err.Source.ToString());
return false;
}
}

IMO this COM server (prnadmin.dll) has not been designed(tested) to be used
from non-scripting languages (VBS or JS), everything else like VB.NET, C#
and C++ fails to set/get some properties.
Unless you need this to run on NT4, I would suggest you to use
System.Management and WMI for this.

Willy.

Hi, first of all thanx for the reply :), but i have tried using VBS
already, and it throws the same error, even the sample microsoft
provides in there .vbs file throws the same error?

Any thoughts?

Thanx
Brett
Nov 17 '05 #3

"Brett Mostert" <br**********@sebrio.com> wrote in message

Hi, first of all thanx for the reply :), but i have tried using VBS
already, and it throws the same error, even the sample microsoft provides
in there .vbs file throws the same error?

Any thoughts?

Thanx
Brett


This works for me on both W2K3 and XP, using prnadmin.dll version 5.2.3790.0
..

Dim oMaster
set oMaster = CreateObject("PrintMaster.PrintMaster.1")
for each oDriver in oMaster.Drivers("")
wscript.echo "DriverName : " & oDriver.ModelName
next

Using any non-scripting language (C++, C#, VB.NET) to enum the drivers fail
with HRESULT 0x8007007A, other interfaces like Printer, Port and Form work
as expected.

Willy.


Nov 17 '05 #4
Willy Denoyette [MVP] wrote:
"Brett Mostert" <br**********@sebrio.com> wrote in message

Hi, first of all thanx for the reply :), but i have tried using VBS
already, and it throws the same error, even the sample microsoft provides
in there .vbs file throws the same error?

Any thoughts?

Thanx
Brett

This works for me on both W2K3 and XP, using prnadmin.dll version 5.2.3790.0
.

Dim oMaster
set oMaster = CreateObject("PrintMaster.PrintMaster.1")
for each oDriver in oMaster.Drivers("")
wscript.echo "DriverName : " & oDriver.ModelName
next

Using any non-scripting language (C++, C#, VB.NET) to enum the drivers fail
with HRESULT 0x8007007A, other interfaces like Printer, Port and Form work
as expected.

Willy.

Hey, hmm yes your are right, is there away i could do this using C#?
I need to be able to add printer ports, drivers, printers and administer
them?

thanx
Brett
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brett Mostert | last post by:
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...
6
by: notregister | last post by:
hi, i have been trying to send a printer-ready data to an unknown printer to print. the reason why the printer is unknown is that i do no wish installed any printer driver. so at the end my...
3
by: Mika M | last post by:
Hi all! I have made an application for printing simple barcode labels using PrintDocument object, and it's working fine. Barcode printer that I use is attached to the computer, and this...
4
by: Support | last post by:
Hello: I would like to create my own printer driver so that it is available in all applications through the file ->Print menu of applications. The driver will essentially take the contents of what...
4
by: Paul H | last post by:
OK, I tried getting and old Newbury Data ND2500 working using the "Generic /Text only" driver in Win XP. It prints, but I could not find a way to set a custom page size that matches the paper I am...
1
by: pigge79 | last post by:
Hi there, We are thinking of developing a product that needs to be able to parse data printed via some printer driver. The data will then be used to fill a PDF form. We believe the printer...
0
by: coolsilver.net | last post by:
I am not sure if I am in the right group. My problem is this: My VB.NET application prints to the Epson printer using Epson OPOS drivers. I have downloaded the Epson ADK for .NET from the...
2
by: =?Utf-8?B?Qm9vazIwNDc=?= | last post by:
I am stumped. I lost my printer about a week ago and cannot reinstall it. When I try it tells me that the specified print monitor cannot be found. I have a Dell computer with Windows XP and a...
7
by: Morias | last post by:
I have been trying to install a Zebra LP2844 on a computer running Windows XP. When using the add printer wizard I get an error that simply tells me "The printer could not be installed," but when...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.