远程asp udp协议

时间:2017-12-17 09:18:56

标签: c# remote-desktop

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

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

现在我想远程作为UDP协议 服务器pc已准备好用于udp远程(已安装udp组件),我通过远程桌面对其进行了测试 但我在我的应用程序和代码中做了什么来启用UDP启用远程服务器?

1 个答案:

答案 0 :(得分: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");
        }