微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何以编程方式打开Windows操作系统中的“networking发现”?

我的项目使用UPnP协议打开端口。 Windows在认情况下禁用UPnP设备发现,需要在networking和共享中心中启用networking发现才能启用UPnP设备发现。

有没有办法做到这一点编程?

networking股份上市

C ++和Windows:SYstemTIME总是基于公历日历吗?

用户提供的代码获取窗口的特殊文件

如何在拖放时在窗口中隐藏光标(可能使用python或其他语言)

你怎么能发送信息到Windows的任务栏从Java或javafx

您可以使用cmd命令启用网络发现

netsh firewall set service type = upnp mode = mode

然后将该命令作为参数来编码

public void ExecuteCommandSync(object command) { try { // create the processstartinfo using "cmd" as the program to be run,// and "/c " as the parameters. // Incidentally,/c tells cmd that we want it to execute the command that follows,// and then exit. System.Diagnostics.processstartinfo procStartInfo = new System.Diagnostics.processstartinfo("cmd","/c " + command); // The following commands are needed to redirect the standard output. // This means that it will be redirected to the Process.StandardOutput StreamReader. procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; // Do not create the black window. procStartInfo.CreateNowindow = true; // Now we create a process,assign its processstartinfo and start it System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo = procStartInfo; proc.Start(); // Get the output into a string string result = proc.StandardOutput.ReadToEnd(); // display the command output. Console.WriteLine(result); } catch (Exception objException) { // Log the exception } }

如果该命令不起作用,则根据您的系统查找另一个命令来启用网络发现。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐