NextArticleI reprinted it from other places. I thought it was better after reading it. So I made a reshipment, So we studied it together. To respect others' intellectual property rights, please declare it in advance!
What is DLL?
DLL (Dynamic Connection Library), since it is dynamic, there is a static Connection Library, I think if you say so, you will better understand:
Some may have written it in DOSProgramI have written a program that provides the function of turning the screen content to 90 ° for printing. Then I need to write the entire program.
To all of myCodeBut if I write another program that has the same function, I can
Call the previous program function? Of course this is not acceptable, so I will write it again, as shown in
If there are 5 programs that need to call this function, and my function needs 20 K, then my
The hard disk has 80 K junk data (20 K * 5-20 k). This is just a function. Can you count
In Windows, how many functions do I need to write? You can see all the buttons, scroll bars,
ListBox \ textbox \ checkbox \ form, Print dialog box, color dialog box, open, save, and save
, Font dialog box, file arrangement, copy, paste... all of this is not in
What do some programs need to write? If this is the case, we should press TB for Windows.
Computing (1 TB = 1024 GB), maybe you say your hard disk is very large, so they still occupy
Use the same big content! As a result, the concept of dynamic connection library (DLL) is as follows:
Dynamic connection refers to placing these interconnected functions and functions in a special form of windwos executable file.
When a DLL is generated, the programmer needs to write it, including the functions that need to be written
Program to access. This process is called "exporting" the function"
When creating a Windows program, a dedicated Connection Program scans the program's object files and generates
List of called functions at the location of the DLL and the process of specifying the location of each function
It is called the "import" of the function. When the program runs, once the execution file is required
Function, Windows automatically loads the dynamic connection library so that the application can access these functions. At this time,
The address of each function is parsed and dynamically connected to the program-this is the term
The Origin of "dynamic connection.
Another benefit is that when you update the version and function of your function, the static connection
The amount of work required (assuming that windwos has thousands of such functions, a total of 100
If multiple programs are used, the static connection needs to be updated 100000 times, and the dynamic connection only needs 1000 times)
, Thus saving the memory space.
Dynamic connection libraries are not necessarily DLL extensions, but can also be ocx, vbx, EXE, DRV, etc.
You can find that when calling the Win32 API, it will indicate that it comes from the DLL and other host files.
Parts
Now I will talk about some standard DLL usage:
See the following API declaration:
Public declare function getwindowsdirectory lib "Kernel32" alias
"Getwindowsdirectorya" (byval lpbuffer as string, byval nsize as long)
As long
Have you seen Kernel32? In fact, this is the name of kernel32.dll. You can find it on your hard disk.
To him, this means that the getwindowsdirectory function is in kernel32.dll, his alias
Is getwindowsdirectorya, () is his parameter, there are two is character type, one is long
The return value is also a long integer. Lpbuffer ------- string, specifying a string buffer,
Used to load the Windows directory name. Unless it is the root directory, there will not be a "\"
Character nsize ---------- long, maximum length of the lpbuffer string, return value is long, copy
The length of a string to lpbuffer. If lpbuffer is not large enough to accommodate the entire string, it will return
The length required by lpbuffer. Zero indicates failure.
This is what the API declaration means!
DLL description
Kernel32.dll ---- low-level kernel functions. It can be used to complete memory management, task management,
Resource control.
User32.dll ------ functions related to Windows Management. Message, menu, cursor, Timer
Communication and most other non-realistic functions can be found here
Gdi32.dll ------- graphic device interface library. Functions related to device output: Most plotting
You can find the display scenario, metadata file, coordinates, and font functions from here.
Comdlg32.dll \ lz32.dll \ version. dll \ --- these are libraries that provide some additional functions.
Including general dialog box, File compression, and version control.
Comctl32.dll -------- a new set of Windows controls, such as Treeview and RichTextBox
And so on. At first it seems to have been made for Win95, but now it is also used with NT
Mapi32.dll --------- provides a set of email-specific functions.
Netapi32.dll -------- provides a set of network access and control functions.
Odbc32.dll -------- (no more) One of the ODBC function DLL
Winmm. dll ------ (this is not Windows mm) is a set of multimedia access control functions
Windows API is developing and changing rapidly. It is a fast development that you and I cannot catch up with. Fortunately
We do not need to know all windows APIs, but the Windows APIs that need to be used frequently.
And his regular structure and basic feelings, which are important.
For Win32 APIs, see what is Win32 API
These two articles were specially sent to beijingfish and some netizens who are new to Windows programming. They were made overnight and lost!