background preloader

COM

Facebook Twitter

What is the Windows Integrity Mechanism? The Windows integrity mechanism is a core component of the Windows security architecture that restricts the access permissions of applications that are running under the same user account and that are less trustworthy. The Windows Vista® integrity mechanism extends the security architecture of the operating system by assigning an integrity level to application processes and securable objects.

The integrity level is a representation of the trustworthiness of running application processes and objects, such as files created by the application. The integrity mechanism provides the ability for resource managers, such as the file system, to use pre-defined policies that block processes of lower integrity, or lower trustworthiness, from reading or modifying objects of higher integrity. The integrity mechanism allows the Windows security model to enforce new access control restrictions that cannot be defined by granting user or group permissions in access control lists (ACLs). Architecture of Connectable Objects (COM)

The connectable object is only one piece of the overall architecture of connectable objects. This technology includes the following elements: The relationships between client, connectable object, a connection point, and a sink are illustrated in the following diagram: Note A connectable object can support more than one client and can support multiple sinks within a client. Likewise, a sink can be connected to more than one connectable object. The steps for establishing a connection between a client and a connectable object are as follows: Architecture of Connectable Objects (COM) COM, COM+, Delphi Tutorials and References - Binh Ly. Building a COM Client - COM, COM+, Delphi Tutorials and References - Binh Ly. Building a COM Client Application by Binh Ly A COM client application uses the services of a COM server application. If you've previously studied the basics of COM clients and servers , we're now ready to see it in action in Delphi.

The following basic steps are performed to build a COM client: Ensure that the desired COM server is installed and registered on your machine. If you are using remote COM (DCOM), ensure that the server is registered on the remote machine and, if necessary, the server's type library is installed and registered on the client machine. Import the server's type library into native Delphi interface definitions. This process generates a COM import module that we include into our COM client project to simplify programmatic access to the COM server. Registering a COM Server Every COM server needs to be registered before it can be used by a client. There are 2 general types of COM servers, EXEs and DLLs.

Server /regserver regsvr32 Server.dll or tregsvr Server.dll. An Introduction to COM Programming with Borland Delphi. COM stands for Component Object Model. It allows you to create COM objects that are not specific to any language, and in some cases, even platforms. For instance, COM objects can be ported to a Unix system. COM also allows you to create COM Objects that will be instantiated on a different machine across the world if you so desired. Email Course This Course (also) comes as a 6-week email class. You will receive the first lesson as soon as you sign up. Lessons at a glance: Lesson 1 A brief historical rundown on COM's glorious past. Lesson 2 What is an Interface? Lesson 3 What is the implements directive? Lesson 4 A Com Object walk-a-bout. Lesson 5 Marshaling Data. Lesson 6 COM type definitions usually reside in a type library.

ATLEventHandling Sample: Handles Word Events Using IDispEventImpl and IDispEventSimpleImpl. Download sample The ATLEventHandling sample demonstrates the use of IDispEventImpl and IDispEventSimpleImpl to handle events fired by Microsoft Word. The sample consists of an ATL project that includes two COM classes: CSimple and CNotSoSimple . These classes represent COM objects that display a message box in response to document change events fired by Microsoft Word. CSimple shows how to handle events using ATL's IDispEventSimpleImpl class template, and CNotSoSimple shows how to handle events using ATL's IDispEventImpl class template.

The code in the two classes is identical except for the differences caused by the use of the different ATL templates. To build and run this sample Open the solution file ATLEventHandling.sln. You'll see a dialog box with a drop-down list allowing you to run the test using IDispEventImpl or IDispEventSimpleImpl . You can trigger events by creating new documents, loading documents, or switching to a different document using Word's Window menu. How to: Handle Events Raised by a COM Source. If you are not familiar with the delegate-based event model provided by the .NET Framework, see Handling and Raising Events . A .NET client (event sink) can receive events raised by an existing COM server (event source). COM interop generates the necessary delegates in metadata that you include in your managed client. An imported delegate signature comprises the sink event interface, an underscore, the event name, and the word EventHandler: SinkEventInterface _ EventName EventHandler.

Note that COM objects that raise events within a .NET client require two Garbage Collector (GC) collections before they are released. This is caused by the reference cycle that occurs between COM objects and managed clients. If you need to explicitly release a COM object you should call the Collect method twice. To interoperate with an existing COM event source Obtain the primary interop assembly for the COM server if the COM types are to be shared by other applications. Tasks Reference Concepts Other Resources. Automation collections. Collections are a part of automation. Languages like VBA offer language constructs which work with automation collections. A lot of methods and API calls use an automation collection as a parameter. In this chapter I will wrap up a stringlist inside a Delphi component and describe step by step how to publish the strings contained as an automation collection. A programmers way to look at collections In the file-manager example the user can select and deselect multiple files.

To program this ever changing bunch of selected files in code I could use an array, but that would not be the most handy thing. A better way to work with the selected files is a collection. IenumVariant describes an automation collection The Ienumvariant interface is part of the automation specification. Sub ListFiles() Dim File As SelectedFile For Each File In MyManager.Selected Selection.InsertAfter (File.Name) Selection.InsertParagraphAfter Next End Sub Ienumvariant is described as follows in ActiveX.pas instead of.

Writing COM Automation Events. Abstract: A short tutorial on writing simple Automation server and client classes. WHAT IS AN AUTOMATION EVENT? The typical COM Client/Server model that you have probably worked with before allows the client to call the server through a supported interface. This is fine when a client calls the server to perform an action or retrieve data, but what about when the server wants to ask things of the client? Incoming interfaces are just that: incoming. There is no way for the server to talk to any of its clients. HOW DO THEY DO IT? Connection Point: An entity describing the access to an events interface. Event Source: An object that defines an outgoing interface and fires events, typically the Automation Server. Event Sink: An object that implements an event interface and responds to events, typically the client.

Advise: Linking a sink to a connection point so that the sinks methods can be accessed by the source. These are the main pieces of the Events model. So lets begin. Fundamentals of ATL COM Objects (ATL) COM Connection Points. Download demo project - 55 Kb Introduction This article is intended to explain the concept behind connection points with a clear practical example, which will demonstrate an in-process COM server and an MFC client that uses the server. What Exactly Is It? It is a method used by a COM object to call back to the client.

In other words, clients get call back notification from the COM object. Perhaps you have heard about callback functions. So, when the COM object is finished with the task, it calls the client function ExecutionOver (passing the result of addition). How Does the COM Object Know How to Call ExecutionOver?? Imagine that the client exposes an interface ISink, which has a method ExecutionOver(int result). Hide Copy Code ISink *pClientSink; HRESULT Add(int a , int b) { pClientSink->ExecutionOver(a+b); } This is what really happens. Both the interfaces are shown below. Now, let's go one step at a time and see how the whole thing works. Click OK. Whew! Do a build and the COM is ready. An Introduction to COM Programming with Delphi (2 / 6) Article written by Curtis Socha, brought to you by Zarko Gajic. An interface is the heart of COM technology. When I use the word interface, do not confuse it with the visual display that the user interacts with.

It is actually a fairly new reserved word incorporated into Delphi. An Interface is little more than group of abstract methods used to manipulate an object. We established during the last lesson that an interface is not a class; it is an interface. Therefore, we must declare it as such. Let us explore some interface characteristics. An interface is defined as type interfaceYou are to use the letter I to define your interface. On GUIDs I am sure you are wondering what the big string of crazy characters are. Your interface will have a GUID unlike any other in the worldAll interfaces and COM interfaces will have a GUID attached to itYou can create a GUID in Delphi by pressing CTRL-SHIFT-GYou are never to copy a GUID from one interface into another That is a good question.

Good luck. An Introduction to COM Programming with Delphi (2 / 6) Biblioteca de Modelos C++ do Tempo de Execução do Windows (WRL)