具体创建如何创建def类型的导出表可以直接自己测试
这里只贴 使用的代码
// 20171111_01.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
#pragma comment(lib,"TestDef.lib")
/*
extern "C" __declspec(dllimport) __stdcall Plus(int x,int y);
extern "C" __declspec(dllimport) __stdcall Sub(int x,int y);
extern "C" __declspec(dllimport) __stdcall Mul(int x,int y);
extern "C" __declspec(dllimport) __stdcall Div(int x,int y);
*/
/*
typedef int (__stdcall *lpPlus) (int x,int y);
typedef int (__stdcall *lpSub) (int x,int y);
typedef int (__stdcall *lpMul) (int x,int y);
typedef int (__stdcall *lpDiv) (int x,int y);
*/
typedef int ( *lpPlus) (int x,int y);
typedef int ( *lpSub) (int x,int y);
typedef int ( *lpMul) (int x,int y);
typedef int ( *lpDiv) (int x,int y);
int main(int argc, char* argv[])
{
lpPlus myPlus;
lpSub mySub;
lpMul myMul;
lpDiv myDiv;
HINSTANCE hModule = LoadLibrary("TestDef.dll");
/*
myPlus = (lpPlus)GetProcAddress(hModule,"_Plus@8");
mySub = (lpSub)GetProcAddress(hModule,"_Sub@8");
myMul = (lpPlus)GetProcAddress(hModule,"_Mul@8");
myDiv = (lpDiv)GetProcAddress(hModule,"_Div@8");
*/
myPlus = (lpPlus)GetProcAddress(hModule,MAKEINTRESOURCE(12));
mySub = (lpPlus)GetProcAddress(hModule,MAKEINTRESOURCE(15));
myMul = (lpPlus)GetProcAddress(hModule,MAKEINTRESOURCE(13));
myDiv = (lpPlus)GetProcAddress(hModule,MAKEINTRESOURCE(16));
//printf("hModule: %x \n",hModule);
int x= myPlus(101,11);
int y = mySub(101,1);
int k = myMul(10,20);
int z= myDiv(22,11);
printf("myPlus: %d \n",x);
printf("mySub: %d \n",y);
printf("myMul: %d \n",k);
printf("myDiv: %d \n",z);
getchar();
return 0;
}
myDiv = (lpPlus)GetProcAddress(hModule,MAKEINTRESOURCE(16));