Delphi code to "net use" a printer in NT4

I'm looking for Delphi 4 code that will allow me to "net use" a network printer under NT4.  I would assume it is an API call.  Can't seem to find it though.  Any help you could provide would be greatly appreciated.
johnstodAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
MadshiConnect With a Mentor Commented:
That's nice! So I think I can answer to get the points...  :-)

Regards, Madshi.
0
 
simonetCommented:
The NetShareAdd function shares a server resource.

Security Requirements

Only members of the Administrators or Account Operators local group or those with Communication, Print, or Server operator group membership can successfully execute NetShareAdd. The Print operator can add only Printer queues. The Communication operator can add only communication-device queues.

Alex
0
 
MadshiCommented:
Hi Don, know I see where you have my EMail from...  :-)
You don't need to write an EMail to me. I look here for new question regularly.

I'm not sure: Do you want to SHARE the printer on the print server or do you want to map the LPT port on the client side? NetShareAdd is the API to share the printer driver at the server side, with WNetAddConnection3 you can map a LPT port on the client side. But normally you don't map a LPT port (like you do with net use, or am I wrong?), but you change the port of the client printer driver directly. To do the latter, look at OpenPrinter, GetPrinter (level2), SetPrinter and ClosePrinter (all in unit windows).

Regards, Madshi.

Regards, Madshi.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
simonetCommented:
johnstod,

Are you there?

Alex
0
 
johnstodAuthor Commented:
We are in the processes of developing an application that is calling
another application's documents.  These documents by default will not
print to the Windows' default printer (for what ever reason).  We need
to "net use" an lpt port to the desired network printer and then copy
the document (pcl file) to the lpt port.  We can do this in a batch file
(see below).  My question is, can this be done programmatically within
Delphi via an API call?

-- batch file ---
C:
cd \temp
substitute the (C:\LPM\JFMERGE.EXE -z"test.txt" will create PCL File
"test.txt") at this point
Net Use LPT3 \\CITICORP_TREE\mrhp5q47.bindery.stl-cmi.mo.lan.citicorp.us
copy test.txt LPT3
Net Use LPT3 /delete
delete test.txt
------------------

Your confusion is our frustration.  Why anyone would write a "Windows
NT" application that is unable to print to the Windows' default printer
is be beyond me.

Thanks

Don
0
 
MadshiCommented:
Well, as I said, the API call to map the LPT port is "WNetAddConnection3". I think you can copy the file somehow with winAPI calls, too. Perhaps even with CopyFile. But I don't know that part of the question. Perhaps you can execute the jfmerge.exe with -z"lpt3" directly?

Regards, Madshi.
0
 
johnstodAuthor Commented:
Madshi,

The call to WNetAddConnection2 did exactly what I was looking for.

Thank you!

Don
0
All Courses

From novice to tech pro — start learning today.