从Windows打开调制解调器配置对话框(C#)
发布时间:2020-12-14 05:38:34 所属栏目:Windows 来源:网络整理
导读:有没有机会通过使用c#程序从 Windows控制中心打开调制解调器对话框? 具体对话框是: Windows – 控制中心 – 电话和调制解调器 – 选项卡高级 – 选择提供者 – 按钮配置 启动的进程在任务管理器中显示为dllhost.exe. 谢谢和亲切的问候 藤 解决方法 您可以
有没有机会通过使用c#程序从
Windows控制中心打开调制解调器对话框?
具体对话框是: 启动的进程在任务管理器中显示为dllhost.exe. 谢谢和亲切的问候 解决方法
您可以通过“运行”telephon.cpl“程序”打开电话和调制解调器控制面板项.您可以通过p / invoke或使用RunDll32直接使用SHELL32函数来完成此操作.
RunDll32是一个包含在windows中的程序,它加载DLL,并在其中运行一个函数,如命令行参数所指定的.这通常是shell(资源管理器)运行控制面板小程序的方式. 您也可以自己使用shell32函数直接加载CPL. 这是示例代码: [System.Runtime.InteropServices.DllImport("shell32",EntryPoint = "Control_RunDLLW",CharSet = System.Runtime.InteropServices.CharSet.Unicode,SetLastError = true,ExactSpelling = true)] private static extern bool Control_RunDLL(IntPtr hwnd,IntPtr hinst,[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string lpszCmdLine,int nCmdShow); private void showOnMainThread_Click(object sender,EventArgs e) { const int SW_SHOW = 1; // this does not work very well,the parent form locks up while the control panel window is open Control_RunDLL(this.Handle,IntPtr.Zero,@"telephon.cpl",SW_SHOW); } private void showOnWorkerThread_Click(object sender,EventArgs e) { Action hasCompleted = delegate { MessageBox.Show(this,"Phone and Modem panel has been closed","Notification",MessageBoxButtons.OK,MessageBoxIcon.Information); }; Action runAsync = delegate { const int SW_SHOW = 1; Control_RunDLL(IntPtr.Zero,SW_SHOW); this.BeginInvoke(hasCompleted); }; // the parent form continues to be normally operational while the control panel window is open runAsync.BeginInvoke(null,null); } private void runOutOfProcess_Click(object sender,EventArgs e) { // the control panel window is hosted in its own process (rundll32) System.Diagnostics.Process.Start(@"rundll32.exe",@"shell32,Control_RunDLL telephon.cpl"); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Exp2 后门原理与实践 20164309
- windows-server-2008 – “ipv6等效”192.168.x.x(配置静态
- windows-server-2008 – 双跃点窗口认证
- PyCharm激活码
- cmd – 如何缩短DOS提示符的路径?
- Microsoft Excel 2010复制/粘贴编辑想法和帮助请求小细节
- windows-phone-7 – 无法在Expression Blend中拖放行为
- 批处理文件 – Windows 2008服务器任务调度程序不运行.bat批
- windows-server-2003 – 即使在明确同步时间之后,Windows S
- 使用Windows SDK构建GTK
推荐文章
站长推荐
热点阅读