How can I show the “Open with” file dialog?

后端 未结 4 1144
不知归路
不知归路 2020-11-29 08:33

Is there any simple way to open the \"Open with\" file dialog?

4条回答
  •  既然无缘
    2020-11-29 09:13

    Some reverse-engineering with ProcExp revealed a rundll32.exe command line that worked. Here's a sample program that uses it:

    using System;
    using System.Diagnostics;
    using System.IO;
    
    class Program {
        static void Main(string[] args) {
            ShowOpenWithDialog(@"c:\temp\test.txt");
        }
        public static void ShowOpenWithDialog(string path) {
            var args = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "shell32.dll");
            args += ",OpenAs_RunDLL " + path;
            Process.Start("rundll32.exe", args);
        }
    }
    

    Tested on Win7, I cannot guess how well this will work on other versions of Windows.

提交回复
热议问题