64,651
社区成员
发帖
与我相关
我的任务
分享
// IShellExtInit::Initialize
HRESULT CCopyPathExt::Initialize(LPCITEMIDLIST /*pidlFolder*/, LPDATAOBJECT lpdobj, HKEY /*hKeyProgID*/)
{
try {
if ( lpdobj == NULL )
return E_INVALIDARG;
const HINSTANCE hinst = _Module.GetResourceInstance();
if ( hinst ) {
m_hbmpUnchecked = ::LoadBitmap( hinst, MAKEINTRESOURCE( IDB_CopyPath ) );
if ( m_hbmpUnchecked ) {
// We loaded the bitmap, so attach the CBitmap to it.
VERIFY( m_bmp.Attach ( m_hbmpUnchecked ) );
}
}
// Get the data as CF_HDROP
STGMEDIUM medium;
FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
HRESULT hr = lpdobj->GetData( &fe, &medium );
if ( FAILED( hr ) )
return E_INVALIDARG;
// Get the number of selected files
m_cFiles = DragQueryFile( reinterpret_cast<HDROP>(medium.hGlobal), 0xFFFFFFFF, NULL, NULL );
// Build the list of file names
m_lstFiles.clear();
for ( int iFile = 0; iFile < m_cFiles; iFile++ )
{
// Get the name of the selected file
memset( m_szFile, 0, sizeof m_szFile );
DragQueryFile( reinterpret_cast<HDROP>(medium.hGlobal),
iFile,
m_szFile,
sizeof(m_szFile)/sizeof(m_szFile[0]) );
m_lstFiles.push_back( m_szFile );
}
ReleaseStgMedium(&medium);
return hr;
} catch ( ... ) {
return E_FAIL;
}
}