Click here to Skip to main content
15,894,343 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
AnswerRe: Keys in a map Pin
studyu4-Sep-07 20:38
studyu4-Sep-07 20:38 
AnswerRe: Keys in a map Pin
Stephen Hewitt4-Sep-07 22:19
Stephen Hewitt4-Sep-07 22:19 
AnswerRe: Keys in a map Pin
valikac17-Sep-07 9:35
valikac17-Sep-07 9:35 
Questionretrieve source code of a webpage and store it in a CString Pin
Dhiraj kumar Saini3-Sep-07 21:54
Dhiraj kumar Saini3-Sep-07 21:54 
QuestionImplementing IDownloadManager & download() method.. Pin
p33ks3-Sep-07 3:54
p33ks3-Sep-07 3:54 
AnswerRe: Implementing IDownloadManager & download() method.. Pin
Michael Dunn3-Sep-07 22:14
sitebuilderMichael Dunn3-Sep-07 22:14 
AnswerRe: Implementing IDownloadManager & download() method.. Pin
myshketer4-Sep-07 4:08
myshketer4-Sep-07 4:08 
Answerread csExWBv2.0.0.2 and TrueDownloaderIE Pin
xinkmt11-Dec-11 21:20
xinkmt11-Dec-11 21:20 
/////////////////////////////////////////////////////////////////////////////
// CestDLHandler
CestDLHandler::CestDLHandler()
{
m_lUid = 0;
}

STDMETHODIMP CestDLHandler::Download(IMoniker* pmk,
IBindCtx* pbc,
DWORD dwBindVerb,
LONG grfBINDF,
BINDINFO* pBindInfo,
LPCOLESTR pszHeaders,
LPCOLESTR pszRedir,
UINT uiCP )
{
traceFerruccio(_T("IMoniker %p CestDLHandler %p \n"),pmk, this);

HRESULT hr;
//Stream will be released in the BSCB OnDataArrival
IStream *pstm;

//Attempt to create our BindStatusCallBack
WBBSCBFileDL *filedl = NULL;
//Returns a NonAddRef pointer to a new BSCB
//AddRef is called on this BSCB during a successfull call
//to RegisterBindStatusCallback
if(WBCreateBSCBFileDL(&filedl) != S_OK)
{
return E_FAIL;
}
//Init the BSCB
m_lUid++;
filedl->InitByUser(m_lUid, this, pszHeaders, NULL);

IBindStatusCallback *pPrevBSCB = NULL;
hr = RegisterBindStatusCallback(pbc,
reinterpret_cast<ibindstatuscallback*>(filedl), &pPrevBSCB, 0L);
/*
Exception to the rule
RegisterBindStatusCallback return E_FAIL
Cause: Content_Disposition header returned from a server
in response to a file download via a post or ,..
Example: downloading attachements from Hotmail, Yahoo, ...

Unfortunately, due to no documentation regarding an E_FAIL return,
and more specifically, regarding RegisterBindStatusCallback internal workings,
I had to resort to using RevokeObjectParam on the previous BSCB and in my
implementation of BSCB, relay certain calls to the previous BSCB to make DL work.
I do not know if this is a bug or done intentionaly.
*/

/*
KB article http://support.microsoft.com/default.aspx?scid=kb;en-us;274201
Notifies the client application that this resource contained a
Content-Disposition header that indicates that this resource is an attachment.
The content of this resource should not be automatically displayed.
Client applications should request permission from the user.
This value was added for Internet Explorer 5.
*/

if( (FAILED(hr)) && (pPrevBSCB) )
{
//RevokeObjectParam for current BSCB, so we can register our BSCB
LPOLESTR oParam = L"_BSCB_Holder_";
hr = pbc->RevokeObjectParam(oParam);
if(SUCCEEDED(hr))
{
//Attempt register again, should succeed now
hr = RegisterBindStatusCallback(pbc,
reinterpret_cast<ibindstatuscallback*>(filedl), 0, 0L);
if(SUCCEEDED(hr))
{
filedl->m_pPrevBSCB = pPrevBSCB;
//Need to add ref to our DLMan
filedl->AddRef();
pPrevBSCB->AddRef();
filedl->m_pBindCtx = pbc;
pbc->AddRef();
}
}
}

if(SUCCEEDED(hr))
{
hr = pmk->BindToStorage(pbc, 0, IID_IStream, (void**)&pstm);
}
else //add right-click "save target as" support
{
delete filedl;

USES_CONVERSION;
LPOLESTR data = NULL;
pmk->GetDisplayName(pbc, NULL, &data);
TCHAR* myUrl = OLE2T(data);

HRESULT hr;
hr = URLDownloadToFile(NULL,myUrl,NULL,0,NULL);

if ( SUCCEEDED(hr) )
{

}
else
{
LPTSTR lpszErrorMessage;

if ( FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, hr,
MAKELANGID ( LANG_NEUTRAL, SUBLANG_DEFAULT ),
(LPTSTR) &lpszErrorMessage, 0, NULL ))
{
//sMsg.Format ( _T("Download failed. Error = 0x%08lX\n\n%s"),
// (DWORD) hr, lpszErrorMessage );

LocalFree ( lpszErrorMessage );
}
else
{
//sMsg.Format ( _T("Download failed. Error = 0x%08lX\n\nNo message available."),
// (DWORD) hr );
}
}
}
return hr;
}
History
QuestionHow to create a dynamic checkbox? Pin
AnnaWang2-Sep-07 1:55
AnnaWang2-Sep-07 1:55 
AnswerRe: How to create a dynamic checkbox? Pin
Dhiraj kumar Saini5-Sep-07 20:28
Dhiraj kumar Saini5-Sep-07 20:28 
GeneralRe: How to create a dynamic checkbox? Pin
AnnaWang9-Sep-07 3:03
AnnaWang9-Sep-07 3:03 
QuestionDisplay a CAxDialogImpl and a CWindowImpl at once. Pin
p_4731-Sep-07 5:22
p_4731-Sep-07 5:22 
QuestionBSTR Pin
anithavikram(manisha)30-Aug-07 17:50
anithavikram(manisha)30-Aug-07 17:50 
AnswerRe: BSTR Pin
prasad_som30-Aug-07 18:48
prasad_som30-Aug-07 18:48 
Questioncreate a custome right click custom menu for Internet Explorer in vc++ Pin
Dhiraj kumar Saini28-Aug-07 0:37
Dhiraj kumar Saini28-Aug-07 0:37 
AnswerRe: create a custome right click custom menu for Internet Explorer in vc++ Pin
Michael Dunn28-Aug-07 7:54
sitebuilderMichael Dunn28-Aug-07 7:54 
QuestionATL owner-draw button problem Pin
WarCraft III27-Aug-07 21:04
WarCraft III27-Aug-07 21:04 
Questionadding menu item to right click context menu Pin
Dhiraj kumar Saini27-Aug-07 1:58
Dhiraj kumar Saini27-Aug-07 1:58 
AnswerRe: adding menu item to right click context menu Pin
Michael Dunn27-Aug-07 6:53
sitebuilderMichael Dunn27-Aug-07 6:53 
GeneralRe: adding menu item to right click context menu Pin
Stephen Hewitt27-Aug-07 22:15
Stephen Hewitt27-Aug-07 22:15 
QuestionUsing QueryInterface inside a COM Pin
donguy7625-Aug-07 5:56
donguy7625-Aug-07 5:56 
AnswerRe: Using QueryInterface inside a COM Pin
Dennis Gourjii29-Aug-07 9:23
Dennis Gourjii29-Aug-07 9:23 
QuestionADODB Rowset vs Stream Arbitration [modified] Pin
Nonpareil23-Aug-07 6:56
Nonpareil23-Aug-07 6:56 
QuestionHow to get IE main menu hwnd? Pin
gzcjun22-Aug-07 22:43
gzcjun22-Aug-07 22:43 
AnswerRe: How to get IE main menu hwnd? Pin
Dennis Gourjii29-Aug-07 9:27
Dennis Gourjii29-Aug-07 9:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.