Use DLL to enhance software features

zhaozj2021-02-11  213

---- Microsoft Windows provides special libraries (DLLs) called dynamic connectors, allowing the application to share code and resources. The DLL is an executable module including a trunk function that provides services for other procedures. Windows uses a DLL to provide the code and resources for all Windows applications. In addition, the programming can also create a self-employed DLL, sharing code and resources between self-employed procedures.

---- DLL master must have the following goals:

The shared code and resource based on the system of information is based on the system of information.

---- We are now going to study the problem, if you have to develop DLL to expand, increase the functionality of common software, such as: VB4.0, Toolbook3.0, etc.

---- Commonly used to open the DLL platform with Blandc , MS Visualc , both of which have a fixed difference between the DLL, but the most convenient is MS Visualc . I used MS Visualc to send a demo.dll, which defines a function: f1 = (x, y) = x * y. In this example, the DLL's programming structure is revealed, and the powerful software function is increased by the call to Demo.dll.

---- Example:

---- Define a F1 (x, y) = x * y in Demo.dll;

---- Total total needs three documents: demo.h; demo.c; demo.def

* In the header (Demo.h):

#include

EXTERN INT_EXPORT_FAR_PASCAL F1 (INT, INT);

* In the source program (DEMO.C):

#include

#include "demo.h"

Int Far Pascal Libmain (Hinstance Hinstance,

Word WDataseGment,

Word Wheapsize,

LPSTR LPSZCMDLINE)

{

Return 1;

}

INT _EXPORT_FAR_PASCAL F1 (int X, int y)

{

Int data;

DATA = x * Y;

Return Data;

}

INT FAR PASCAL WEP (Int BsystemExit)

{RETURN 1;

}

* In the module file (DEMO.DEF):

Library Demo

Description 'C XYY DLL for Windows'

EXTYPE WINDOWS

Code Moveable Discardable

Data Moveable SingleHeapsize 0

Exports

F1 @ 1

---- * Use DLL in VB:

---- In the calling of the call, you must speak in the Module module, and the speech form is:

Declare function function

LIB "DLL Name" (Byval parameter as datatype,,)

Declare Function F1 LIB "Demo" (byval x as integer,

BYVAL X AS INTEGER AS INTEGER

---- If you can use the function F1 () in any place.

---- * Use DLLS in Toolbook3.0:

---- In the first first first first connected DLL, and sound the function of the function, the speech form is:

Link DLL "Demo.dll"

Function type function name (parameter type,)

INT F1 (int, int)

END LINKDLL

---- Using the above method, it is easy to develop DLL to expand most of the software of VB4.0, Toolbook3.0, Delphi1.0, so that it is more powerful, such as: implementing control of non-standard hardware, fulfil requirements. In this way, I use the visualization of the new software, and combined with the advantages of the C language, the advantages of the program, and the drops of the software are opened.

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

New Post(0)