Skip to content

Commit

Permalink
2.00
Browse files Browse the repository at this point in the history
  • Loading branch information
qbj196 committed May 1, 2021
1 parent a5947f9 commit c06035b
Show file tree
Hide file tree
Showing 11 changed files with 702 additions and 277 deletions.
24 changes: 10 additions & 14 deletions ClassFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,20 @@ CClassFactory::~CClassFactory()
//
STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, void **ppvObject)
{
HRESULT hr;

hr = S_OK;
if (IsEqualIID(riid, IID_IUnknown))
*ppvObject = this;
else if (IsEqualIID(riid, IID_IClassFactory))
*ppvObject = (IClassFactory *)this;
else
*ppvObject = NULL;

if (IsEqualIID(IID_IUnknown, riid) || IsEqualIID(IID_IClassFactory, riid))
if (*ppvObject)
{
*ppvObject = static_cast<IUnknown *>(this);
AddRef();
}
else
{
hr = E_NOINTERFACE;
*ppvObject = NULL;
return S_OK;
}

return hr;
return E_NOINTERFACE;
}

STDMETHODIMP_(ULONG) CClassFactory::AddRef()
Expand All @@ -64,13 +62,11 @@ STDMETHODIMP CClassFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, voi
HRESULT hr;
CDeskBand *pdb;

hr = CLASS_E_NOAGGREGATION;
*ppvObject = NULL;

hr = CLASS_E_NOAGGREGATION;
if (!pUnkOuter)
{
hr = E_OUTOFMEMORY;

pdb = new CDeskBand();
if (pdb)
{
Expand Down
56 changes: 24 additions & 32 deletions DeskBand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,32 @@ CDeskBand::~CDeskBand()
//
STDMETHODIMP CDeskBand::QueryInterface(REFIID riid, void **ppvObject)
{
HRESULT hr;

hr = S_OK;

if (IsEqualIID(IID_IUnknown, riid) ||
IsEqualIID(IID_IOleWindow, riid) ||
IsEqualIID(IID_IDockingWindow, riid) ||
IsEqualIID(IID_IDeskBand, riid) ||
IsEqualIID(IID_IDeskBand2, riid))
{
*ppvObject = static_cast<IOleWindow *>(this);
}
else if (IsEqualIID(IID_IPersist, riid) ||
IsEqualIID(IID_IPersistStream, riid))
{
*ppvObject = static_cast<IPersist *>(this);
}
else if (IsEqualIID(IID_IObjectWithSite, riid))
{
*ppvObject = static_cast<IObjectWithSite *>(this);
}
if (IsEqualIID(riid, IID_IUnknown))
*ppvObject = this;
else if (IsEqualIID(riid, IID_IOleWindow))
*ppvObject = (IOleWindow *)this;
else if (IsEqualIID(riid, IID_IDockingWindow))
*ppvObject = (IDockingWindow *)this;
else if (IsEqualIID(riid, IID_IDeskBand))
*ppvObject = (IDeskBand *)this;
else if (IsEqualIID(riid, IID_IDeskBand2))
*ppvObject = (IDeskBand2 *)this;
else if (IsEqualIID(riid, IID_IPersist))
*ppvObject = (IPersist *)this;
else if (IsEqualIID(riid, IID_IPersistStream))
*ppvObject = (IPersistStream *)this;
else if (IsEqualIID(riid, IID_IObjectWithSite))
*ppvObject = (IObjectWithSite *)this;
else
{
hr = E_NOINTERFACE;
*ppvObject = NULL;
}

if (*ppvObject)
{
AddRef();
return S_OK;
}

return hr;
return E_NOINTERFACE;
}

STDMETHODIMP_(ULONG) CDeskBand::AddRef()
Expand Down Expand Up @@ -118,7 +113,7 @@ STDMETHODIMP CDeskBand::GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDIN
{
m_dwBandID = dwBandID;

return E_NOTIMPL;
return S_OK;
}

//
Expand Down Expand Up @@ -190,27 +185,24 @@ STDMETHODIMP CDeskBand::SetSite(IUnknown *pUnkSite)
HWND hwnd;

hr = E_FAIL;

if (pUnkSite)
{
hr = pUnkSite->QueryInterface(IID_IOleWindow,
reinterpret_cast<void **>(&pow));
hr = pUnkSite->QueryInterface(IID_IOleWindow, (void **)&pow);
if (SUCCEEDED(hr))
{
hr = pow->GetWindow(&hwnd);
if (SUCCEEDED(hr))
hr = CreateStart(hwnd);

pow->Release();
}
}

return hr;
}

STDMETHODIMP CDeskBand::GetSite(REFIID riid, void **ppvSite)
STDMETHODIMP CDeskBand::GetSite(REFIID, void **ppvSite)
{
*ppvSite = NULL;

return E_FAIL;
return E_NOTIMPL;
}
6 changes: 2 additions & 4 deletions DllMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
HRESULT hr;
CClassFactory *pcf;

hr = CLASS_E_CLASSNOTAVAILABLE;
*ppv = NULL;

hr = CLASS_E_CLASSNOTAVAILABLE;
if (IsEqualCLSID(CLSID_Start, rclsid))
{
hr = E_OUTOFMEMORY;

pcf = new CClassFactory();
if (pcf)
{
Expand All @@ -54,9 +52,9 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
STDAPI DllRegisterServer()
{
HRESULT hr;
LSTATUS ls;
TCHAR sz[MAX_PATH];
DWORD cb;
LSTATUS ls;
TCHAR *psz;
ICatRegister *pcr;
CATID catid;
Expand Down
Loading

0 comments on commit c06035b

Please sign in to comment.