描述:
我在VC6.0下新建了一个win32 console application,代码如下:
#import "g:\program files\common files\system\ado\msado15.dll" no_namespace
#import <cdosys.dll> no_namespace
#include "stdafx.h"
#include <iostream.h>
#include <windows.h>
#include <objbase.h>
void SaveWholePage(LPCTSTR page_url,LPCTSTR save_filename)
{
CoInitialize(NULL);
{
IMessagePtr iMsg(__uuidof(Message));
IConfigurationPtr iConf(__uuidof(Configuration));
iMsg->Configuration = iConf;
try
{
iMsg->CreateMHTMLBody(
page_url,
cdoSuppressNone,
"domain\\username",
"password");
}
catch(_com_error err)
{
// handle exception
}
_StreamPtr pStream=iMsg->GetStream();
pStream->SaveToFile( save_filename,
adSaveCreateOverWrite);
}
CoUninitialize();
}
void main()
{
SaveWholePage("http://www.zaobao.com/gj/zg002_050203.html",
"test.mht");
}
编译时错误信息为:
Compiling...
TTMht.cpp
E:\My Projects\WRules\TTMht\TTMht.cpp(18) : error C2065: 'IMessagePtr' : undeclared identifier
E:\My Projects\WRules\TTMht\TTMht.cpp(18) : error C2146: syntax error : missing ';' before identifier 'iMsg'
E:\My Projects\WRules\TTMht\TTMht.cpp(18) : error C2065: 'iMsg' : undeclared identifier
E:\My Projects\WRules\TTMht\TTMht.cpp(18) : error C2065: 'Message' : undeclared identifier
E:\My Projects\WRules\TTMht\TTMht.cpp(19) : error C2065: 'IConfigurationPtr' : undeclared identifier
E:\My Projects\WRules\TTMht\TTMht.cpp(19) : error C2146: syntax error : missing ';' before identifier 'iConf'
E:\My Projects\WRules\TTMht\TTMht.cpp(19) : error C2065: 'iConf' : undeclared identifier
E:\My Projects\WRules\TTMht\TTMht.cpp(19) : error C2065: 'Configuration' : undeclared identifier
E:\My Projects\WRules\TTMht\TTMht.cpp(20) : error C2227: left of '->Configuration' must point to class/struct/union
E:\My Projects\WRules\TTMht\TTMht.cpp(23) : error C2227: left of '->CreateMHTMLBody' must point to class/struct/union
E:\My Projects\WRules\TTMht\TTMht.cpp(25) : error C2065: 'cdoSuppressNone' : undeclared identifier
E:\My Projects\WRules\TTMht\TTMht.cpp(29) : error C2061: syntax error : identifier '_com_error'
E:\My Projects\WRules\TTMht\TTMht.cpp(29) : error C2310: catch handlers must specify one type
E:\My Projects\WRules\TTMht\TTMht.cpp(33) : error C2317: 'try' block starting on line '22' has no catch handlers
E:\My Projects\WRules\TTMht\TTMht.cpp(33) : error C2065: '_StreamPtr' : undeclared identifier
E:\My Projects\WRules\TTMht\TTMht.cpp(33) : error C2146: syntax error : missing ';' before identifier 'pStream'
E:\My Projects\WRules\TTMht\TTMht.cpp(33) : error C2065: 'pStream' : undeclared identifier
E:\My Projects\WRules\TTMht\TTMht.cpp(33) : error C2227: left of '->GetStream' must point to class/struct/union
E:\My Projects\WRules\TTMht\TTMht.cpp(34) : error C2227: left of '->SaveToFile' must point to class/struct/union
E:\My Projects\WRules\TTMht\TTMht.cpp(35) : error C2065: 'adSaveCreateOverWrite' : undeclared identifier
Error executing cl.exe.
TTMht.obj - 20 error(s), 0 warning(s)