Skip to main content

Posts

Showing posts from April, 2009

COM Standard Interface

We often create shortcuts for program/documents on Windows desktop. This is a two step process. In step 1 we right click on the desktop and select ‘Create Shortcut’ from the menu that pops up. In step 2 we select the file for which the short is to be created. At times we may want to do this procedure programmatically. Here is the program which, shows how this can be achieved. When we execute the program a dialog box shown in Figure 1 pops up. Figure 1. First we need to select the file for which shortcut needs to be created. This can be done by clicking the ‘browse’ button in the dialog. When we do so the function OnButton1( ) gets called. This function pops up a file dialog and permits the user to select a file. The selected file name and complete path is then retrieved using the functions CFileDialog::GetFileTitle( ) and CFileDialog::Get-PathName( ) . The selected file name is then displayed in the edit box of dialog shown in Figure 1.

Real COM Example

A Real COM Example Using MFC In this article, we would explore an in-process COM component in the form of a DLL that support IMyMath interface. We would then write a real COM client that would use this component. In programming, there are often many ways to solve a problem. MFC and VC++ programming is not an exception to this. The way we code our component in this example is just one way to do it. We want you to learn the interaction between code that wizards provide and the code that you need to write in a simplest possible manner. We hope our approach enables you to understand a more complex programming you might encounter in other places. Developer Studio’s AppWizard is not well optimized to generate a COM DLL. We will try to get as much support from it as possible. In the process, you will see some redundant code that we never use. But don’t pay too much attention to it at this time. As you become more accustomed to the surroundings, you may want to start opti

DLL AND COM

The whole idea of computing today is to put together applications rapidly from reusable maintainable code (preferably written by someone else). Object-oriented languages help developers to write reusable, maintainable code. The benefits of object-oriented techniques are there for all to see. However, an object-oriented language is not sufficient for widespread reuse. This is because developers throughout the world are programming in different languages. Developing all applications through a single programming language is a dream that is never going to come true. There are several reasons for this. They are: Some languages are better suited to a particular problem domain than others. Some programmers have a natural preference for a particular languages because it matches their way of thinking. Some languages are able to exploit the capabilities of some hardware better than the others. New languages may evolve to take advantage of the new processor power.

What Is COM?

Quite often programmers develop the ability to write COM components but are still hazy about what COM really is. So let's make a one-line definition of COM. COM is a specification and a set of services that permit us to create applications that are language-independent, modular, object-oriented, distributed, customizable, and upgradable. Let us now take apart this definition word by word. COM is a specification The COM specification describes the standards that you need to follow in order to create COM components. This standard describes how components should look like and how they should behave. COM is a set of services The COM specification is backed up by a set of services or APIs. On Win32 platforms these services are provided as a part of the operating system in the form of a COM library. In other operating systems they are provided as a separate package. COM components are language-independent COM is a binary standard. The components can be written in any programming l