如何提示“选择默认程序".在代码中? [英] How to prompt the "Choose a default program" in code?

查看:28
本文介绍了如何提示“选择默认程序".在代码中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个程序,其中有一个填充有项目的列表框,当您右键单击该项目时,将弹出上下文菜单,并且可以选择调用打开方式",而我的问题是如何使选择"将显示一个默认程序"窗口,如下图所示.

I am writing a program with a listbox filled with items, and when you right click the item, context menu will pop up and have an option to choose call "Open with", and my question is how to make the "Choose a default program" window to show up, like the image below.

http://postimg.org/image/8ykfrzmjv/

我知道您需要执行 Process.Start()才能打开它,但我不知道exe名称.

I know you need to do Process.Start() in order to open it, but I do not know the exe name.

推荐答案

您可以使用这种方式直接显示打开方式"对话框:

You can use this way to show "Open With" dialog directly:

string FilePath = "C:\\Text.txt";//Your File Path
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "rundll32.exe";
proc.StartInfo.Arguments = "shell32,OpenAs_RunDLL " + FilePath;
proc.Start();

这篇关于如何提示“选择默认程序".在代码中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆