MFC ?? ?? ?????? ????????? ?? ????? ???? ??? ??????? ????????? ????? ?? ??? ???? ????

???? ?????? ???? ??????
???? ID: 178749 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ???? illustrates, ??? ?????, ???? Microsoft Office ??????????? ??? COM-?????? ????????? ?? ??? integration ?? ???????? ???? ?? ??? ???? ?????

???? ???????

????? ??? ???? ??? ???? ??? ??? MFC illustrates ?????????? ?????? Microsoft Excel ?? ???????? ??? ????? ??? ?? ?? ???? ??? ??? ????????? ?? ??? ???? 8 ????? ?? ????? ????, ?? ??????? ??? 9 ?? 15 ?? ?????? ?? ?? ?? ???? ???? ????????? ?? ??? ??? ???? ????

??? ??????? ????????? ?????

  1. Microsoft ?????? Studio ?? ??? ?? ??? ??????? "MFC AppWizard (. exe)" ????????? ?? "AutoProject." ?? ???
  2. ??? 1 ??? MFC AppWizard ??, ????????? ?????? ?? ??? "????? ??????" ????? ?? ???? ??? ?????? ???? ????? ?????

    ??? ????????? ??????? ????? ????? ????? ???? ?? ?? ????? ???? ?? ?? ????? ?? ???? ?? ??? ???? ????? ???:
          Application: CAutoProjectApp in AutoProject.h and AutoProject.cpp
          Dialog: CAutoProjectDlg in AutoProject.h and AutoProjectDlg.cpp
    						
    ????????? ????? ?? ??? ??? ????? ?????
  3. Visual Studio ??????/?????? ??????? ??? "IDD_AUTOPROJECT_DIALOG" ????? ????? ????? ??? ???? ?? ????? ??? ????????? ?? ?????? ??? ??????? ?????
  4. ???? ???????? (IDC_STATIC) ?? ' ???? ???? ' ??? ?? ??????? (IDCANCEL)?
  5. "IDRUN" ?? "?????." ???? ?? ??? ?????? ?? ??? ??? ' ??? ?? ??? ????????? ???? AutoProject.rc ????? ????? ??????? ??????? ??? ?????
  6. ClassWizard ' ????? ' ???? ?? ????? ???? (?? CTRL + W ?????)?
  7. ????? ??? ?? ??? ???? tab. ???????? ids ??? IDRUN ??? ????? ?? ???????? ??, ?? ????? ???? ????? ??? "BN_CLICKED" ?? ??? ????? ?????? ?????? ????? ????, ?? "OnRun" ?????? ??? ??????? ????? ClassWizard ??? ???? ?? ??? ??? ????? ?????

    ????? ???: ?? ??? ????? declaration ???? ?????? ?? ????? ?? ??? "OnRun();" ????? ??? ?? ??? ????? ??? AutoProjectDLG.h. ?? ??? ??? ?? ??? ????? skeleton ????? ?????? ?????? CAutoProjectDlg::OnRun() AutoProjectDLG.cpp ???? ???? ??? ?? ??????
  8. ClassWizard ' ????? ' ???? ?? ????? ???? (?? CTRL + W ?????)?
  9. ??????? tab. ?????? ???? ????? ???? ?? ??? ???? ?? "?? ???? ?????? ?????????." ????? ???????? ????????? ?? ???????? ???? ?? ??? ?????? ????????? ?? ??? ?? ??? ???? ?? ??? ??????? ???? (?? ??? ?? ??????, ??? Excel 97, ??????? ??? Microsoft Excel 8.0 ???????? ????????? ?????; ??????? ????? ?? C:\Program Files\Microsoft Office\Office\Excel8.olb ??)?

    ??? ?? Microsoft Excel 2000 ?? ??????? ?? ??? ???, ?? Microsoft Excel 9.0 ???????? ????????? ?? ??? ?? C:\Program Files\Microsoft Office\Office\Excel9.olb ?? ??????? ????? ?? ??????

    ??? ?? Microsoft Excel 2002 ?? Microsoft Office Excel 2003 ??????? ???, ?? ???????? ????????? Excel.exe ????? ??? ???????? ??? Office 2002 ??? Excel.exe ?? ??? ??????? ????? ?? C:\program Files\Microsoft Office\Office10\Excel.exe ??? Office 2003 ??? Excel.exe ?? ??? ??????? ????? ?? C:\program Files\Microsoft Office\Office11\Excel.exe ??? ?? ??? ?? ?? ??????? ???????? ????????? ?? ????? ??, ????? ????? ????? ??? ???? ?? ?????? ???? ?? ??? ???? ????, ?? ???? ??? ?? ??? Classes.

    ????? ???: ???? ?? ?????? ???? ????? ????? ??? ???? ????? ??? ??? IDispatch ??????? (?? ???? ?? ??? virtually ????? ???) ??? Microsoft Excel ?????? ????????? ??? ????? ?? ???? ??? ??? ???? wrappers ColeDispatchDriver() ?? ??????? ????? ?? ??????? ?? Excel8.cpp ???? ????????????? ????? ??? ????, ?? ??????? declaration ????? ??? ???? Excel8.h ??? ??? (Excel 2002 ?? Excel 2003, ?? ??? ??????? ??? ???? Excel.cpp ?? Excel.h.)
  10. MFC ClassWizard ????? ????? ?? ??? ???? ?? ??? ??? ????? ?????
  11. ????? ??? CAutoProjectApp::InitInstance() ????? ???? ?? ???, ?? loads ?? COM ?? ????? ???? ????????? ??? ??????:
          BOOL CAutoProjectApp::InitInstance()
          {
             if(!AfxOleInit())  // Your addition starts here
             {
                AfxMessageBox("Could not initialize COM dll");
                return FALSE;
             }                 // End of your addition
    
             AfxEnableControlContainer();
          .
          .
          .
    
          }
    					
  12. ????? ?????? AutoProject.cpp ????????? ????? ?? ????? ?? ????? # ???? ?? ??? ?????? ????? ????:
          #include <afxdisp.h>
    					
  13. AutoProjectDlg.cpp ????????? ????? ?? ????? ?? stdafx.h ?? ??? ???????? ??? ?? ??? excel8.h ?? ??? ???????? ??? ??? ??????:
          #include "stdafx.h"
          #include "excel8.h" // excel.h in the case of Excel 2002 and Excel 2003.
    					
  14. CAutoProjectDlg::OnRun() ???? ?? ??? ??????? ??? ?????? ????? ??? ???? ????? ?? ?? ??? ??? ????? ??:
          void CAutoProjectDlg::OnRun()
          {
              _Application app;  // app is the Excel _Application object
    
              // Start Excel and get Application object...
             if(!app.CreateDispatch("Excel.Application"))
             {
                AfxMessageBox("Couldn't start Excel.");
             }
             else
             {
                //Make Excel Visible and display a message
              app.SetVisible(TRUE);
              AfxMessageBox ("Excel is Running!");
             }
          }
    					
  15. ?????, ?? ????????? ?? ?????? ??????: ?? ???? ????? ????? ???? ????? ????? ???, Microsoft Excel ??? ' ??? ?? ????? ?????? Auto_Excel ????? ????? ?????? ??, ?? ????? ????? ?? ?????? ????? Microsoft Excel ?? ???? ?????? ????? ?? CAutoProjectDlg::OnRun() ?????? ?????? ???? ?? ??????? ????????? ?? ????? ?? ???? ??? ?? ??????

???????? ?????

?? ??? ???? ?????? ???? ??? ???? ???? ?????? ????????? ?? ???? ????????? ?? ??? (???? ?? ?? ??? ??? 9 ???), ???? ????? ???? ?? ?? ???? ????????? ??? ????? ??? ??? ClassView, ??? ?? ?? ???? ?? ???? ?? ????? ?????? ?????, ?? ?? ????? ?????? Excel8.cpp ??????????? ????? ??? ?? ????? ?? ??????? ?? ????? ?? ??? ???-????? ???? ?? ??? ??? ????? ?? ???? ????

??? ?? ???? ?????? ?? ????? ?? ???? ???? ????? ??? ?? ??? ???? ??? ?????? ?? ??????????? ?? ????????? ???? ?? ??? ??? ????? ?????? ?? ???????? ???? ?? ??? ???? ?? ??? ?????? ??? ???? ?? ??? ?? ???? ?????? ??????? ??? declaration Excel8.h ????? ??? ????????? ???? ?? ??? ??? ????? ?? ???, ????????? ???? ?? ?? ?? ??? ?????? declaration ????????? ????; ???-???, ?? ?? ??? ?? ?? ?? ?? ??, ?? ?????? classes--GetApplication() ?? ????? ?????? ?? ?? ??? ???????

??? ??? ????? ??? Microsoft Excel ?? ???????? ???? ?? ??? ???? illustrate, ?????? ?? ?? ?? ???? ???? ??????????? ?? ??????? ?? ??? ???? ?? ???? ???? ???? ?? ?? ???? ??? Microsoft Office ??????????? ?? ?????? ????????? ?? ??? ????? ?? ??? ??:
   Application                           Type Library
   --------------------------------------------------

   Microsoft Access 97                   Msacc8.olb
   Microsoft Jet Database 3.5            DAO350.dll
   Microsoft Binder 97                   Msbdr8.olb
   Microsoft Excel 97                    Excel8.olb
   Microsoft Graph 97                    Graph8.olb
   Microsoft Office 97                   Mso97.dll
   Microsoft Outlook 97                  Msoutl97.olb
   Microsoft PowerPoint 97               Msppt8.olb

   Microsoft Word 97                     Msword8.olb
   Microsoft Access 2000                 Msacc9.olb
   Microsoft Jet Database 3.51           DAO360.dll
   Microsoft Binder 2000                 Msbdr9.olb
   Microsoft Excel 2000                  Excel9.olb
   Microsoft Graph 2000                  Graph9.olb
   Microsoft Office 2000                 Mso9.dll
   Microsoft Outlook 2000                Msoutl9.olb
   Microsoft PowerPoint 2000             Msppt9.olb
   Microsoft Word 2000                   Msword9.olb 

   Microsoft Access 2002                 Msacc.olb
   Microsoft Excel 2002                  Excel.exe
   Microsoft Graph 2002                  Graph.exe 
   Microsoft Office 2002                 MSO.dll
   Microsoft Outlook 2002                MSOutl.olb
   Microsoft PowerPoint 2002             MSPpt.olb
   Microsoft Word 2002                   MSWord.olb

   Microsoft Office Access 2003          Msacc.olb
   Microsoft Office Excel 2003           Excel.exe
   Microsoft Graph 2003                  Graph.exe 
   Microsoft Office 2003                 MSO.dll
   Microsoft Office Outlook 2003         MSOutl.olb
   Microsoft Office PowerPoint 2003      MSPpt.olb
   Microsoft Office Word 2003            MSWord.olb
				
????? ???: ?? ?????? ????????? ?? ??? ??????? ????? ?? C:\Program Files\Microsoft Office\Office (?? ??? Office 2002 ?? C:\...\Office10 ?? Office 2003 ?? ??? ?? ?? C:\...\Office11), Dao350.dll ?? Dao360.dll, ?? ????? ?? Microsoft Office 10(MSO.dll). Dao350.dll/Dao360.dll ?? ??? ??????? ????? ?? C:\Program Files\Common Files\Microsoft Shared\Dao ??? Office 2002 ?? ??? C:\Program Files\Common Files\Microsoft Shared\Office10 ?? Office 2003 ?? ??? C:\Program Files\Common Files\Microsoft Shared\Office11 MSO.dll ?? ??? ??????? ????? ???

??????

?? ???? ??? ?? ????? ????? ????????? ????? ?? ??? ??? ??????? approach presents. ??? ?? ???? VC ++ ????????? ??? Microsoft ?????? Studio ????? ?? ????????? ?? ???? ??? ???? ??????? ???????? ????? ???? ????? ???, ??????? excellent ?????????? ??? Visual Studio InfoView ?? ????? ?? ????? ???? ??? ?????????? ?? ????? ??, ' ??? ' ???? ?? ????? ????? ????? ??????????? ??? ????? ????, ?? ????? ???? ????:
????????? ?? ??? ????? ????
???? ?? ???? ?? ????? ????? ???? "??? ?????: ????? ?? ??? ???????????" ?? ??? ????, ?? ???????? ?? ????? ?????Office ??????????? ?? ??????? ?? ???? ??? ???? ??????? ?? ??? Microsoft ???????? ??? ???? ????? ?? ??? ????? ???? ?????? ?? ????? ????:
222101?????? ?? Office ???????? ???? ???????? ?? ????? ???? ????

???

???? ID: 178749 - ????? ???????: 03 ?????? 2010 - ??????: 4.0
???? ???? ???? ??:
  • Microsoft Foundation Class Library 4.2
  • Microsoft Office XP Developer Edition
  • Microsoft Office 2000 Developer Edition
??????: 
kbautomation kbhowto kbinterop kbmt KB178749 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:178749

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com