DelphiFAQ Home Search:
General :: Programming :: Delphi :: Network
Network (local network and Internet) programming under Windows with Delphi.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Dialogs to connect or disconnect mapped network drives

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.

Note:
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

begin
   // show the connect dialog
  WNetConnectionDialog(Handle, RESOURCETYPE_DISK);
 
   // ...

   // show the disconnect dialog
  WNetDisconnectDialog(handle, RESOURCETYPE_DISK);
 end;
You don't like the formatting? Check out SourceCoder then!
Generated 16:01:36 on Jul 20, 2017