-
Recent Posts
Recent Comments
Mike T. on Code snippet Using WMI via… Drew Canitz on minimal ATL window eskici on file transfer over synchronous… Rose on Purify reported error entry po… duongnguyenvan on file transfer over synchronous… Archives
- August 2018
- March 2018
- May 2017
- July 2012
- May 2012
- April 2012
- March 2012
- January 2012
- October 2011
- September 2011
- July 2011
- June 2011
- May 2011
- April 2011
- October 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- July 2009
- June 2009
- May 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- December 2005
- November 2005
Categories
Meta
Category Archives: COM
Running Object Table leads to memory leak
“When an object is registered, the ROT always calls AddRef on the object.”, but IRunningObjectTable::Revoke will not call Release method of registered object if there is client using the object, so later when all clients released its reference, the COM … Continue reading
Posted in COM
Leave a comment
Changing the Startup type and description of VC++ 2008 service project
#include <stdio.h>#include <sstream>#include <xutility>#include <exception>#include <iomanip>typedef std::basic_stringstream<TCHAR> tsstream;typedef std::basic_string<TCHAR> tstring;#ifdef _UNICODE#define __FUNCTIONT__ __FUNCTIONW__#else#define __FUNCTIONT__ __FUNCTION__#endif class COzSvcModule : public CAtlServiceModuleT< COzSvcModule, IDS_SERVICENAME >{public : DECLARE_LIBID(LIBID_OzSvcLib) DECLARE_REGISTRY_APPID_RESOURCEID(IDR_OZSVC, "{08E6E609-0FBD-4098-8006-D703FCEB8C17}") HRESULT InitializeSecurity() throw() { // TODO : Call CoInitializeSecurity and provide the appropriate … Continue reading
Posted in COM
Leave a comment
dynamic_cast with COM interface pointer
When I use c cast to get a pointer to an implementation class of an interface and call its method, it reports access violation upon the entry of the method, even if the method only contains one line: "return S_OK". … Continue reading
Posted in COM
Leave a comment
ROT and typelib
If typelib is not properly registered, a COM object can be registered to ROT, but subsequent GetObject would fail with error : "Invalid Pointer". It is valid to have two typelib in one executable, but the registeration has to be … Continue reading
Posted in COM
Leave a comment
RPC_E_CANTCALLOUT_ININPUTSYNCCALL Error with Out-of-Proc COM Server
Steps to reproduce: Create an out-of-proc COM server, add one method STDMETHODIMP ExeMsg::Test(long process_id, long thread_id){ std::stringstream ss; ss << "ExeMsg::Test() Called from process " << process_id << " caller thread " << thread_id << " callee process " << … Continue reading
Posted in COM
Leave a comment
Purify reports memory leak in UpdateRegistryFromResource method
Rational Purify reported memory leak in UpdateRegistryFromResource method, which is introduced by DECLARE_REGISTRY_RESOURCEID(…) macro. After I rebuilt with _ATL_STATIC_REGISTRY enabled, Rational Purify is happy.
Posted in COM
Leave a comment
Wrapper class for using UDT (User Defined Type) in COM
UDTs must be freed by caller, just like BSTR. So I created a template to ease the work of caller.template <typename UDT >class UDTWrapper : public UDT{public: UDTWrapper() { HRESULT hr = S_OK; CComPtr<ITypeLib> pTypelib; CComPtr<ITypeInfo> pTypeInfo; hr = LoadRegTypeLib(lib_id, … Continue reading
Posted in COM
Leave a comment
COM Client Method Call Fails with ERROR_NOACCESS(0xC0000005)
I encountered this problem in recent project development. It is very likely to be the same problem as documented in MSDN Q273721. Only one method failed, because it contains a parameter of IUnknown*. Another related KB article may be Q149231 … Continue reading
Posted in COM
Leave a comment
Share COM objects between threads/processes
The CoCreateFreeThreadedMarshaler function enables an object to efficiently marshal interface pointers between threads in the same process. The IGlobalInterfaceTable interface is an efficient way for a process to store an interface pointer in a memory location that can be accessed … Continue reading
Posted in COM
Leave a comment
Add ATL object to existing MFC SDI project
I met the following mistakes:missing [out] specifier in IDL file, so the method can’t be called by vbscript;messing up CLSID and LIBID.AfxGetApp() and AfxGetMainWnd() return NULL — workaround is to use theApp object, store HWND as a member of theApp … Continue reading