我正在做一个音乐播放器。我基本上想知道的是如何让你的程序打开一个文件,该文件被用户在资源管理器中单击。
例如:
我已将音乐播放器设置为默认程序以打开 .mp3。当我双击音乐文件夹中的 .mp3 文件时,我希望我的程序打开并开始播放那首歌。
但这是如何工作的?
提前致谢!
This is handled via the registry. You can see details of the (many) registry keys and values required to properly setup a file association here.
That being said, the best way to handle this is typically via your installation. Windows Installer supports the RegisterExtensionInfo extension, which will properly setup the registry for you during your program's installation.