用VC,不出现“另存为。。”对话框。

解决方案 »

  1.   

    //导入必要的库
    #import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF", "EndOfFile")
    #import <cdosys.dll> no_namespace rename("EOF", "EndOfFile")//代码
    void CAssetReportDlg::OnButtonSave() 
    {
    GetDlgItem(IDC_BUTTON_SAVE)->EnableWindow(FALSE);
    CFileDialog fdlg(FALSE,
    "mht",
    m_FileNameCN,
    OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
    "Web档案,单一文件(*.mht)|*.mht||");
    if(IDOK == fdlg.DoModal())
    {
    CString strPathFile = fdlg.GetPathName();
    IMessagePtr       iMsg(__uuidof(Message));
    IConfigurationPtr iConf(__uuidof(Configuration));
    iMsg->Configuration = iConf;
    _bstr_t url;
    try
    {
    m_FileName.Insert(0,"file://");//注意这里!
    url = (LPSTR)(LPCSTR)m_FileName;iMsg->CreateMHTMLBody(
    url, 
    cdoSuppressNone,
    "domain\\username",
    "password");
    }
    catch(_com_error err)
    {
    // handle exception
    }
    _StreamPtr pStream=iMsg->GetStream();
    url = (LPSTR)(LPCSTR)strPathFile;pStream->SaveToFile(url,adSaveCreateOverWrite);
    ::MessageBox(0,"保存结束","信息",MB_OK|MB_ICONASTERISK);
    }
    GetDlgItem(IDC_BUTTON_SAVE)->EnableWindow(TRUE);
    谢谢!