procedure TMainForm.ConnectRDPByIndex(index: Integer); var ServerItem: PServerItem; tmpRpdFile, cmd: string; listview: TListView; begin listview := GetCurrentListview; if listview.Items.Count = 0 then Exit; if index > listview.Items.Count - 1 then Exit; if index < 0 then Exit; ServerItem := PServerItem(listview.Items[index].Data); tmpRpdFile := CreateRdpFile(ServerItem, listview.ItemIndex + 1, ScreenWidth, ScreenHeight, ForbidCopy); cmd := '/c mstsc.exe "%s" /w:%d /h:%d'; cmd := Format(cmd, [tmpRpdFile, ScreenWidth, ScreenHeight]); AddDeleteIp(ServerItem.IP); StopLinkMstscWarning(ServerItem.IP); ShellExecute(Handle, 'open', 'cmd', PChar(cmd), nil, SW_HIDE); TimerCheckTitle.Enabled := HideIP; FStopTime := DateUtils.IncSecond(Now, 20); end;
procedure TMainForm.Button2Click(Sender: TObject); begin ConnectRDPByIndex(3); end;