How to self-made function modules

xiaoxiao2021-03-06  44

How to self-made function modules

The function module is a dynamic link library (DLL) file, and the function module DLL is called by the main program in the same interface specification. If you want homemade function module DLL to extend the system's function, your DLL should export the following functions: Extern "c" __declspec (dllexport) Ansistring getModulenAme (); // Export Module Name EXTERN "C" __DECLSPEC (DLLEXPORT) ANSISTRING GETMODULE () ; // Export Module Description EXTERN "C" __DECLSPEC (DLLEXPORT) INT getModuleId (); // Export Module ID EXTERN "C" __DECLSPEC (DLLEXPORT) ANSISTRING GETAUTHOR (); // Export author Name Extern "C" __declspec (dllexport) INT getverID (); // Guide the version of the code EXTERN "C" __DECLSPEC (DLLEXPORT) ANSISTRING GETBUILDDATE (); // Export Creative Date EXTERN "C" __DECLSPEC (DLLEXPORT) INT getFunccount (); // Export The number of call functions in the module Extern "C" __DECLSPEC (DLLEXPORT) BOOL GETFUNCINFO (Funcinfo & Fi, INT I); / / Export Information EXTERN "C" __DECLSPEC (DLLEXPORT) Void Run (INT I, ANSISTRING PARAMS); // Tape parameters Call the iSpec () "c" __declspec (dllexport) BOOL Useconnection (); // Whether to use data connection extern "c" __declspec (tadoconnection *); // Transfer the data connection of the master program In DLL. Extern "C" __declspec (dllexport) void setmain (TAPPLICATION * APP); // Set the main program

FunctionInfo is a structural definition, you should define it in front of the DLL entry function, the definition statement is as follows: typef struct functioninfo {char Caption [20]; // Tit, used on the menu bar Char Hite [100]; // Tip, used to display the resource ID of the status bar int smallimageid; // small icon, 0 is no icon INT LARGEIMAGEID; // large icon resource ID, 0 is no icon} Funcinfo; according to the number of functions in the DLL, you need Create a variable or variable array for the FunctionInfo structure, and export the element number of this variable array with getFunccount to make the master program understand how many functions in this DLL can be modified. The master program will use the GetFuncinfo function provided by the DLL to pass each function to use the corresponding menu bar or button in the master program. When the corresponding function call event in the master program is excited, the DLL RUN method will be called.

DLL sharing master program data connection

DLL can share the data connection established by the master program. At this time, you should export the useconnection to true, and export the setConnection method to allow the master to pass its AdoConnection to the DLL.

Specify the icon for function

You can use different icons to represent the features in the DLL. To do this, you must build a resource file first, add this resource for the DLL. Finally, specify the resource ID of its size icon in the function information object of the FunctionInfo structure, and the master program will read this resource when needed. Permission control

The permissions of the function are managed by the master program, incorporating the scope of system management. If the function module author wants to control the additional permissions, we recommend:

Check if the master program is safe, there is no counterfeit master program to implement the data connection of the master program, which is only increasing chaos and risk, and does not increase additional security.

Module function deployment

All installed modules are unified in the master program. The rights control of the master program and the user interface custom function, the display and layout control of the module on the interface, the module itself does not have to care about how its interface is presented to the user, as long as it can call its RUN method when the master program calls its Run method Guaranteed it normally. The main program uses the main menu and the PageControl-based multi-page toolbar to represent each function, similar to the Ide style of the BCB.

Call the function of other modules

To call the functions in the other module DLL in the function module, you can broadcast a dedicated message, the master program will intercept this message, and start the corresponding functional module according to the message of the message. Send message format to be determined.

转载请注明原文地址:https://www.9cbs.com/read-55501.html

New Post(0)