pani, .mht, alebo microsoft web archive ako uz je jasne z nazvu vynasiel microsoft a prvy krat predstavi v IE 5... alebo 5.cosi, to uz neviem
takze inde podporu asi tazko najdete
alebo ak to potrebujes nutne, nebude problem si skompilovat program na to
Kód: Vybrat vše
Function finally fixed -- have working demo
I now have this code working on my Windows 2000 Professional system, using MS Visual C++.
The errors generated by the compiler were caused by incorrect import statements. The correct statements are shown below.
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace raw_interfaces_only
#import "C:\WINNT\system32\cdosys.dll" no_namespace raw_interfaces_only
#include "C:\Program Files\Microsoft SDK\include\cdosysstr.h"
#include "C:\Program Files\Microsoft SDK\include\cdosyserr.h"
Make sure each import and include statment is on a single line. Also, note that these files may have different paths on your system.
If you cannot find these files on your system, you will probably have to download the Platform SDK from Microsoft. You will need the Core SDK and the MDAC SDK component (this is the one with the CDO/ADO support). After installation you will find the header files in the include directory of the SDK folder. The cdosys.dll should be in your system folder.
The rest of the code is OK, except you should uncomment the //return 1 statement, and add the required semicolon, so that you can evaluate the success or failure of the function upon return.
Here is that code again:
int CDBrowseView::SaveWholePage(CString szPageURL,CString szFileName)
{
CoInitialize(NULL);
BSTR bstr=szPageURL.AllocSysString();
CString szUserName="domain\\username";
BSTR bstrUserName=szUserName.AllocSysString();
CString szPass="domain\\username";
BSTR bstrPass=szPass.AllocSysString();
IMessage *pMsg=NULL;
IConfiguration* pConfig = NULL;
_Stream* pStm = NULL;
HRESULT hr=CoCreateInstance( __uuidof(Message), NULL, CLSCTX_INPROC_SERVER, __uuidof(IMessage), (void**)&pMsg);
hr=CoCreateInstance(
__uuidof(Configuration),
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IConfiguration),
(void**)&pConfig);
//pMsg->Configuration = pConfig;
pMsg->put_Configuration (pConfig);
try
{
pMsg->CreateMHTMLBody(
bstr,
cdoSuppressNone,
bstrUserName,
bstrPass );
}
catch(_com_error err)
{
// handle exception
AfxMessageBox("Exception");
return 0;
}
_StreamPtr pStream;
pMsg->GetStream(&pStm);
pStm->SaveToFile( szFileName.AllocSysString(),
adSaveCreateOverWrite);
pMsg->Release();
pStm->Release();
CoUninitialize();
return 1;
}
Just as an aside, in the event that you want to use a Save As dialog to call the function from, here is the code for that:
void CDBrowseView::OnHtmSave()
{
static char szFilter1[] = "MHT File (*.mht)|*.mht|Email File (*.eml)|*.eml||";
// FALSE gives you a file save dialog box, TRUE a file open
CFileDialog m_FileDialog(FALSE,
"mht", "*.mht",
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, szFilter1,
NULL);
if (m_FileDialog.DoModal() == IDOK)
{
// URL of web page to be saved
CString szUrl = CDBrowseView::GetLocationURL();
// filename and path return from save as dialog
CString szFile = m_FileDialog.GetPathName();
//call save page function
int r = SaveWholePage(szUrl, szFile);
// handle return code from function
if(r == 1)
AfxMessageBox("File Saved ");
else
AfxMessageBox("Save Failed ");
}
}
prevziate zo stranky
http://www.codeguru.com/Cpp/I-N/ieprogr ... hread=1029
zaciatok ...
http://www.codeguru.com/Cpp/I-N/ieprogr ... php/c4397/
edit:/ nadstavba v IE pre MHT
http://www.sycory.com/
edit:/ 2Calis, suhlasim s pavlom.minarikom, IE sa proste neda odstranit, ak si das stahovat zaplaty z winupdate kazdy den tak by si sa nemusel bat tych bezpecnostych dier
