//连接到\\192.168.0.1\picbook目录,用户名是administrator,密码是:'aaaa'
procedure TForm1.ConnectServer;
var
NetSource : TNetResource;
begin
with NetSource do
begin
dwType := RESOURCETYPE_ANY;
lpLocalName :=''; // 将远程资源映射到此驱动器
lpRemoteName:='\\192.168.0.1\picbook'; // 远程网络资源
lpProvider :='';
end;
WnetAddConnection2(NetSource, 'aaaa','Administrator',CONNECT_UPDATE_PROFILE);
end;
//关闭连接
procedure TForm1.DisConnectServer;
begin
WNetCancelConnection2('\\192.168.0.1\picbook',CONNECT_UPDATE_PROFILE,True);
end;