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:

Read Also:  Gadget Ogling A Mighty Little Amp a Credit Card-Sized Phone and a Food Tray Keyboard

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.

Leave a Reply

Your email address will not be published. Required fields are marked *