473,573 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ 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 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;
}
}
Nov 17 '05 #1
4 6991

"Brett Mostert" <br**********@s ebrio.com> wrote in message
news:Ov******** ******@TK2MSFTN GP10.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 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;
}
}


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.Manageme nt and WMI for this.

Willy.
Nov 17 '05 #2
Willy Denoyette [MVP] wrote:
"Brett Mostert" <br**********@s ebrio.com> wrote in message
news:Ov******** ******@TK2MSFTN GP10.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.Runtim e.InteropServic es.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
{
strServerNa me = "";
PrintMasterCl ass oPrinterMaster = new PrintMasterClas s();
object oRefDriver = strServerName;
object oDrivers;
oDrivers = oPrinterMaster. get_Drivers(ref oRefDriver);
DriverCollect ion oDriverCollecti on = (DriverCollecti on)oDrivers;

foreach (Driver oDriver in oDriverCollecti on)
{
System.Window s.Forms.Message Box.Show(oDrive r.MonitorName);
System.Window s.Forms.Message Box.Show(oDrive r.ConfigFile);
System.Window s.Forms.Message Box.Show(oDrive r.DataFile);
System.Window s.Forms.Message Box.Show(oDrive r.DriverVersion );
System.Window s.Forms.Message Box.Show(oDrive r.DriverArchite cture);
System.Window s.Forms.Message Box.Show(oDrive r.Environment);
System.Window s.Forms.Message Box.Show(oDrive r.HelpFile);
System.Window s.Forms.Message Box.Show(oDrive r.InfFile);
System.Window s.Forms.Message Box.Show(oDrive r.ModelName);
System.Window s.Forms.Message Box.Show(oDrive r.Path);
System.Window s.Forms.Message Box.Show(oDrive r.ServerName);
System.Window s.Forms.Message Box.Show(oDrive r.Version.ToStr ing());
}
return true;
}
catch (Exception err)
{
System.Window s.Forms.Message Box.Show(err.Me ssage.ToString( ) + " | " +
err.ToString( ) + "|" + err.Source.ToSt ring());
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.Manageme nt 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**********@s ebrio.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("P rintMaster.Prin tMaster.1")
for each oDriver in oMaster.Drivers ("")
wscript.echo "DriverName : " & oDriver.ModelNa me
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**********@s ebrio.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("P rintMaster.Prin tMaster.1")
for each oDriver in oMaster.Drivers ("")
wscript.echo "DriverName : " & oDriver.ModelNa me
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
1339
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 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...
6
2557
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 printing would have to bypass the printer driver.. i have read several article on sending file directly to a printer, but i could not understand how...
3
6280
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 computer has drivers installed for this printer, and this printer is shared for the network. Question 1:
4
7487
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 is in the parent application and save it so file (like a file - save as). I will do some information processing when the printer driver is called...
4
1875
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 using. So there was no way it would ever work. The customer is happy to buy another Dot Matrix printer because the ND2500 can be used elsewhere....
1
1629
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 solution will be best as there are multiple applications that we need to retrieve data from. This is a brand new area for us, so I'm basically...
0
7907
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 EpsonExpert site (www.epsonexpert.com) I have also downloaded the Epson Advanced Printer Driver from the Epson site. I have installed Microsot POS for...
2
1805
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 Dell Photo Printer 720. Any help will be greatly appreciated.
7
34908
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 using the plug and play auto detect wizard I get the error "Data area passed to a system call is too small." The printer has worked on this particular...
0
7781
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8027
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8202
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8066
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6421
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5594
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3733
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2216
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1304
muto222
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.