MFC下COM框架实例.docx

上传人:b****5 文档编号:12119647 上传时间:2023-04-17 格式:DOCX 页数:28 大小:20.52KB
下载 相关 举报
MFC下COM框架实例.docx_第1页
第1页 / 共28页
MFC下COM框架实例.docx_第2页
第2页 / 共28页
MFC下COM框架实例.docx_第3页
第3页 / 共28页
MFC下COM框架实例.docx_第4页
第4页 / 共28页
MFC下COM框架实例.docx_第5页
第5页 / 共28页
点击查看更多>>
下载资源
资源描述

MFC下COM框架实例.docx

《MFC下COM框架实例.docx》由会员分享,可在线阅读,更多相关《MFC下COM框架实例.docx(28页珍藏版)》请在冰豆网上搜索。

MFC下COM框架实例.docx

MFC下COM框架实例

DictComp\DictComp.cpp

DictComp\DictComp.def

DictComp\DictComp.h

DictComp\DictComp.odl

DictComp\DictComp.rc

DictComp\DictionaryObj.cpp

DictComp\DictionaryObj.h

DictComp\Interface.h

DictComp\Resource.h

DictComp\StdAfx.cpp

DictComp\StdAfx.h

///DictComp/DictComp.cpp

//DictComp.cpp:

DefinestheinitializationroutinesfortheDLL.

//

#include"stdafx.h"

#include"DictComp.h"

#ifdef_DEBUG

#definenewDEBUG_NEW

#undefTHIS_FILE

staticcharTHIS_FILE[]=__FILE__;

#endif

//

//Note!

//

//IfthisDLLisdynamicallylinkedagainsttheMFC

//DLLs,anyfunctionsexportedfromthisDLLwhich

//callintoMFCmusthavetheAFX_MANAGE_STATEmacro

//addedattheverybeginningofthefunction.

//

//Forexample:

//

//extern"C"BOOLPASCALEXPORTExportedFunction()

//{

//AFX_MANAGE_STATE(AfxGetStaticModuleState());

////normalfunctionbodyhere

//}

//

//Itisveryimportantthatthismacroappearineach

//function,priortoanycallsintoMFC.Thismeansthat

//itmustappearasthefirststatementwithinthe

//function,evenbeforeanyobjectvariabledeclarations

//astheirconstructorsmaygeneratecallsintotheMFC

//DLL.

//

//PleaseseeMFCTechnicalNotes33and58foradditional

//details.

//

/////////////////////////////////////////////////////////////////////////////

//CDictCompApp

BEGIN_MESSAGE_MAP(CDictCompApp,CWinApp)

//_{{AFX_MSG_MAP(CDictCompApp)

//NOTE-theClassWizardwilladdandremovemappingmacroshere.

//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!

//_}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

//CDictCompAppconstruction

CDictCompApp:

:

CDictCompApp()

{

//TODO:

addconstructioncodehere,

//PlaceallsignificantinitializationinInitInstance

}

/////////////////////////////////////////////////////////////////////////////

//TheoneandonlyCDictCompAppobject

CDictCompApptheApp;

/////////////////////////////////////////////////////////////////////////////

//CDictCompAppinitialization

BOOLCDictCompApp:

:

InitInstance()

{

//RegisterallOLEserver(factories)asrunning.Thisenablesthe

//OLElibrariestocreateobjectsfromotherapplications.

COleObjectFactory:

:

RegisterAll();

returnTRUE;

}

/////////////////////////////////////////////////////////////////////////////

//Specialentrypointsrequiredforinprocservers

STDAPIDllGetClassObject(REFCLSIDrclsid,REFIIDriid,LPVOID*ppv)

{

AFX_MANAGE_STATE(AfxGetStaticModuleState());

returnAfxDllGetClassObject(rclsid,riid,ppv);

}

STDAPIDllCanUnloadNow(void)

{

AFX_MANAGE_STATE(AfxGetStaticModuleState());

returnAfxDllCanUnloadNow();

}

//byexportingDllRegisterServer,youcanuseregsvr.exe

STDAPIDllRegisterServer(void)

{

AFX_MANAGE_STATE(AfxGetStaticModuleState());

COleObjectFactory:

:

UpdateRegistryAll();

returnS_OK;

}

///DictComp/DictComp.def

;DictComp.def:

DeclaresthemoduleparametersfortheDLL.

LIBRARY"DictComp"

DESCRIPTION'DictCompWindowsDynamicLinkLibrary'

EXPORTS

;Explicitexportscangohere

DllCanUnloadNowPRIVATE

DllGetClassObjectPRIVATE

DllRegisterServerPRIVATE

///DictComp/DictComp.h

//DictComp.h:

mainheaderfilefortheDICTCOMPDLL

//

#if!

defined(AFX_DICTCOMP_H__84B0BBFB_AD8B_11D2_A2DC_A31D6122660F__INCLUDED_)

#defineAFX_DICTCOMP_H__84B0BBFB_AD8B_11D2_A2DC_A31D6122660F__INCLUDED_

#if_MSC_VER>1000

#pragmaonce

#endif//_MSC_VER>1000

#ifndef__AFXWIN_H__

#errorinclude'stdafx.h'beforeincludingthisfileforPCH

#endif

#include"resource.h"//mainsymbols

/////////////////////////////////////////////////////////////////////////////

//CDictCompApp

//SeeDictComp.cppfortheimplementationofthisclass

//

classCDictCompApp:

publicCWinApp

{

public:

CDictCompApp();

//Overrides

//ClassWizardgeneratedvirtualfunctionoverrides

//_{{AFX_VIRTUAL(CDictCompApp)

public:

virtualBOOLInitInstance();

//_}}AFX_VIRTUAL

//_{{AFX_MSG(CDictCompApp)

//NOTE-theClassWizardwilladdandremovememberfunctionshere.

//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!

//_}}AFX_MSG

DECLARE_MESSAGE_MAP()

};

/////////////////////////////////////////////////////////////////////////////

//_{{AFX_INSERT_LOCATION}}

//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.

#endif//!

defined(AFX_DICTCOMP_H__84B0BBFB_AD8B_11D2_A2DC_A31D6122660F__INCLUDED_)

///DictComp/DictComp.odl

//DictComp.odl:

typelibrarysourceforDictComp.dll

//ThisfilewillbeprocessedbytheMIDLcompilertoproducethe

//typelibrary(DictComp.tlb).

[uuid(84B0BBF6-AD8B-11D2-A2DC-A31D6122660F),version(1.0)]

libraryDictComp

{

importlib("stdole32.tlb");

importlib("stdole2.tlb");

//_{{AFX_APPEND_ODL}}

//_}}AFX_APPEND_ODL}}

};

///DictComp/DictComp.rc

//MicrosoftVisualC++generatedresourcescript.

//

#include"resource.h"

#defineAPSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////

//

//GeneratedfromtheTEXTINCLUDE2resource.

//

#include"afxres.h"

/////////////////////////////////////////////////////////////////////////////

#undefAPSTUDIO_READONLY_SYMBOLS

#ifdefAPSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////

//

//TEXTINCLUDE

//

1TEXTINCLUDEDISCARDABLE

BEGIN

"resource.h\0"

END

2TEXTINCLUDEDISCARDABLE

BEGIN

"#include""afxres.h""\r\n"

"\0"

END

3TEXTINCLUDEDISCARDABLE

BEGIN

"#define_AFX_NO_SPLITTER_RESOURCES\r\n"

"#define_AFX_NO_OLE_RESOURCES\r\n"

"#define_AFX_NO_TRACKER_RESOURCES\r\n"

"#define_AFX_NO_PROPERTY_RESOURCES\r\n"

"\r\n"

"#if!

defined(AFX_RESOURCE_DLL)||defined(AFX_TARG_CHS)\r\n"

"#ifdef_WIN32\r\n"

"LANGUAGE4,2\r\n"

"#pragmacode_page(936)\r\n"

"#endif//_WIN32\r\n"

"#include""res\\DictComp.rc2""//non-MicrosoftVisualC++editedresources\r\n"

"#include""l.chs\\afxres.rc""//Standardcomponents\r\n"

"#endif\r\n"

"\0"

END

/////////////////////////////////////////////////////////////////////////////

#endif//APSTUDIO_INVOKED

#if!

defined(AFX_RESOURCE_DLL)||defined(AFX_TARG_CHS)

#ifdef_WIN32

LANGUAGE4,2

#pragmacode_page(936)

#endif//_WIN32

/////////////////////////////////////////////////////////////////////////////

//

//Version

//

VS_VERSION_INFOVERSIONINFO

FILEVERSION1,0,0,1

PRODUCTVERSION1,0,0,1

FILEFLAGSMASK0x3fL

#ifdef_DEBUG

FILEFLAGS0x1L

#else

FILEFLAGS0x0L

#endif

FILEOS0x4L

FILETYPE0x2L

FILESUBTYPE0x0L

BEGIN

BLOCK"StringFileInfo"

BEGIN

BLOCK"080404B0"

BEGIN

VALUE"CompanyName","\0"

VALUE"FileDescription","DictCompDLL\0"

VALUE"FileVersion","1,0,0,1\0"

VALUE"InternalName","DictComp\0"

VALUE"LegalCopyright","版权所有(C)1999\0"

VALUE"LegalTrademarks","\0"

VALUE"OriginalFilename","DictComp.DLL\0"

VALUE"ProductName","DictCompDynamicLinkLibrary\0"

VALUE"ProductVersion","1,0,0,1\0"

VALUE"OLESelfRegister","\0"

END

END

BLOCK"VarFileInfo"

BEGIN

VALUE"Translation",0x0804,1200

END

END

#endif

#ifndefAPSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////

//

//GeneratedfromtheTEXTINCLUDE3resource.

//

#define_AFX_NO_SPLITTER_RESOURCES

#define_AFX_NO_OLE_RESOURCES

#define_AFX_NO_TRACKER_RESOURCES

#define_AFX_NO_PROPERTY_RESOURCES

1TYPELIB"DictComp.tlb"

#if!

defined(AFX_RESOURCE_DLL)||defined(AFX_TARG_CHS)

#ifdef_WIN32

LANGUAGE4,2

#pragmacode_page(936)

#endif//_WIN32

#include"res\\DictComp.rc2"//non-MicrosoftVisualC++editedresources

#include"l.chs\\afxres.rc"//Standardcomponents

#endif

/////////////////////////////////////////////////////////////////////////////

#endif//notAPSTUDIO_INVOKED

///DictComp/DictionaryObj.cpp

//DictionaryObj.cpp:

implementationfile

//

#include"stdafx.h"

#include"DictComp.h"

#include

#include"DictionaryObj.h"

#ifdef_DEBUG

#definenewDEBUG_NEW

#undefTHIS_FILE

staticcharTHIS_FILE[]=__FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

//CDictionaryObj

IMPLEMENT_DYNCREATE(CDictionaryObj,CCmdTarget)

CDictionaryObj:

:

CDictionaryObj()

{

m_nWordNumber=0;

m_nStructNumber=0;

m_pData=NULL;

}

CDictionaryObj:

:

~CDictionaryObj()

{

if(m_pData!

=NULL)

{

delete[]m_pData;

}

}

BEGIN_MESSAGE_MAP(CDictionaryObj,CCmdTarget)

//_{{AFX_MSG_MAP(CDictionaryObj)

//NOTE-theClassWizardwilladdandremovemappingmacroshere.

//_}}AFX_MSG_MAP

END_MESSAGE_MAP()

extern"C"constIIDIID_Dictionary=

{0x54bf6568,0x1007,0x11d1,

{0xb0,0xaa,0x44,0x45,0x53,0x54,0x00,0x00}};

extern"C"constIIDIID_SpellCheck=

{0x54bf6569,0x1007,0x11d1,

{0xb0,0xaa,0x44,0x45,0x53,0x54,0x00,0x00}};

BEGIN_INTERFACE_MAP(CDictionaryObj,CCmdTarget)

INTERFACE_PART(CDictionaryObj,IID_Dictionary,Dictionary)

INTERFACE_PART(CDictionaryObj,IID_SpellCheck,SpellCheck)

END_INTERFACE_MAP()

//{54BF6567-1007-11D1-B0AA-444553540000}

IMPLEMENT_OLECREATE(CDictionaryObj,"Dictionary.Object",

0x54bf6567,0x1007,0x11d1,0xb0,0xaa,0x44,0x45,0x53,0x54,0x00,0x00)

/////////////////////////////////////////////////////////////////////////////

//CDictionaryObj:

:

XDictionary

STDMETHODIMP_(ULONG)CDictionaryObj:

:

XDictionary:

:

AddRef()

{

METHOD_PROLOGUE_EX_(CDictionaryObj,Dictionary)

return(ULONG)pThis->ExternalAddRef();

}

STDMETHODIMP_(ULONG)CDictionaryObj:

:

XDictionary:

:

Release()

{

METHOD_PROLOGUE_EX_(CDictionaryObj,Dictionary)

return(ULONG)pThis->ExternalRelease();

}

STDMETHODIMPCDictionaryObj:

:

XDictionary:

:

QueryInterface(

REFIIDiid,LPVOID*ppvObj)

{

METHOD_PROLOGUE_EX_(CDictionar

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1