In this article, you will learn how to write working COM components from scratch, and without a single macro.
|
#pragma once
// ICOMServer interface declaration ///////////////////////////////////////////
//
//
class CoCOMServer : public ICOMServer
{
// Construction
public:
CoCOMServer();
~CoCOMServer();
// IUnknown implementation
//
virtual HRESULT __stdcall QueryInterface(const IID& iid, void** ppv) ;
virtual ULONG __stdcall AddRef() ;
virtual ULONG __stdcall Release() ;
// ICOMServer implementation
//
virtual HRESULT __stdcall Name(/*out*/BSTR* objectname);
private:
// Reference count
long m_cRef ;
};
///////////////////////////////////////////////////////////
//
// Class factory
//
class CFactory : public IClassFactory
{
public:
// IUnknown
virtual HRESULT __stdcall QueryInterface(const IID& iid, void** ppv) ;
virtual ULONG __stdcall AddRef() ;
virtual ULONG __stdcall Release() ;
// Interface IClassFactory
virtual HRESULT __stdcall CreateInstance(IUnknown* pUnknownOuter,
const IID& iid,
void** ppv) ;
virtual HRESULT __stdcall LockServer(BOOL bLock) ;
// Constructor
CFactory() : m_cRef(1) {}
// Destructor
~CFactory() {;}
private:
long m_cRef ;
} ;
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Addicted to reverse engineering. At work, I am developing business intelligence software in a team of smart people (independent software vendor).
Need a fast Excel generation component? Try
xlsgen.