dll文件的制做与调用

http://blog.csdn.net/testcs_dn/article/details/27237509           -dll文件制做函数

http://blog.csdn.net/very_2/article/details/6534915                  -dll文件调用.net

// SimpleDLLTest.cpp : 定义控制台应用程序的入口点。  
  
#include "stdafx.h"  
#include <stdio.h>
#include <Windows.h>
#include <tchar.h>

  
int _tmain(int argc, _TCHAR* argv[])  
{  
      HMODULE hModule = NULL;
      typedef int (*Func)(int a, int b);
 
      // 动态加载 DLL 文件
      hModule = LoadLibrary(_TEXT("e:/SimpleDLL.dll" ));    dll文件存放的路径
 
      // 获取 add 函数地址
      Func fAdd = (Func)GetProcAddress(hModule, "add" );
 
      // 使用函数指针
      printf("%d\n" , fAdd(8, 20));
 
      // 最后记得要释放指针
      FreeLibrary(hModule);
      
	  system("pause");
      return 0;
}
相关文章
相关标签/搜索