Download example source code
Link: http://www.vckbase.com/vckbase/vckbase12/vc/nonctrls/atlcomocx_02/1202008.htm
Many programs now support plug-ins, which can be easily expanded. Plug-ins generally require standard interfaces. Here we will make the simplest plug-in. The plug-in structure is defined as follows:
This is the output function of the plug-in DLL, used to create the plug-in.
Bool plug_createobject (void ** pobj ){
* Pobj = new cmyplug;
Return * pobj! = NULL;
}
Plug-in base class definition
Class cplugbase {
Public:
Cplugbase (){};
Public:
Virtual hicon getIcon () = 0; // display the plug-in icon
Virtual void Hello (int K) = 0; // function of the plug-in.
Virtual void release () = 0; // release the plug-in.
};
The class of the plug-in must be based on cplugbase. To implement the above three functions, other functions can be expanded as needed.
This example includes a main program and two plug-ins.
Main program interface:
This is the interface when no plug-in is available. We can click plug-in-> to add plug-ins. The program pops up.
Enter the category and plug-in files and press OK to add a plug-in. After adding the plug-in, the program automatically adds an icon:
This icon represents the plug-in just now. We can also add another plug-in.
Let's test and click "1标1,
We test and click 1标2
The preceding two messages are displayed when the hello function of the plug-in is run.
When the program is started next time, the plug-in is automatically added and you do not need to register it again.
The above program is compiled and run in Win2000 professional + vc6 + SP5 + platform SDK 2001.11.
Generally, you can install VC. I have done similar operations in vc5 + Win98 in the past.