Library
新建 Library
新建Cpp File
File1.cpp
extern "C" __declspec(dllexport) int add(int a,int b)
{return a+b;}
Build
Project->Build Project1
使用
新建项目
Add New Project
Unit1.cpp
#pragma hdrstop#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#pragma comment(lib, "Project1.lib")//链接lib
extern "C" __declspec(dllimport) int add(int a,int b);//引入涵娄
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner)
{int c=add(10,20);//使用函数ShowMessage(IntToStr(c));
}
//---------------------------------------------------------------------------
说明:vcl编写的dll的调用也类似