Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / November 2004



Tip: Looking for answers? Try searching our database.

EnumPrinterDrivers fails when enum on Win9x

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jerry West - 28 Nov 2004 07:38 GMT
I'm calling the EnumPrinterDrivers function on a WinXP system. For the first
parameter I'm passing in the name of a Windows ME computer residing on the
network. The MSDN indicates this is perfectly acceptable. The function fails
with an error 1722 (RPC unavailable). This seems odd to me as other APIs
that access this WinME system on the network function properly. The
EnumPrinterDrivers function has no issues when run on the local system or
when accessing a NT based system across the network.

sCompName$ = "\\jaguar"    'jaguar being the Windows ME computer name on the
network. Also tried w/o backslashes.
sDriverEnvironment$ = vbNullString

Call EnumPrinterDrivers(sCompName$, sDriverEnvironment$, DRIVER_LEVEL3, 0,
0, lRequired&, lEntries&)

As stated, other APIs that access this ME computer over the network function
perfectly fine and when accessing a NT based computer over the network there
are no issues enumerating the printer drivers remotely.

I see nothing about this issue when Googling. Does anyone know why this
occurs and whether a workaround exists?

Many thanks,

JB
Randy Birch - 28 Nov 2004 17:23 GMT
Hmm ... the description of that API is "enumerates the printer drivers
installed on a ***specified printer server***".  Since ME can not be
configured as a server to offer printer drivers for a network install, I
wonder if this is the cause of the failure?  The fact you have success with
other NT-based machines leads me to suspect this might be the problem.

Signature

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/

: I'm calling the EnumPrinterDrivers function on a WinXP system. For the first
: parameter I'm passing in the name of a Windows ME computer residing on the
[quoted text clipped - 21 lines]
:
: JB
Jerry West - 28 Nov 2004 17:36 GMT
Yes, I did consider that but couldn't find anything that offered further
clarification. The error I get also, I think, reinforces that theory.

If anyone has any further comments on this please do add them.

Thanks,

JW

> Hmm ... the description of that API is "enumerates the printer drivers
> installed on a ***specified printer server***".  Since ME can not be
[quoted text clipped - 36 lines]
> :
> : JB
Steve Gerrard - 28 Nov 2004 17:53 GMT
Any chance that "File and Printer Sharing for Microsoft Networks" is not
active on the ME computer? I saw something about it being needed for
some RPC calls to work.

I'm not sure about ME, but I think I have seen printers attached to
Win98 systems shared out over a network, and it seems to me that if you
can use them, you should be able to enumerate them...

| Yes, I did consider that but couldn't find anything that offered further
| clarification. The error I get also, I think, reinforces that theory.
[quoted text clipped - 45 lines]
| > :
| > : JB
Jerry West - 28 Nov 2004 23:33 GMT
Well I must say, after reading your suggestion I checked and found printer
sharing NOT to be enabled. So I was hopeful that was the trick. Alas, after
enabling it, rebooting and then trying again it still fails with the same
error <sigh>.

I wish the MSDN was more specific about whether it works on 9x/ME when these
platforms are called remotely. It does indicate that the API is supported on
Windows 95 and higher --it just doesn't specifically state that it is not
supported when calling them remotely. Though, it does leave one the
impression that those platforms are supported when reading the text for the
pEnvironment value.

Thanks for your post. If anyone has anything further to suggest or comment
please do!

JW

> Any chance that "File and Printer Sharing for Microsoft Networks" is not
> active on the ME computer? I saw something about it being needed for
[quoted text clipped - 69 lines]
> | > :
> | > : JB
Steve Gerrard - 29 Nov 2004 00:14 GMT
pEnvironment
"Pointer to a null-terminated string that specifies the environment (for
example, Windows NT x86, Windows IA64, Windows x64, Windows NT R4000,
Windows NT Alpha_AXP, Windows 4.0, or Windows NT PowerPC). If this
parameter is NULL, the function uses the current environment of the
caller/client (not of the destination/server)."

You are calling with NULL (vbNullString). That would mean you are using
the "current environment of the caller", which is Windows NT (WinXP),
wouldn't it? Maybe you should try the call with "Windows 4.0", which I
think means pre-NT. Maybe?

| Well I must say, after reading your suggestion I checked and found printer
| sharing NOT to be enabled. So I was hopeful that was the trick. Alas, after
[quoted text clipped - 86 lines]
| > | > :
| > | > : JB
Jerry West - 29 Nov 2004 00:27 GMT
I did note that information in the MSDN originally and so I am passing the
proper value for the remote system in question (in the case of ME it is
"Windows 4.0"). This does not correct the issue.

JW

> pEnvironment
> "Pointer to a null-terminated string that specifies the environment (for
[quoted text clipped - 115 lines]
> | > | > :
> | > | > : JB
Randy Birch - 29 Nov 2004 04:50 GMT
Hi Jerry ...

Are you sure you don't want the simpler EnumPrinters function rather than
EnumPrinterDrivers?  EnumPrinters is a mandatory function that all providers
must respond to; EnumPrinterDrivers is used to "return a list of printer
drivers that have been added to a specified server by calling
AddPrinterDriver or AddPrinterDriverEx".

It is my understanding that EnumPrinterDrivers is used to enumerate the
available printers drivers that can be installed from a network server onto
a machine running the environment specified under the pEnvironment variable.
IOW, you're on a XP box, you query the server for "Windows NT x86" (or
"All") to get the list of printers the server can install onto that XP box.
You're on a 9x box you ask for "Windows 4.0".

As for the RPC error, it could be the required ports on the machine are
blocked or the machine has an incompatible network adapter error. Also, is
there a print$ admin share on the ME machine?  Finally, the XP machine must
have rights to access the remote machine -- for example, on an XP -to- XP
network, if the calling XP machine does not have permission to access the
shares because the calling machine has not yet successfully completed a
required authentication challenge, the error returned through
Err.LastDllError is 1722. So in this case it's not so much an "RPC error";
it's an "error accessing the remote machine via RPC due to insufficient
credentials". Methinks 1722 might be a catch-all error code.

Also, have you determined that running the same code provides the expected
info when the app is run locally on the ME machine with vbNullString
specified as the server?

There's also some EnumPrinterDrivers code at
http://vbnet.mvps.org/code/enums/enumprinterdrivers.htm) which may provide
some other insight.

Signature

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/

Jerry West - 29 Nov 2004 16:55 GMT
Randy,

Thanks for your comments. It does appear that EnumPrinters would indeed do
what I need. A little more work is involved and it looks like I'd need to
use a PRINTER_INFO_2 structure versus what I originally wanted;
PRINTER_INFO_3. At any rate, thanks for pointing me toward another possible
solution!

JW

> Hi Jerry ...
>
[quoted text clipped - 34 lines]
> http://vbnet.mvps.org/code/enums/enumprinterdrivers.htm) which may provide
> some other insight.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.