I have a WPF application that I've associated with a custom file type.
The steps were:
1. Open Project Properties->Publish->Options->File Associations 2. Filled in Extension = .tr2, Description = TR2 file, ProgID = TR2File.tr2, Icon = W32.ico 3. Opened a blank text file, renamed it to test.tr2, double click it and the program starts up. 4. Created a second file, named test2.tr2, double click it and a second instance of my program starts up.Now, I still haven't figured out how to actually open/read the files yet, but first I would re开发者_StackOverflowally like to make it so that if the program is already running, then it just opens in the current app, and doesn't try to open a new instance of the app.
Have your program create a named pipe. When a second instance executes, before it does anything else, have it check for the existence of this named pipe. If it exists, open it and use it to send the filename being opened in the second instance, and then terminate. If it doesn't exist you don't have an existing instance, so you can open.
精彩评论