* ) ( & 2XWOLQH &RPSRQHQ 2EMHF 0RGXOHV CMPT 470 ased on lecture notes by Woshun Luk What is a DLL? What is a COM object? Linking two COM objects Client-Server relationships between two COM objects COM interfaces ActiveX Control The Future of COM 7KUH 6WHS L 3URJUD 3URJUD /LEUDU /LQNLQJ ([HFXWLRQ A Program library is a library of pre-written pre-compiled procedures (not executables that is not XXXexe in a Windows World) When a program calls a procedure in a program library it is loaded into the process where the program runs Compilation: source code is compiled into binary code Linking: external symbols inside the program (eg Systems and program library procedure names) are resolved Loading: the linked binary code is loaded into the address space of a process for execution
- ()* 3URJUD QWHUSUHWDWLRQ \QDPLFOLQ /LEUDU // As an alternative to compilation the source code or its intermediate representation is interpreted during the runtime External symbols are also resolved during runtime ie late binding Compilation vs Interpretation The former is more efficient while the latter is more flexible Static-link: the procedure is linked to the calling program before execution Once linked it becomes part of the program Dynamic-link: the procedure is linked to the calling program only when it is called Procedures with dll extension will be loaded by the windows operating system at the load time :K // :K 2 // Since only one copy of DLL is needed it saves memory and disk space Minor updates and bug mixing may be done without compiling and re-linking DLL is about code reuse DLL is too difficult to write for an average application programmer (There can be only one instance of DLL in the entire system) Component object model (COM) has evolved to become the fundamental technology for binary code sharing among applications on MS platform In a way a COM object is a DLL plus &
0 / *( - 0 2EMHFWV COM as a programming standard specifies how objects in binary code are invoked and communicate with each other COM supports three types of object: In-process (dll) Local (exe in local machine) Remote (dll or exe in remote machine) COM is programming language neutral COM is not cross-platform From the outside world a COM object is black box which exposes the following: properties: information about the object behavior: methods: functions implemented in the object events: external actions that an object will handle in a certain manner Many MS apps are COM objects (Office IE) DLL usually has no GUI 7DNH 7Z W 7DQJR &RQQHFWLQ 7Z 2EMHFWV Two communicating objects are in a clientserver relationship server: the COM object being called client: the calling program This relationship is manifested as: Object Linking/Embedding (OLE) control OLE document The client must find out where the server is located Type conversion is often required when parameters are passed between the client and the server Object instances must be created and destroyed as demanded by the client or server Error and status reports must be generated on demand Automation (or OLE/COM automation) )* (& (
) ( 6 * 7 8 7 7 5 / 234 & IR 2EMHFWV 2U R W /RFDW WK REMHFW 2EMHF QYRFDWLRQ 7Z :D\V Each (COM) object belongs a certain type (instance/class) Each object type has a (globally) unique ID ie CLSID (class ID) Each interface of an object type has a unique ID ie IID (interface ID) Together CLSID IID makes GUID (Globally unique ID) GUIDs are stored in the registry of an NT workstation which is accessible to the user C way (aka the COM way) supports early binding express method parameters in language neutral way (eg IDL interface definition language) V (or VScript) way (aka the Automation way) support late binding rely on type library for parameter type conversion One trend is to provide objects which may be invoked in either way (aka dual interfaces) &UHDWLR DQ HVWUXFWLR R 2EMHF QVWDQFH 2/ XWRPDWLRQ COM objects may be created by an application program It is the responsibility of the application program to destroy the object when it is done and if you forget you get a memory leak One overview at http://modenaintergateca/personal/iago/ol etut/olep3htm OLE automation is Microsofts technology for cross-application macro programming It is a standard The server is usually a full-fledged application eg Word Excel and IE The client (automation controller) is usually a V program or a script (eg V for Application) 0 /- /
* & () 2/ GRFXPHQW 2/ &RQWURO OLE control (the server) is usually an in-process DLL OLE document is a way to link up two applications (eg WORD and EXCEL) through the medium of a OLE compound document object The object (server) is either embedded into or linked to the client (ie container) The server exposes usually visually a set of methods (eg EDIT) which may be called through the container by the end user These methods will be executed on the server on the application which produces the server that runs in the address space of the container (client) This tight integration is preferred because the client provides ambient support to the server (eg font display location and background color) the client and server work together to handle external events (eg mouse clicks or keyboard entries) QWHUIDFHV QWHUIDFHV According to COM objects communicates with each other via prescribed interfaces A COM object has two types of interfaces: System supplied interface (COM interface) User written (custom) interface like a DLL exposes methods and properties ie an interface for communication with outside world There may be more than one custom interfaces for a COM object Since server and client are typically written in isolation they must be written such that they can communicate with each other in a specific way Typically the server and client each provide specific COM interfaces for the other to call Tools such as MFC and ATL are useful for highpowered COM objects In-process GUI-less COM objects are easy to write in Vasic &
COM is the meat and potatoes of DNA Run-time licensing Reduced footprint (for quick downloading) Digital certification - H @ K K A> G = A@ =?> [ Y VU Y \ V e [ U Rd c b U m i i srq Ž ~ Š ~ ~ Ÿ Ÿ œ œ «º ³ ¼» ± º ž ¹ œž º ³ ² Å º ¹ ² ¾ ± Ê ¾ À± º³»º º ³ ¾ Æ ² ¼  Äà ÅÀ ² Á ºÇ ³ ¾ Ƽ ¾¾º ³ Å Å À» ³ Å ºÌ ± ± ³ ¹ Ë À À± Þ Ò Ð ÒÓ ÎÔ Ù Ñ Ô Ø Ñ ÒØ Ó Ï Ð Ñ ìè ëà ë ê ò â ó æ êé è ç ü ú ú ù ù üü ø ù ø ú ù ù * )( ) 0 R )XWXU 7K LQWHUHW Microsoft has its LVWULEXWH UFKLWHFWXUH The NET initiative is a new architecture oth DNA and NET will co-exist Article from Infoworld http://wwwinfoworldcom/articles/tc/xml/0/0 3/9/0039tcwindowsxml &RQWURO FWLYH An ActiveX control is an OLE control that supports the following features: Initialization security Scripting security IE is an example of ActiveX control container Tutorial (ancient history) http://wwwinfospherescaltechedu/mailing_lists/ja va/msg00207html 7HVW &HQWUH QIR:RUO 7 <DJHU : 98 & 0 7 6 035-2 3 4 0 &/0 - * & )( M A A)P O L AF MN FKL JI H A DE AF C @ ;< = Z eefg R\ S ^]_a` V \ [ R Y Z WX RV SRU ST RQ k r{ qmp q o{ z y m y w x j)v rp iut srq n op l m k j h i ƒ ~ ~ } ~ ~) Ž ~)ˆ ƒ ~ } ~ Ž ~ Ž ~ ª Ÿš š º³ À ¾º³» ½ ²³ ± ¾ º Å Â ±uỳ º Å ÉÃ È º Å ±uá ¾ º À ³ ³ ³ ß Ö Î Ú)Ý ÛÎ Ü Ù Ù Ø Î Ú Ô Ò Ö Ô Õ Î Ò ÍÎ ÏÐ ö ñò õî ò ë ô àâæ ì ñò ï î ïð ë ìí éë ì â æä ã äå á à â ú ú ú þ øùú ú ùú ú ú ú ùú ú ù üú þ øù ù ùú ü & -