Posts

Showing posts from July, 2009

Simplest method to create COM object -VC++

Here i am going to write steps that i used to create a object of component and call the functions of that object. i was just having the progid of that component and i supposed to call the function of that component. in VB it is very simple to do. u need to just call a function "CreateObject(progID)" and start wrking with that object. Eg: ProgId : abc.application.1 dim obj = CreateObject("abc.application.1e"); done. but in VC++ it is quite complicated to call the function or object creation. but lets see i have done the task. required header files: #include #include "Objbase.h" CLSID clsid; LPUNKNOWN punk; LPDISPATCH pdisp; OLECHAR FAR* szMember = _T("GetIpAddress"); DISPID dispid; DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; OleInitialize(NULL);// if OLE isn't already loaded. CLSIDFromProgID(_T("abc.application.1"), &clsid); CoCreateInstance(clsid, NULL, CLSCTX_SERVER,IID_IUnknown,

VC++ - Importent Outlook - Add in close

I was just working with Outlook 7 and made aVC++- ATL addin and things were very fine. for a moment i just shifted my code on Outlook 2003 the things gone changed ...suddenly my smile converted in deep worry becoz of in case of multiple instance i was not able to close all the explorer of outlook.outlook was not getting closed,was running behind. then after a lots of debug loops i found where exactly the problem........ here i am goin to list some issues that may be a part of such problems while developin a com addin for outlook. 1 - if u are registering any event (DispEventAdvise(.......)) with button or menu item just check that its having corresponding un registeration(DispEventUnadvise(...........)).If DispEventAdvise is coming in your code then there must be DispEventUnadvise(.....). 2 - Arelease the explorer object that u r using. 3 - free all the Com object that u r using. 4 - always try to handle the events that you are using in your addin case in a different class. Here i

Outlook add-in - multiple explorer of OL and Close Problems vc++

So now here i am going to write about the issues that came when i was developing the outlook add-in. 1 - On outlook close issues: Outlook never call begin shutdown(...) method while any of its resourece and object is in use and not properly released.so handle all the case while u are shutting down your add-in to ensure that your add-in released all outlook objects and resources. eg... before closing ensure all the explorer object that u have used for your add-in, has properly released. 2. Stop all the threads that are runnng inside your addin before outlook close. 3 . In case of multiple explorer of outlook bimd each explorer close event so that it would be easier to realease particular explrer object on its close. 4. In case of multiple explorer first un advise the previous events and then advise new event. HRESULT hr; hr = BrechaMeetingButtonEvents::DispEventUnadvise ((IDispatch*) m_spMeetingButton[m_ExpCount - 1]); //BRECHA_LOG(" DispEventAdvise((IDispatch