简体   繁体   中英

BHO Accessing resource in managed dll

I've created my first BHO, an addon for IE. I want to inject a javascript file to the head.

IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)document.all.tags("head")).item(null, 0);
IHTMLScriptElement scriptObject = (IHTMLScriptElement)document.createElement("script");
scriptObject.type = @"text/javascript";
scriptObject.text = "\nwindow.onload = function(){alert('loaded..');}\n\n";
((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);

This works just fine, but I would like to use: scriptObject.src and link to a resource file I have added to the project. I tried using the RES: protocol but IE cannot find it. Am I doing this correctly? Thank you.

scriptObject.src = "res://C:/git/addon/ie/bin/addon.dll/script.js";

你有没有尝试过

scriptObject.src = "res://C:\\git\\addon\\ie\\bin\\addon.dll/script.js";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM