Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delphi code to "net use" a printer in NT4

Posted on 1999-07-08
7
Medium Priority
?
459 Views
Last Modified: 2010-04-04
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.
0
Comment
Question by:johnstod
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 15

Expert Comment

by:simonet
ID: 1387243
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
 
LVL 20

Expert Comment

by:Madshi
ID: 1387244
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
 
LVL 15

Expert Comment

by:simonet
ID: 1387245
johnstod,

Are you there?

Alex
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:johnstod
ID: 1387246
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
 
LVL 20

Expert Comment

by:Madshi
ID: 1387247
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
 

Author Comment

by:johnstod
ID: 1387248
Madshi,

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

Thank you!

Don
0
 
LVL 20

Accepted Solution

by:
Madshi earned 300 total points
ID: 1387249
That's nice! So I think I can answer to get the points...  :-)

Regards, Madshi.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question