Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get printer network name using API for copyfile api
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00883676
Message ID:
00883687
Views:
18
I thought aprinters() would, but looking at the results it does not. For instance, our HP LaserJet 4000 printers are connected via jetdirect and an example entry from aprinters() is:

gaprinters(4,1) "\\NCSERVER\HP LaserJet 4000 Series PCL 6"
gaprinters(4,2) "HPJD1"

4,1 is actually the windows printer name, not the network name (the network name is "\\NCSERVER\HP_4000" which I pulled from net view and net use) and 4,2 is the port (the printer on my LPT1 port has LPT1 for this column).

I must be missing something, because I remember reading an api function that would do this here on the UT (or a procedure that included many api functions that used together could pull this information) at sometime or other but I have not been able to locate it searching yet. Thanks for the WSH information though! However, for this version, some of our customers do not have WSH installed and our powers that be refuse to include it in our install procedures (I think they just want to make it more difficult for me sometimes). The next version of our software will only be installed on Windows Xp (and whatever comes after) so then I can use WSH...


>>I am using copyfile api to send a file to a printer and it works great. However, I noticed today that it requires not the windows printer name (as we retrieve using getprinter() in vfp) but the sharename. Now I will have to determine if the printer is local or network and if network determine its network name. Is there a simple way to do this? I have many printername retrieval functions but none that I've found so far will return the sharename for a network printer based on its windows name on the workstation...
>>
>>For instance if I use SET PRINTER TO NAME GETPRINTER() then SET('PRINTER',3) will have the windows name whether it is local or not and if it is a network printer it will not contain the network name. I need to somehow get the network name of the printer so I can pass it to copyfile...
>>
>>TIA,
>
>Tracy,
>
>Doesn't APRINTERS() give you both?
>
>If the is WSH OK and the above doesn't work then
oNet = CREATEOBJECT('WScript.Network')
>oPrinters = oNet.EnumPrinterConnections
The even numbered items, beginning with zero, has the port. In the case of network printers, this will be the name I think you might need.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform