Scalabium Software

SMReport Autogenerated
Knowledge for your independence'.
Home Delphi and C++Builder tips

#75: How can I map/unmap the network disk in run-time?

Sometimes in run-time you must map/unmap the some remote resource. You can make it with the next code:

uses Windows;

var nw: TNetResource;
  nw.lpLocalName := nil;
  nw.lpRemoteName := PChar('\\yourServerName\yourDiskOnServer');
  nw.lpProvider := nil;
  errCode := WNetAddConnection2(nw, nil, nil, 0);
  if errCode = NO_ERROR then
  <Ok, disk mapped>

If the remote server have the password, then you must call the

errCode := WNetAddConnection2(nw, 'strPassword', nil, 0);

If you want to map this disk as own local resource, you must define the lpLocalName. For example,

nw.lpLocalName := 'F:';

When you want to un-map resource, you must call the WNetCancelConnection2 procedure.

Published: May 4, 2000

See also
Viewer for TNEF-files (winmail.dat)
Paradox to Text converter
Clarion to Text converter
DBExport tools
ABA Document Convert
Paradox to MS Access converter
SMExport suite
ABA Database Convert
ABA Spreadsheet Convert

Contact to webmaster


Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2019, Scalabium Software. All rights reserved.

SMExport advertising