How to add plug-ins to your programs-use dll as plug-ins

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.