How to embed an image on a web page from a BHO?

柔情痞子 提交于 2019-12-05 18:59:28

You are confusing Win32 resources and .NET assembly resources. the 'res:' protocol handler returns a Win32 resource from a DLL. .NET resources are NOT Win32 resources, and as such IE (Actually urlmon.dll, where res: is implemented) cannot find your image.

You have two options:

  1. The easiest way would probably be to create a Win32 resource (*.res file) and embed it into the managed assembly. First, create a *.RC file, which points to your image. I'm not sure, but I think you'll have to convert your PNG to BMP format first. Then, compile the RC file into a binary resource (with RC - the Resource Compiler). Finally, as you build your managed assembly, use the /win32res switch to add the Win32 resource.

  2. You can also implement a Asynchronous Pluggable Protocol handler. Say you want to implement a new protocol scheme: julien://image.png'. Register it at HKCR\PROTOCOLS\Handler\julien, and implement IInternetProtocol (and few other protocols). This is NOT a very easy task (did it once - there are many opportunities to make mistakes).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!