Many programs now support plug-in Plug-ins, Plug-ins can make the program easy to expand. Plug-ins are generally required to have a standard interface. We are here to make the simplest plug-ins. The structure of the plug-in is defined as follows:
This is the output function of the plug-in DLL, which is used to create plug-ins.
BOOL Plug_CreateObject(void ** pobj){
*pobj = new CMyPlug;
return *pobj != NULL;
}
base class definition for Plug-ins
class CPlugBase {
public:
CPlugBase(){};
public:
virtual HICON GetIcon() = 0; //用于显示插件的图标
virtual void Hello(int k) = 0; //插件的功能函数。
virtual void Release() = 0; //释放插件。
};
The plug-in's class must be based on cplugbase, to implement the above three functions, others can be arbitrarily extended.
This example includes a main program and two plugins.
Main Program Interface:
This is not a plugin when the interface, we can click on plug-in-〉 added to add Plug-ins, program pop-up
We enter the category and plug-in files, press OK to add a plugin, add after the program automatically add an icon:
This icon represents just that plugin, again we can add a plugin
We test click on the icon 1,
We test click on the icon 2
The above two message is displayed by the Hello function that runs the plug-in.
The next time the program starts, the plugin has been automatically added, without registering again.
The above procedures are compiled and run through Win2000 Professional + VC6 + SP5 + Platform SDK 2001.11.
General installation of VC can be, before I have done similar in vc5+win98.
This article supporting source code