DelphiFAQ Home Search:

Dialogs to connect or disconnect mapped network drives


commentsThis 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:  \\\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:


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

  // ...

  // show the disconnect dialog
  WNetDisconnectDialog(handle, RESOURCETYPE_DISK);
You don't like the formatting? Check out SourceCoder then!
Content-type: text/html


2012-11-12, 05:32:29
anonymous from United States  



NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: