ActiveX/COM object doing OutputDebugString for use

2019-06-12 05:08发布

问题:

This is specific to Internet Explorer. For certain reasons, I'm unable to use console.log. I'm looking for a simple ActiveX object, safe for scripting, that would allow me to log debug output from JavaScript for viewing with the excellent DbgView tool. The object should use OutputDebugString for that.

Then I could simply use it like this:

<script>
function debugLog(str)
{
  if (window.debugLogAx === undefined) {
    try { window.debugLogAx = new ActiveXObject("IEDebugTools.Logger"); }
    catch(e) { window.debugLogAx = null; }
  }
  if (window.debugLogAx !== null)
    window.debugLogAx.OutputDebugString(str);
}

debugLog("Hello to DbgView from JavaScript!");
</script>

Does such thing exist?

回答1:

I don't believe such ActiveX exists really, but it's quite easy to create such one. Visual Studio, ATL, new object, add new method, and that's all :)