//// test_调用dll测试.cpp : 定义控制台应用程序的入口点。
////
//
#include "stdafx.h"
//
#include <stdio.h>
#include <Windows.h>
typedef int(*dllfun)(int,int); //定义形式对应的函数指针类型
int main()
{
int a = 2;
int c=5;
dllfun adde; //声明一个函数指针
HINSTANCE hdll;
hdll = LoadLibrary("d:\\mydll01.dll");
if(hdll == NULL)
{
printf("无法载入dll\n");
FreeLibrary(hdll);
getchar();
return 0;
}
//typedef int (*funcSum)(int,int); // 定义函数指针
//typedef int (*funcSum)(int,int); // 定义函数指针
adde = (dllfun)GetProcAddress(hdll,"adde");
if(adde == NULL)
{
printf("无法获取函数地址\n");
FreeLibrary(hdll);
getchar();
return 0;
}
int b = adde(a,c);
printf("%d\n",b);
FreeLibrary(hdll);
getchar();
return 1;
}