Opening a “known file type” into running instance of custom app - .NET

前端 未结 5 1712
情歌与酒
情歌与酒 2020-11-30 06:56

How would you open a file (that has a known file/app association in the registry) into a \"running instance\" of the application it\'s supposed to open in? An example would

5条回答
  •  甜味超标
    2020-11-30 07:35

    The way I'd do it is like this:

    1. First thing in the main method, check the process list for an existing instance of the application.
    2. If found, send the filename/path to the already running instance using your favorite interprocess communication method (sending windows messages, remoting, wcf, etc.)
    3. Close the new process that windows tried to start (since the existing instance already handled the file open operation

提交回复
热议问题