Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GetPrinterDriver - Local only?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00936421
Message ID:
00936447
Views:
37
Gunnar, I am not too sure, but, Is your printer shared? Are the drivers in the print server set up as shared? The reason I ask is this: We have several printers, most of them are attached to a print server and some are attached to local computers, now if I ran this dirty functions :
lcMessage = ''

? installPrinter('\\COMP-00286\Brother PT-9200DX') && -> 'The printer driver is unknown'
? installPrinter('\\PrintServer\MIS HP8100') && -> 'Printer installed...'
? installPrinter('\\COMP-00484\ST-LABELS') && -> 'Printer installed...'
Where PrintServer is a Print Server with several network printers and COMP-00?? are two computers in the network with locally attached printers.

In my case, this method works for one of the local printers,but not for the other (it worked for all the printers attached to the server though), and I do not understood quite well what the network admin told me, but apparently has something to do with setting the computers that have the printers to allow other computers to download the drivers. I have no clue how to accomplish this, but it might be that once you do this, your API call works too. Sorry for a long message that gives you no answer.

By the way, if I try to manually install the printer PT-9200DX, it also informs me "The server for the 'Brother PT-9200DX' printer does not have the correct printer installed. If you want to search for the proper driver, click OK. Otherwise, click Cancel and contact your network administrator or original equipment manufacturere for the correct printer driver", and clicking OK very slowly (took like 2 minutes) showed me a dialog to locate an *.INF file
function installPrinter(tcPrinter)
local lcReturn
if addPrinter(tcPrinter, @lcMessage)
	lcReturn = 'Printer installed. Driver used: ' + lcMessage
else
	lcReturn = 'Printer was not installed, the reason was: ' + lcMessage
endif
return lcReturn

function addPrinter(tcPrinter, tcMessage)
local loWMI, loPrinterClass, loPrinter, lnReturn, lcMessage, llMessage

llMessage = pcount() = 2
if Vartype(tcPrinter) # 'C' or Empty(tcPrinter)
	if llMessage
		tcMessage = 'Printer name is mandatory'
	endif
	return -1
endif

loWMI		= Getobject('WinMgmts:')
loPrinterClass	= loWMI.Get('Win32_Printer')
lnResult	= loPrinterClass.AddPrinterConnection(tcPrinter)
do case
case lnResult = 0
	loPrinter = loWMI.Get('Win32_Printer.deviceID="' + Strtran(tcPrinter, '\', '\\') + '"')
	lcMessage = loPrinter.DriverName
case lnResult = 5
	lcMessage = 'Access denied'
case lnResult = 1797
	lcMessage = 'The printer driver is unknown'
case lnResult = 1801
	lcMessage = 'Invalid printer name'
case lnResult = 1930
	lcMessage = 'Incompatible printer driver'
otherwise
	lcMessage = 'Unknown Error(' + Transform(lnResult) + ')'
endcase

tcMessage = lcMessage
return lnResult = 0
>Hello everybody.
>
>here i am again
>
>the GetPrinterDriver() works great for me as long as i have the printer-driver installed on my machine. however, i need to use this to install a network printer. so, at that time the driver data is not available localy.
>
>if i run the program, with which i am able to retrive localy the information, for a network printer (not installed locally), i do not receive any data.
>
>can this function only be used for local drivers? if so, is there a way to accomplish what i need?
>
>thanks for all your help in advance!
>
>-Update-
>i optain a printer handel with OpenPrinter() sucessfully
>on the GetPrinterDriver() i get as an API error "1 - Incorrect Function"
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform