// DllCnsTest.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <windows.h>
#include "DllCnsTest.h"

typedef int(*lpFunc)(int a,int b); //此语句可以放在.h文件中

int _tmain(int argc, _TCHAR* argv[])
{
    HINSTANCE hDll; //声明一个Dll实例文件句柄 
    hDll = LoadLibrary(_T("DllDemo2.dll"));//导入DllDemo.dll动态连接库

    lpFunc MaxFunc, AddFunc; 
    MaxFunc = (lpFunc)GetProcAddress(hDll, "Max"); 
    AddFunc = (lpFunc)GetProcAddress(hDll, "Add");
    if( MaxFunc != NULL )
    {
        int value; 
        value = MaxFunc(2,9); 
        printf("The Max value is %d\n",value);
    }
    if( AddFunc != NULL )
    {
        int value;
        value = AddFunc(2,9);
        printf("The Add result is %d\n", value);
    }
    FreeLibrary(hDll);

    int value; 
    value = Max(2,9); 
    printf("隐式调用The Max value is %d\n",value); 

	return 0;
}

