Delphi IDE (239)
Windows with Delphi (38)
About this site
Links to us
Dialogs to connect or disconnect mapped network drives
This article has not been rated yet. After reading, feel free to leave comments and rate it.
There are two functions WNetConnectionDialog and WNetDisconnectionDialog that will display these dialogs. They are defined in unit Windows (Delphi 5).
The first parameter Handle identifies the owning window by its window handle.
These Win32 API calls only brings up the network connections dialog.
If you want to map programmatically a specific (remote or local) directory to a specific drive letter, then I recommend creating a temporary batch file with a command like this:
NET USE N: \\192.168.0.3\C$\Temp
This only works if the currently logged in user has an identical account on the remote machine. Otherwise the batch file will ask for the password during execution - ugly.
To remove a mapping programmatically, create a batch file with a command like this:
NET USE N: /DELETE
You don't like the formatting? Check out SourceCoder then!