我的一段代码
var
netRes: TNetResource;
begin
sServer := '//192.168.0.124' + '/C$';
netRes.dwDisplayType := RESOURCEDISPLAYTYPE_SERVER;
netRes.dwScope := RESOURCE_CONNECTED;
netRes.dwType := RESOURCETYPE_ANY;
netRes.lpRemoteName := pchar(sServer);
netRes.dwUsage := RESOURCEUSAGE_CONNECTABLE;
netRes.lpLocalName := 'z:';
netRes.lpProvider := nil;
iError := WNetAddConnection2(netRes,'',pchar(edtuser.Text),CONNECT_UPDATE_PROFILE);
end;