• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 42  文章 - 3  trackbacks - 0
            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(2)

            隨筆檔案

            文章檔案

            網頁收藏

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            Recently, I have read Inside COM, it is not my first time to read it. But still I got some useful information from it.

            First of all, rather than inheriting, Containment and Aggregation are the two methods COM used to achieve reusability.
            Aggregation is the specialized form of Containment, in which the programmer doesn’t have to implement code in the outer component to forward/delegate a call to the inner component and hence makes the life of a programmer easier. In Aggregation, the outer component hands over the control of the interface, which is being implemented by the inner component, to the client directly and the outer component gets out of the picture. In Aggregation, the interface to the inner component is exposed directly to the client, which is in contrast with the Containment. The outer IUnknown and the Inner IUnknown will be having the different implementation of the QueryInterface and hence it violates the basic QueryInterface rules. To forward/delegate calls to the outer IUnknown, the inner component needs the outer component’s IUnknown interface pointer. The outer component passes its IUnknown interface pointer at the time of creating the inner component. The outer component calls CoCreateInstance and passes its IUnknown pointer in the second argument of CoCreateInstance. If this parameter is non-NULL, then the component is being aggregated, otherwise the component is not aggregated.

            Secondly, The IDispatch interface was initially designed to support Automation. It provides a late-binding mechanism to access and retrieve information about an object's methods and properties.In addition to the methods inherited from IUnknown, server developers must implement the following methods within the class definition of each object that is exposed:
            • GetTypeInfoCount returns the number of type descriptions for the object. For objects that support IDispatch, the type information count is always one.
            • GetTypeInfo retrieves a description of the object's programmable interface.
            • GetIDsOfNames maps the name of a method or property to a DISPID, which is later used to invoke the method or property.
            • Invoke calls one of the object's methods, or gets or sets one of its properties.

            When the client need to call the method provide by the server, and the code is like this:

             

             1HRESULT hret=CoInitialize(NULL); assert(SUCCEEDED(hret));
             2    CComPtr<IDispatch> ptr;
             3
             4    ptr.CoCreateInstance(L"InternetExplorer.Application");
             5      if(ptr==0{ wprintf(L"Unable to create Application\n"); return 1; }
             6    
             7    wchar_t *array=L"GoHome";
             9    long id;
            10    hret=ptr->GetIDsOfNames(IID_NULL,&array,1,LOCALE_SYSTEM_DEFAULT,&id);
            11    assert(SUCCEEDED(hret));
            12    
            13    DISPPARAMS noparams;  memset(&noparams,0,sizeof(noparams));
            14    
            15    hret=ptr->Invoke(id,IID_NULL,LOCALE_SYSTEM_DEFAULT,DISPATCH_METHOD,&noparams,NULL,NULL,NULL);   
            18    CoUninitialize();    return 0;
            19

            Third, Connection Points, Com’s Observer Pattern
            -Based on Callbacks
            -COM-Object can have one or more event sources
            -Per event source may be one or more subscribed event sink
            -asynchronous communication between a server and its clients

            //Client
            class myEventSink : public EventSink
            {
             void handleEvent(int arg)
             { cout << “myEventHandler” << arg << endl; }
            };

            //Server
            [ object, uuid(…) }
            interface IEventSource : IUnknown
            {
             HRESULT Attach( [in] IEventSink* PEveSink);
            };

            Protocol
            IConnectionPointContainer::FindConnectionPoint
            IConnectionPoint::Advise       //passing sink interface pointer, receiving cookie
            IConnectionPoint::Unadvice    //terminates notification

             

            posted on 2012-03-04 22:08 鷹擊長空 閱讀(1235) 評論(0)  編輯 收藏 引用
            无码人妻精品一区二区三区久久久| 国产精品久久久久jk制服| 国产精品热久久无码av| 精品一久久香蕉国产线看播放| 国产精品九九久久精品女同亚洲欧美日韩综合区| 四虎国产精品免费久久5151| 久久久青草青青国产亚洲免观| 久久久久波多野结衣高潮| 97久久天天综合色天天综合色hd | a级毛片无码兔费真人久久 | 国产精品亚洲综合久久 | 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 看全色黄大色大片免费久久久 | 精品精品国产自在久久高清| 久久成人精品| 91精品国产高清91久久久久久| 欧美久久久久久午夜精品| 国产精品久久久久久久久| 久久久久99这里有精品10| 色噜噜狠狠先锋影音久久| 蜜臀久久99精品久久久久久小说| 久久精品成人免费观看97| 久久国产一区二区| 三上悠亚久久精品| 久久99久久99精品免视看动漫 | 精品国产日韩久久亚洲| 国内精品久久久久久久影视麻豆 | 狠狠色噜噜狠狠狠狠狠色综合久久| 亚洲国产天堂久久久久久| 久久精品国产亚洲一区二区三区| 久久精品国产精品亚洲毛片| 超级97碰碰碰碰久久久久最新| 久久久久人妻精品一区三寸蜜桃| 99久久精品影院老鸭窝| 国产成人久久激情91| 国产Av激情久久无码天堂| 精品国产VA久久久久久久冰| 久久精品99久久香蕉国产色戒 | 久久久久久曰本AV免费免费| 欧美精品丝袜久久久中文字幕 | 亚洲第一极品精品无码久久|