I’ve written a log parser, with some generous and insightful help from the SO community:
Keeping the UI responsive while parsing a very large logfile
Now, I’d like to be able to right click one of these logs, select “MyNewLogParser” from “Open With..” and see it open in my new program.
This would require me to
- Change something about my XP installation to show my program in the dropdown list
- Change the program so that it knows to open the selected file and run the parsing.
What do you call these things, and how is it done? I don’t know what to search for…
To open the selected file, you need to implement command-line parameters. Take a look at your
Program.csfile and theMainfunction.You want its signature to look something like this:
The
argsarray will be the array of command-line params passed to your application. So if you ranMyNewLogParser myLog.txt, the contents ofargs[0]would bemyLog.txt.For the OpenWith… menu, you’ll need to modify the registry. Search for the “OpenWith” key in Regedit and you’ll find it. On my machine (Windows 7), it’s in
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts. I’m not sure on the exact details of how it works, but Google should be able to help you out from there.If you don’t want to do it programmatically, I’m pretty sure there’s some menu item that allows you to select the application that will open a file. Don’t recall what it is on XP, though. Alternatively, you can associate a file extension with your application through a tab in the Folder Options dialog, so that double-clicking it opens your application.