4

I have an ActiveX control generated by the FireBreath framework (http://firebreath.org). I need to get a reference to the <object> tag in the page that hosts the plugin from C++.

If I were using NPAPI, I would use the NPNVPluginElementNPObject constant with NPN_GetValue.

so to make sure I am being clear, say I have the following in the page:

<object id="testPlugin" type="application/x-someplugin" width="100%" height="100%"></object>

I want to get a reference to the plugin like I would if I used document.getElementById("testPlugin"), except from within the C++ code of the activex control that is inserted for that mimetype.

Please note that passing the id in as a <param> is not a good option for me, but if there is a way to get the ID from inside the activex control that may work.

edit: I am considering using getElementsByTagName and trying to find it through the DOM, but it would be difficult to tell the difference between two instances of the same plugin.


Sending an Email with python using the SMTP Library

import smtplib

def prompt(prompt):
    return raw_input(prompt).strip()

fromaddr = prompt("From: ")
toaddrs  = prompt("To: ").split()
print "Enter message, end with ^D (Unix) or ^Z (Windows):"


msg = ("From: %s\r\nTo: %s\r\n\r\n"
       % (fromaddr, ", ".join(toaddrs)))
while 1:
    try:
        line = raw_input()
    except EOFError:
        break
    if not line:
       break
    msg = msg + line

    print "Message length is " + repr(len(msg))

server = smtplib.SMTP('smtp.live.com:25')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()

I'm trying to send an Email using that example, but it doesnt work, I dont get any error it just doesn't send anything, I'm trying to send it to a hotmail email. Any help will be appreciated, Thanks.

4

2 に答える 2

2

フィンランドの FireBreath 寄稿者 jtojanen のおかげで、ようやく解決策が見つかりました。

まず、COM オブジェクトを「Single」ではなく「Apartment」として (レジストリに) 登録する必要があります。そうしないと、これは機能しません。COMのバグのようです。

次に、SetClientSite が呼び出された後の任意の場所で、次の操作を実行できます。

CComQIPtr<IOleControlSite> site(m_spClientSite);
CComPtr<IDispatch> dispatch;
site->GetExtendedControl(&dispatch);
CComQIPtr<IHTMLElement2> htmlElement = dispatch;

これで誰かの時間を節約できることを願っています。これに答えてくれる人を見つけるのに2年近くかかりました。

htmlElement のオブジェクトは、プラグインをラップする <object> タグになります。したがって、インターフェイスのいずれかに対して queryInterface を実行すると、成功するはずですが、実際には文字通りオブジェクトではない可能性があり、オブジェクトのラッパーになる可能性があります。

于 2011-01-11T20:52:00.717 に答える
0

C# の場合:

    public int SetSite(object site)
    {
        if (site != null)
        {
            var oleControl = (IOleControlSite)site;
            object oHtmlElement;
            oleControl.GetExtendedControl(out oHtmlElement);
            var htmlElement = (IHTMLElement2)oHtmlElement;
            ...
        }
    }
于 2014-10-02T12:36:00.060 に答える