function WNetAddConnection2W(var lpNetResource: TNetResourceW;
lpPassword, lpUserName: PWideChar; dwFlags: DWORD): DWORD; stdcall;
var NRW: TNetResource;
begin
with NRW do
begin
dwType := RESOURCETYPE_ANY;
lpLocalName := 'X:'; // map to this driver letter
lpRemoteName := '//MyServer/MyDirectory';
// Must be filled in. If an empty string is used,
// it will use the lpRemoteName.
lpProvider := '';
end;
WNetAddConnection2(NRW, 'MyPassword', 'MyUserName',
CONNECT_UPDATE_PROFILE);
end;