I have a BHO library mybho.dll written in C#. I have embedded a Resource file "image.png". I'd like to show this image on some pages. According to what I read, it should look like this:
<img src="res://mybho.dll/image.png">
But Internet Explorer does not find the image. I've tried this one without success:
<img src="res://mybho.dll/#2/image.png">
What is the right way to do it?
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:
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.
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).
来源:https://stackoverflow.com/questions/9156177/how-to-embed-an-image-on-a-web-page-from-a-bho