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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
simonetCommented:
johnstod,

Are you there?

Alex
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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
MadshiCommented:
That's nice! So I think I can answer to get the points...  :-)

Regards, Madshi.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.