COM interface types. A quick glossary

by Matt 13. June 2007 06:24

Right. Let's brush away some cobwebs, and write this down so I don't have to google all over the web whenever I need a quick COM 101 refresher:

  • A custom or vtable interface is a COM interface that derives from IUnkown. It only supports early binding through the compiler's vtable.
  • A dispinterface is a purely IDispatch based interface. The methods defined in the IDL file are only callable via IDispatch::Invoke, and not via a vtable. These are usually used as event interfaces (i.e. you implement the interface on your object and pass it to another object that you want to receive events from). Knowing this explains why it's not a cardinal COM sin that Microsoft have been expanding DWebBrowserEvents2 for each release of Internet Explorer.
  • A dual interface is a COM interface that derives from both IUnknown and IDispatch - it's both a vtable interface and a dispinterface.
  • Expando objects implement IDispatchEx and allow you to add methods and properties at runtime. This is how JavaScript, VBScript and Internet Explorer allow you to expand script and HTML objects.

A type library can be used to store interface information. It can contain vtable layouts and the DispId's required to call IDispatch based interfaces.

You can implement IDispatch by hand, with a huge switch statement, if you want to, but remember that you'll need to crack the parameters out of arrays and stuff them back in again for the return value. 

Alternatively, you can let someone else do the heavy lifting for you and use an implementation of IDispatch which is based on a type library. (And seeing how one of the methods of IDispatch is to get a pointer to an ITypeInfo interface representing a type library - you might as well). This works by calling LoadTypeLib to get an instance of ITypeLib, then calling ITypeLib::GetTypeInfoOfGuid. The resulting ITypeInfo can be used to defer the interesting IDispatch methods (including Invoke). This is what ATL's IDispatchImpl does. It's interesting to note that the Invoke method will call vtable based methods on your interface. This is pretty good voodoo.

As far as I can make out, you could also use CreateStdDispatch to create an IDispatch interface for you, which essentially does the same thing as IDispatchImpl. Or, you can implement bits of IDispatch yourself and defer to methods such as DispInvoke and DispGetIDsOfNames.

If you want to support dispinterfaces, you can use ATL's IDispEventImpl. This is an implementation of IDispatch that doesn't require an implementation of each member on the dispinterface. It does this by using a map that routes DispId's to functions - ideal for an interface that doesn't actually have a vtable. You could even use IDispEventSimpleImpl if you didn't want to use a typelib.

Sheesh. It's nice that .net moves well away from all of this malarky, but it's still something that you need to know from time to time...


Comments (18) -

best suv 2011
best suv 2011
7/20/2011 10:34:58 PM #

Per il tuo bambino scegli Moncler. Una scelta di capi, estivi ed invernali, eccezionali. Tuo figlio sarà sempre alla moda e potrà muoversi in totale comodità.


photographe mariage paris
photographe mariage paris United States
6/8/2015 2:09:19 AM #

I have noticed that in unwanted cameras, unique detectors help to focus automatically. The actual sensors with some video cameras change in in the area of contrast, while others use a beam involving infra-red (IR) light, particularly in low light. Higher specification cameras often use a blend of both programs and will often have Face Priority AF where the digicam can 'See' any face as you concentrate only upon that. Many thanks for sharing your notions on this weblog.


Deena Hofer
Deena Hofer United States
1/15/2016 6:24:09 AM #

AWESOME!Can't wait for that, will be something to want to accomplish day by day, to do something AWESOME!


Lidia Loser
Lidia Loser United States
1/15/2016 7:19:29 AM #

I love the dolphin saving you one.


Selma Houzah
Selma Houzah United States
1/15/2016 8:29:43 AM #

Congratulations on your success! You deserve it for brightening all of my work days with something to be excited about.


Hilaria Rieff
Hilaria Rieff United States
1/15/2016 8:59:35 AM #

The dolphin saving you one is the best one!


Patrica Guccione
Patrica Guccione United States
1/17/2016 9:57:45 PM #

AWESOME!Can't wait for that, will be something to want to accomplish day by day, to do something AWESOME!


Irvin Dewinter
Irvin Dewinter United States
1/19/2016 3:04:11 AM #

Congratulations, Neil! I love this site and I know I'll love the book. Christmas, birthdays, Father's Day 2010  check!


Kylee Marett
Kylee Marett United States
1/20/2016 6:02:26 AM #

Hey, congratulations Neil. This site really is something special and it's been a pleasure to share it with my readership too. Looking forward to future awesome things, and I'll send any suggestions that are sufficiently awesome.


Odell Jirasek
Odell Jirasek United States
7/19/2016 4:08:08 PM #

You know therefore considerably when it comes to this subject, produced me for my part believe it from numerous varied angles. Its like men and women don’t seem to be fascinated except it’s one thing to do with Lady gaga! Your personal stuffs nice. At all times maintain it up!


Stephania Bukrim
Stephania Bukrim United States
3/14/2017 7:48:49 PM #

This is a awesome website with some awesome tips


dildo toys
dildo toys United States
9/12/2018 5:28:40 PM #

the surround sound systems like dolby can really make the home theater sounds super great“


醫學美容 藍針
醫學美容 藍針 United States
10/10/2018 6:24:12 AM #

Shan 善 【枸杞萃系列】枸杞萃豐盈洗髮菁 Goji Essential Volumizing Shampoo的商品介紹   Shan 善,枸杞萃系列,枸杞萃豐盈洗髮菁 Goji Essential Volumizing Shampoo       


IELLIOS是由歐盟資助倫敦大學細胞重建研究所研究. 採用諾貝爾生理醫學獎科技 , 透過"納米能量電流" 以最親膚與迅速導入的方式 , 利用電腦化系統去令皮膚再生 , 令皮膚組織在無創傷的情況下自然更新及收緊 . 這治療是無創無痛的 . 完成治療後亦沒有傷口 . 我們是香港第一引入IELLIOS的機構 , 醫生會根據客人不同情況去為你設計不同的組合 .在外國IELLIOS受到很多荷里活明星, 歌手以至政客的追棒 , Madonna的facialist kate somer -field就常用IELLIOS為她護理肌膚 , 令52歲的她肌膚輪廓均保持於30歲的狀態.  IELLIOS的訊號技術,採用心臟起博起原理,活躍無法正常運作的心臟細胞。訊號技術可活化及修復愛損皮膚,透過傳送訊號,激活靜止的細胞。IELLIOS的訊號技術給予細胞指令,引發細胞再次生長,令肌膚重回年輕。


無論您是首次置業、換樓或是物業投資者,富邦樓宇按揭服務,為您提供多元化按揭計劃,全面配合不同的財務需要;加上專業按揭顧問的一站式服務,助您抓緊每個 ...


醫學美容 送禮
醫學美容 送禮 United States
10/16/2018 5:24:19 PM #

┃旅遊┃首爾「時裝周住宿」選擇丨Hotel QB 東大門酒店丨近東大門DDP廣場 @ 潮流、美妝、消費 創造個人化風格的女性社群 PIXstyleMe  ┃旅遊┃首爾「時裝周住宿」選擇丨Hotel QB 東大門酒店丨近東大門DDP廣場      


按摩 United States
10/17/2018 11:40:15 AM #

CLINIQUE 倩碧線上購物官網。瀏覽倩碧, Clinique, 化妝品,護膚,美白,香水,香氛,彩妝, ,頂級化妝品, 美容, 護膚品, 美麗, 世界頂級化妝品,世界頂級,頂級化妝品,清潔,清理皮層,三步驟,3步驟


醫學美容 韓方
醫學美容 韓方 United States
10/18/2018 8:37:43 PM #

減肚腩兼紓緩經痛!必學3招床上懶人骨盤運動    造型打扮 Grooming    新Monday  夏天到了,女士們除了要注重身形外,還要注重骨盤歪斜、盆骨底肌肉鬆弛等婦科問題!只要每晚睡前在床上做3個骨盆運動 ,就能預防骨盤歪斜,改善盆骨底肌肉鬆弛、漏尿等問題,更能促進燃脂,減肚腩兼紓緩經痛!  


Add comment

  • Comment
  • Preview


Month List


Comment RSS