用于EagleEye3.0 规则集漏报和误报测试的示例项目,项目收集于github和gitee
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

119 lines
2.4 KiB

#pragma once
class CTestDropTarget :public IDropTarget
{
public:
CTestDropTarget()
{
nRef = 0;
}
virtual ~CTestDropTarget() {}
//////////////////////////////////////////////////////////////////////////
// IUnknown
virtual HRESULT STDMETHODCALLTYPE QueryInterface(
/* [in] */ REFIID riid,
/* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
{
HRESULT hr = S_FALSE;
if (riid == __uuidof(IUnknown))
*ppvObject = (IUnknown*)this, hr = S_OK;
else if (riid == __uuidof(IDropTarget))
*ppvObject = (IDropTarget*)this, hr = S_OK;
if (SUCCEEDED(hr)) AddRef();
return hr;
}
virtual ULONG STDMETHODCALLTYPE AddRef(void) { return ++nRef; }
virtual ULONG STDMETHODCALLTYPE Release(void) {
ULONG uRet = --nRef;
if (uRet == 0) delete this;
return uRet;
}
//////////////////////////////////////////////////////////////////////////
// IDropTarget
virtual HRESULT STDMETHODCALLTYPE DragEnter(
/* [unique][in] */ IDataObject *pDataObj,
/* [in] */ DWORD grfKeyState,
/* [in] */ POINTL pt,
/* [out][in] */ DWORD *pdwEffect)
{
*pdwEffect = DROPEFFECT_LINK;
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE DragOver(
/* [in] */ DWORD grfKeyState,
/* [in] */ POINTL pt,
/* [out][in] */ DWORD *pdwEffect)
{
*pdwEffect = DROPEFFECT_LINK;
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE DragLeave(void)
{
return S_OK;
}
protected:
int nRef;
};
class CTestDropTarget1 : public CTestDropTarget
{
protected:
SWindow *m_pEdit;
public:
CTestDropTarget1(SWindow *pEdit) :m_pEdit(pEdit)
{
if (m_pEdit) m_pEdit->AddRef();
}
~CTestDropTarget1()
{
if (m_pEdit) m_pEdit->Release();
}
public:
virtual HRESULT STDMETHODCALLTYPE Drop(
/* [unique][in] */ IDataObject *pDataObj,
/* [in] */ DWORD grfKeyState,
/* [in] */ POINTL pt,
/* [out][in] */ DWORD *pdwEffect)
{
FORMATETC format =
{
CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL
};
STGMEDIUM medium;
if (FAILED(pDataObj->GetData(&format, &medium)))
{
return S_FALSE;
}
HDROP hdrop = static_cast<HDROP>(GlobalLock(medium.hGlobal));
if (!hdrop)
{
return S_FALSE;
}
bool success = false;
TCHAR filename[MAX_PATH];
success = !!DragQueryFile(hdrop, 0, filename, MAX_PATH);
DragFinish(hdrop);
GlobalUnlock(medium.hGlobal);
if (success && m_pEdit)
{
m_pEdit->SetWindowText(filename);
}
*pdwEffect = DROPEFFECT_LINK;
return S_OK;
}
};