我在我的电脑上制作了MP3文件,以便与我的媒体播放器相关联.因此,当我双击浏览器中的MP3文件时,显然媒体播放器会启动并播放它.
我的问题 我可以防止弹出多个实例,但是如何将新实例的文件路径传输到我正在使用的实例
What i want to happen: I double click a song,... and im listening to it I double click another song and the current song should stop and new song should start playback, without popping up a new instance of the application.
I use Mutex to check whether there is already a running instance. To get file path i use Environment.GetCommandLineArgs()
All I need is to pass the file's path to the current instance. How can I do this??
本质上,您必须将其构建到您的应用程序中。
当用户单击第二首歌曲时,您必须有某种方式让当前实例终止应用程序的前一个实例或向其发送消息。
这些对我来说似乎有点脏。
我认为一个干净的方法是编写一个app_booter.exe与您的媒体文件相关的小文件。单击媒体文件时,它会启动此_app_booter_,其中:
要从另一个 exe 发送应用程序数据,您可以查看 IPC: C# 中的 Windows 进程间通信 (.NET 2.0)
我认为WM_COPYDATA上面的帖子中提到的方法或 tcp 套接字就足够了,因为您的数据非常简单,只是一个文件路径,也许还有一个命令。
我认为保留两个单独的 exe 比构建应用程序来与其前一个实例进行对话更容易、更干净。
| 归档时间: |
|
| 查看次数: |
171 次 |
| 最近记录: |