| Delphi .NET (2) Database (71) Delphi IDE (90) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280) |
Map or unmap a network disk at run-time
Question: I want to attach to a file server and map a network disk from within my Delphi application. How can I do this?Answer: You need to use the Windows API function WNetAddConnection2 to map a remote share as a disk.This function replaces the old WNetAddConnection call which did not allow to specify a username. If you need to specify a user name or password you can do this in arguments 2 (password) and 3 (user name). Note that example below sends nil. If you send nil as user name and password, then WNetAddConnection2 will use the user context for the running process and the password associated with this account. Note that supplying a user name/ password other than the process currently running will only work on Windows NT, Windows 2000 and Windows XP. Finally use WNetCancelConnection2() to remove a network mapping.
Comments:
|