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:
00936614
Views:
22
Hello Hugo

Thank you for your continues support.

The Printers i am trying this with are shared. i am able to manually install them. i have not checked, but because of that i think the drivers are also correctly shared.

i did find in the meanwhile the following: the network i am testing this on is a mixed plattform network. i have xp, nt workstation, 98, and 95 machines. My developer workstation is a xp machine. it seems that when run my program against another xp workstation to install a printer - it works. if the printer is attached to a 98 or 95 machine it does not.

i think thats where the problem is. somehow xp has problems finding the information. what i have done as a fix, i have already the network printers which are available to be installed in a table. i added another field where the administrator in a 1-time setup enters the printerdriver manually. my install routine then pick this up - and the install works. not pretty - but hey...

but bothers me, because i would think that there has to be a way, because the 'add-printer' wizzard from windows is able to do this.

another thing what i don't realy know specifics on is: i know that there are supposed to be different drivers for the same printer, for different possible plattforms. the GetPrinterDriver() takes care of this by specifying the windows plattform you whish to get the driver for. with my solution this does not work, but i have not seen any trouble with the driver at printing time - so maybe its not that important!?


>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"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform