рефераты конспекты курсовые дипломные лекции шпоры

Реферат Курсовая Конспект

Accessing COM Objects from Assembly

Accessing COM Objects from Assembly - раздел Образование, Accessing COM Objects from Assembly   Ernest Murphy Ernie@surfree.com   Revi...

 

Ernest Murphy ernie@surfree.com

 

Revised Dec 26 2000 for inclusion as part of MASM32

Revised July 10 2000 for the new form of coinvoke.

 

Sample code for this article is available at ...COMexamplesshortcut

 

 

Abstract:
--------------------------------------------------------------------------------------------------------------------

The COM (Component Object Model) is used by the Windows operation system in increasing ways. For example, the shell.dll uses COM to access some of its API methods. The IShellLink and IPersistFile interfaces of the shell32.dll will be demonstrated to create a shortcut shell link. A basic understanding of COM is assumed. The code sample included is MASM specific.

 

 

Introduction:
--------------------------------------------------------------------------------------------------------------------

COM may seem complicated with it's numerous details, but in use these complications disappear into simple function calls. The hardest part is understanding the data structures involved so you can define the
interfaces. I apologize for all the C++ terminology used in here. While COM is implementation neutral, it borrows much terminology from C++ to define itself.

 

In order to use the COM methods of some object, you must first instance or create that object from its coclass, then ask it to return you a pointer to it's interface. This process is performed by the API function CoCreateInstance. When you are done with the interface you call it's Release method, and COM and
the coclass will take care of deleting the object and unloading the coclass.

 

A COM object is referred to as the SERVER. The program that calls up a COM object so it may use it is referred to as the CLIENT.

 

 

Assessing COM Methods
--------------------------------------------------------------------------------------------------------------------
To use COM methods you need to know before hand what the interface looks like. Even if you "late bind" through an IDispatch interface, you still need to know what IDispatch looks like. A COM interface is just table of pointers to functions. Let's start with the IUnknown interface. If you were to create a component that simply exports the IUnknown interface, you have a fully functional COM object (albeit on the level of "Hello World"). IUnknown has the 3 basic methods of every interface, since all interfaces inherit from IUnknown. Keep in mind all an interface consists of is a structure of function pointers. For IUnknown, it looks like this:

 

– Конец работы –

Эта тема принадлежит разделу:

Accessing COM Objects from Assembly

IUnknown methods IUnknown QueryInterface QueryInterface Pointer IUnknown AddRef AddRef Pointer IUnknown Release Release Pointer... AddRef Pointer typedef ptr AddRef Proto Release Pointer typedef ptr...

Если Вам нужно дополнительный материал на эту тему, или Вы не нашли то, что искали, рекомендуем воспользоваться поиском по нашей базе работ: Accessing COM Objects from Assembly

Что будем делать с полученным материалом:

Если этот материал оказался полезным ля Вас, Вы можете сохранить его на свою страничку в социальных сетях:

Все темы данного раздела:

IUnknown ENDS
  That's it, just 12 bytes long. It holds 3 DWORD pointers to the procedures that actually implement the methods. It is the infamous "vtable" you may have heard of. The poin

AddRef_Pointer typedef PROTO :DWORD Release_Pointer typedef PROTO :DWORD
  In keeping with the MASM32 practice of "loose" type checking, function parameters are just defined as DWORDs. Lots of work to set things up, but it does keeps lots of erro

ADDR IID_SomeOtherInterface, ADDR ppv_new
  I hope you find this as wonderfully simple as I do.   Note we must pass in the pointer we used, this lets the interface know which object (literally &quo

ADDR ppnew
  Note that now the name decoration is done for us by the macro.   The only 'gotcha' (well, the most obvious) is that no parameters to a COM call should be pass

Хотите получать на электронную почту самые свежие новости?
Education Insider Sample
Подпишитесь на Нашу рассылку
Наша политика приватности обеспечивает 100% безопасность и анонимность Ваших E-Mail
Реклама
Соответствующий теме материал
  • Похожее
  • Популярное
  • Облако тегов
  • Здесь
  • Временно
  • Пусто
Теги