Create and Call DLL files

Source: Internet
Author: User

1. dll Concept

The dynamic link library (DLL) is short for dynamic link library. dll is a library that contains code and data that can be used by multiple programs at the same time. dll is not an executable file. Dynamic links provide a way for a process to call a function that does not belong to its executable code. The executable code of a function is located in a DLL, which contains one or more functions that have been compiled, linked, and stored separately from the processes that use them. DLL also helps to share data and resources. Multiple applications can simultaneously access the content of a single DLL copy in the memory. DLL is a library that contains code and data that can be used by multiple programs at the same time.

2. dll advantages

A. extends the features of applications;

B. It can be written in many programming languages;

C. simplified the management of software projects;

D. It helps to save memory;

E. Facilitates resource sharing;

F. Facilitates application localization;

G. helps resolve platform differences;

H. It can be used for some special purposes. Windows allows some features to be used only by DLL.

3. Create DLL

Create a DLL project,

Add the tested helloworld function to the Project

Extern "C" _ declspec (dllexport) bool helloworld () <br/>{< br/> MessageBox (null, _ T ("This Is The dll library interface"), null, 0); <br/> return true; <br/>}

After compilation, the DLL. lib and DLL. DLL files are generated.

4. dll call Method

Create an MFC project and add the test button on the interface. Before calling the API, you must declare the name of the referenced External Database and the external function interface. The description and specific implementation Code are as follows:

# Pragma comment (Lib, "DLL. lib ") // reference External library <br/> extern" C "_ declspec (dllimport) bool helloworld (); // declare the call interface <br/> void cdllmfcdlg :: onbnclickedbutton1 () <br/>{< br/> helloworld (); <br/>}< br/>

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.