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

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.

Leave a Comment