在 Windows 操作系统中打开文件时将默认程序重定向到另一个程序
这只是在windows环境下。 据我所知,Windows 操作系统通过文件扩展名来识别特定文件的关联应用程序。 同样,每个文件(二进制)都以相应的符号(“起始符号”)开头。例如,.JPG 以 ÿØÿà 开头。假设我在十六进制编辑器或文本编辑器中打开此 .JPG 文件,然后将该起始符号更改为另一种文件类型。例如,我可以将 ÿØÿà 更改为 .Eߣ (.mkv)。因此,当我双击 .JPG 时,Windows 照片查看器显示存在一些错误或类似消息。因此,我需要获取有关尝试打开此类文件的应用程序的一些信息。如果可以的话,我需要使用与“起始符号”关联的应用程序打开该文件。
简而言之,当我打开 .JPG 时,我需要打开默认视频播放器 .mkv 文件。但对于这个例子来说可能不起作用。因为我只更改了 .JPG 的“起始符号”。
请给我任何想法来做到这一点。
谢谢!
This is only under windows env.
As I know windows os identifies associated application of a particular file by file extension.
Like wise each file (binary) starting with corresponding symbols ("starting symbols"). For an example .JPG starts with ÿØÿà. Let say I open this .JPG file in a Hex editor or a Text editor and then I change that starting symbols into another file type. for an example I can change ÿØÿà to .Eߣ (.mkv). So when I double click on the .JPG the Windows Photo Viewer says there are some errors or similar message. So I need to get some information about the application that tries to open that kind of a file. If I can, I need to open that file using the application that associated with "starting symbols".
Briefly when I open .JPG I need to open a default video player .mkv files. But It may not work for this example. Because I changed only the "starting symbols" of my .JPG.
Please give me any idea to do this.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
加密文件时,为其指定一个新的扩展名。例如,
Picture.jpg
变为Picture.encrypted-jpg
。然后,您注册为encrypted-jpg
的处理程序,解密文件,然后启动正常的jpg
处理程序。When you encrypt the file, give it a new extension. e.g.
Picture.jpg
becomesPicture.encrypted-jpg
. You then register as the handler forencrypted-jpg
, decrypt the file, then launch the normaljpg
handler.当要求 shell 对文件执行动词时,shell 不会使用文件的内容来确定将其传递给哪个应用程序。文件扩展名决定了文件的处理方式。
您希望使用文件的内容来影响哪个应用程序处理 shell 动词。为此,您需要创建一个启动器应用程序来读取文件头,然后决定将文件传递到哪个应用程序。您可以将启动器应用程序指定为您感兴趣的所有文件扩展名的处理程序应用程序。
虽然您可以这样做,但只需适当设置文件扩展名就会容易得多。
When the shell is asked to perform a verb on a file, the shell does not use the contents of the file to determine which app to pass it to. The file extension is what determines how the file will be treated.
You wish to use the contents of the file to influence which app processes a shell verb. In order to do so you would need to create a launcher app that reads the file header and then decides which app to pass the file on to. You would assign your launcher app as the handler app for all file extensions that you were interested in.
Although you could do this, it would be much easier just to set the file extension appropriately.
执行此类操作的正确方法是将文件替换为 重新分析点。
缺点是这涉及编写文件系统过滤器驱动程序,即操作系统扩展,这比普通应用程序编程带来了更大的麻烦。 (由于 Windows 已经进行了文件加密,我怀疑这是否值得。)
The proper way to do this sort of thing is to replace the files with reparse points.
The downside is that this involves writing a file system filter driver, i.e., an operating system extension, which is a whole level of trouble above and beyond ordinary application programming. (Since Windows already does file encryption, I doubt it would be worth the effort.)