DLL files created in VC step Mac

The method steps to create a DLL file in VC Mac Source: Published :2007-11-17 Views: of 2862 passengers Font: [medium and small]
Teach you to create a DLL file in VC steps together to learn about, is not very difficult, I believe you will see.
Win32 dynamic link library

Production steps:

(1) the new WIN32 Dynamic-Link Library project, the project called MyDll select A simple DLL project type.

(2) The MyDll.h the contents are as follows:

The following is quoted fragment:
extern “C” _declspec (dllexport) int sum (int a, int b) ;/ / all of the examples of this article is only a sum that the addition function.

(3) MyDll.cpp the contents are as follows:

The following is quoted fragment:
# Include “stdafx.h”
# Include “windows.h”
# Include “MyDll.h
BOOL APIENTRY DllMain (
HANDLE hModule,
DWORD ul_reason_for_call
LPVOID lpReserved
)
{
return TRUE;
}
extern “C” _declspec (dllexport) int sum (int a, int b)
{
return a + b;
}

(4) After compiling the two files MyDll.lib MyDll.dll.

2 How to use:

(1) implicitly calls the method: the MyDll.lib and MyDll.h copied to the need to apply the DLL project directory, the the copy MyDll.dll to the application’s directory, and require the application of the DLL the function of the CPP file add the following lines:

The following is quoted fragment:
# Include “MyDll.h
# Pragma comment (lib, “MyDll”);

(2) display the calling method: the MyDll.lib and MyDll.h copy to require the application of the DLL project directory, MyDll.dll copied to the application’s directory, and require the application of the DLL function of the CPP file contains header files, such as:

The following is quoted fragment:
# Include “MyDll.h

Also need to increase MyDll.lib this library in Project-> Setting-> Link-> Object / library modules box.

MFC dynamic link library

Production steps:

(1) new MFC AppWizard (dll) project, the works entitled MFCDll select the Regular DLL to the using shared MFC DLL type.

(2) behind the generated MFCDll.cpp file, add the following lines:

The following is quoted fragment:
int sum (int a, int b)
{
return a + b;
}

(3) behind generated MFCDll.def file, add the following:

The following is quoted fragment:
sum @ 1; said first function is a sum

(4) the compiler will generate two files MFCDll.lib, MFCDll.dll

2. Use

(1) implicitly calls: MFCDll.lib copied to the need to apply the DLL project directory, the the copy MyDll.dll to the application’s directory, and require the application of the function in the DLL CPP file Add the following lines:

/ / Note that there is no statement in MFCDll.h function, so can not directly contain MFCDll.h to declare the function.

The following is quoted fragment:
# Pragma comment (lib, “MFCDll”);
int sum (int a, int b);

/ / Of course, if your DLL has many functions, it can also write a MFCDll.h contains all the function declarations, and then directly to the header files included into

(2) to call method: Win32 call, do not need to # pragma comment (lib, “MFCDll”);, but needs to be increased in the Project-> Setting-> Link-> Object / library modules box MFCDll. lib library.

Read More Post

STAY CONNECTED

Most Popular

Why Serviced Apartments Are the Perfect Choice for Long-Term Stays in Singapore – Everything You Need to Know
17 Dec

Why Serviced Apartments Are the Perfect Choice for Long-Term Stays in Singapore – Everything You Need to Know

If you’re heading to Singapore for a few weeks or many months, maybe for work or study or just to

Manifesting Your Dream Career: Finding Your Passion And Purpose
01 Aug

Manifesting Your Dream Career: Finding Your Passion And Purpose

Are you passionate about finding your dream career? Manifesting can help you align your career with your passions and purpose.

Revolutionizing Your Ride: Expert Auto Service At Carolina Auto Service
27 Feb

Revolutionizing Your Ride: Expert Auto Service At Carolina Auto Service

Finding a reliable auto service provider is paramount in the bustling world of vehicle maintenance and repair. That's where Carolina

Floratam: The Robust Grass Solution From Council Growers SOD
25 Jan

Floratam: The Robust Grass Solution From Council Growers SOD

Floratam grass, a popular St. Augustine variety, has become a go-to choice for homeowners and landscapers seeking a lush, durable

Carolina Mobile Autoservice: Your Go-To For Expert Brake Service Repair
25 Jan

Carolina Mobile Autoservice: Your Go-To For Expert Brake Service Repair

For vehicle owners, the braking system is among the most critical components for safety and performance. Carolina Mobile Autoservice, a

Safeguarding Your Property: Expert Water Damage Services By MBC Capital
24 Jan

Safeguarding Your Property: Expert Water Damage Services By MBC Capital

Water damage can significantly impact homes and businesses, often leaving a trail of destruction and disruption in its wake. Understanding