Hi everybody,
The following snippet is part of a software. This software runs on a webpage and the following snippet saves that webpage. The problem is that untill i close down the website on which the software is working the process of saving file is not getting completed. I want the software to be running on that website so the website to be open while the page is saved. Please help.
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spHTMLDocument2;
CComPtr<IDispatch> pDisp;
MessageBox("Saving file","",MB_OK);
_Module.m_pWebBrowser->get_Document(&pDisp);
spHTMLDocument2 = pDisp;
IPersistFile* pFile = NULL;
if(SUCCEEDED(spHTMLDocument2->QueryInterface(IID_IPersistFile, (void **)&pFile)))
{
if ((pFile->Save(L"c:\\593\\eclipse\\workspace\\pardom\\partitionDom\\files\\news\\urlName.htm",FALSE)) == E_FAIL)
{
MessageBox("Unable to Save File", "", MB_OK);
}
if((pFile->SaveCompleted(L"c:\\593\\eclipse\\workspace\\pardom\\partitionDom\\files\\news\\urlName.htm")) == E_FAIL)
{
MessageBox("Unable to SaveComplete File", "", MB_OK);
}
}
/********/
MessageBox("Saved file","",MB_OK);
int a;
pDisp.Release();
//a = pFile->Release();
pFile->Release();
MessageBox("Handle Released", "", MB_OK);
CloseHandle(hProcess);
Even i tried using the following snippet but the same result was obtained
LPDISPATCH lpDispatch=GetHtmlDocument();
LPDISPATCH lpDispatch=pDisp;
IPersistFile *lpPersistFile = NULL;
lpDispatch->QueryInterface(IID_IPersistFile, (void**)&lpPersistFile);
USES_CONVERSION;
// LPCOLESTR TheFileName=A2COLE("c:\\593\\eclipse\\workspace\\pardom\\partitionDom\\files\\news\\urlName.htm");
lpPersistFile->Save(L"c:\\593\\eclipse\\workspace\\pardom\\partitionDom\\files\\news\\urlName.htm",1);
lpPersistFile->SaveCompleted(L"c:\\593\\eclipse\\workspace\\pardom\\partitionDom\\files\\news\\urlName.htm");
// lpPersistFile->Save(TheFileName,0);
lpPersistFile->Release();
I wasnt able to save using the function LPCOLESTR. I was getting error when i used that but was able to save using function L.
Please help on the above topic.
Ajay Kalra - 13 Jun 2004 13:56 GMT
I am curious as to why you are not using URLDOwnloadToFile to do this?
--
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com
> Hi everybody,
>
> The following snippet is part of a software. This software runs on a webpage and the following snippet saves that webpage. The problem is that
untill i close down the website on which the software is working the process
of saving file is not getting completed. I want the software to be running
on that website so the website to be open while the page is saved. Please
help.
> CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spHTMLDocument2;
>
[quoted text clipped - 11 lines]
>
> if
((pFile->Save(L"c:\\593\\eclipse\\workspace\\pardom\\partitionDom\\files\\ne
ws\\urlName.htm",FALSE)) == E_FAIL)
> {
> MessageBox("Unable to Save File", "", MB_OK);
> }
if((pFile->SaveCompleted(L"c:\\593\\eclipse\\workspace\\pardom\\partitionDom
\\files\\news\\urlName.htm")) == E_FAIL)
> {
>
[quoted text clipped - 22 lines]
> USES_CONVERSION;
> // LPCOLESTR
TheFileName=A2COLE("c:\\593\\eclipse\\workspace\\pardom\\partitionDom\\files
\\news\\urlName.htm");
lpPersistFile->Save(L"c:\\593\\eclipse\\workspace\\pardom\\partitionDom\\fil
es\\news\\urlName.htm",1);
lpPersistFile->SaveCompleted(L"c:\\593\\eclipse\\workspace\\pardom\\partitio
nDom\\files\\news\\urlName.htm");
> // lpPersistFile->Save(TheFileName,0);
> lpPersistFile->Release();
>
> I wasnt able to save using the function LPCOLESTR. I was getting error when i used that but was able to save using function L.
>
> Please help on the above topic.