Tuesday, June 29, 2010

Creating A COM DLL USING VC++

Steps for creating a COM DLL using VC++ :

1.Create an ATL Project


File->New->ATL->ATL Project.

Select Support MFC CheckBox (if u want to use MFC classe).
 
2: Add Class

Select Class View.

Add a new Class.

Visual C++ ->ATL->ATL Simple Object.

Enter Class Name.(above slide)

3: Adding Methods to Class


Open Class View.

RightClick the interface (IComInerface).

Add->Add Method.(slide2)

Enter the method name and add all the Parameters for the method.(slide3)

(Note the return type of the method by default ll be HRESULT but parameters can be passed to methods as references, while entering the parameters the appropriate type has to be selected).


 




4: Implement Method:
Open the Com Class file(.cpp) the class that you created .

Find the method you added (slide 4)

write the functionality for the method.
 

........now when u have compiled your code the com dll is created !

Thursday, June 3, 2010

AutoExpansion in Visual Studio

Lets take a CStringArray. In the debugger (Watch Window) we will be able to see only the first element inserted into the array.

What if we wanted to see all the elements  present in the array?

1. Open the file "c:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\autoexp.dat" in notepad.
2.Search for the line "[AutoExpand]"
3.add the following line below it.
      CStringArray=size = //Add this line
4. Search for the line "[Visualizer]"
5. add the following line below it.
CStringArray{ children ( #array ( expr : ($e.m_pData[$i]), size : ($e.m_nSize) ) )}
6. Save this file and close All Visual studio application and open again and try.

You can also expand other structures or classes designed by you. Refer autoexp.dat for samples.