“打开方式”命令只是将文件的路径作为第一个参数传递给应用程序,因此您所需要做的就是
public static void Main(string[] args){ if(args[0] != null) { //args[0] contans a path to the file do whatever you need to do to display it } else { //Start normally }}要自动将您的程序置于“打开方式”列表中,您需要在中添加一些reg键
HKEY_CLASSES_ROOTYOUR_EXT。这是一个如此的答案说如何做
或者,您也可以按常规方式将其手动添加到列表中。


![C#Windows“打开方式>”上下文菜单行为[重复] C#Windows“打开方式>”上下文菜单行为[重复]](http://www.mshxw.com/aiimages/31/568464.png)
