For NigelTodd - NetAddConnection question

This is an attempt to get both you and Madshi points for helping answer my question.

How can I dynamically map a drive to a Network Server in Delphi 3 without requiring multiple calls to a Batch file containing the Net Use M: command?

I am writing a program that has to retrieve data from a database that resides locally on 46 Network Servers.  The database is located in the same folder and has an identical name on each of the 46 Network Servers.  I kind of know how to solve this problem with the Batch file approach but would rather avoid pulling a DOS/Command window up 46 times each time the program is run.


Thanks again for your help.
blakecAsked:
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.

JaymolCommented:
Have this....

function MapNetworkDrive(RemoteName, LocalName: String): Integer;
var
  NewMap : NetResource;
begin
  NewMap.lpRemoteName:=PAnsiChar(RemoteName); // Path to dir to map.
  NewMap.lpLocalName:=PAnsiChar(LocalName);  // Drive letter to use.
  NewMap.lpProvider:=nil;
  NewMap.dwType:=RESOURCETYPE_DISK;
  Result:=WNetAddConnection(PChar(RemoteName), nil, PChar(LocalName));
end;

Maps a network drive.

Have fun,

John.
0
nigeltoddCommented:
Use the netconn component available from Delphi Super Page or give me you r eamil address & I'll send it to you. While Madshi (& others) have suggested using WNetConnection calls, this component is as easy as just setting the properties, and making the connection.

Good luck,

Nigel
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
blakecAuthor Commented:
Hey Nigel,

I tried using the NetConn component but couldn't get it to install.  I'm using D3 for this project and am not sure I have all the patches for it.

Email me @ blake.cook@staff-leasing.com or blakec@iname.com

Thanks for your help Nigel!!!

Blake
0
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.