远程asp udp协议

问题描述 投票:0回答:1

我在我的应用程序中使用AxInterop.MSTSCLib.dll来远程访问我的服务器,代码很常见,如下所示:

var rdp = new AxMSTSCLib.AxMsRdpClient6NotSafeForScripting();
rdp.Server = "ServerAddress";
rdp.UserName = "Username";
sec.ClearTextPassword = "password";
rdp.Connect();

现在我想远程作为UDP协议服务器pc已准备好udp远程(安装udp组件),我通过远程桌面测试它,但我在我的应用程序和代码远程服务器启用UDP启用?

c# remote-desktop
1个回答
0
投票

取决于这个answer,你需要使用这个代码来启用远程桌面如果我很好地理解你的代码你需要什么

try
        {
            RegistryKey key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, TargetMachine.Name);
            key = key.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Terminal Server", true);
            object val = key.GetValue("fDenyTSConnections");
            bool state = (int)val != 0;
            if (state)
            {
                key.SetValue("fDenyTSConnections", 0, RegistryValueKind.DWord);
                MessageBox.Show("Remote Desktop is now ENABLED");
            }
            else
            {
                key.SetValue("fDenyTSConnections", 1, RegistryValueKind.DWord);
                MessageBox.Show("Remote Desktop is now DISABLED");
            }
            key.Flush();
            if (key != null)
                key.Close();
        }
        catch
        {
            MessageBox.Show("Error toggling Remote Desktop permissions");
        }
© www.soinside.com 2019 - 2024. All rights reserved.