用VC++6.0打开你的C语言程序,在你的C语言程序中加两个文件用来调DLL,CallDll.h,CallDll.cpp;把对Dll的调用放到CallDll中去,如调用Dll中的int Add(int, int)在 CallDll.h中声明 #ifdef __cplusplusextern "C"{#endif int CallAdd(int, int);#ifde 展开
用VC++6.0打开你的C语言程序,在你的C语言程序中加两个文件用来调DLL,CallDll.h,CallDll.cpp;把对Dll的调用放到CallDll中去,如调用Dll中的int Add(int, int)在 CallDll.h中声明 #ifdef __cplusplusextern "C"{#endif int CallAdd(int, int);#ifdef __cplusplus}#endif在CallDll.cpp中实现#include <windows.h>#include "TestCall.h"int CallAdd(int x, int y) { HINSTANCE hIns = NULL;//加载DLL hIns = LoadLibrary( (LPCTSTR)("Dll名称") );typedef int (*pFun)(int, int);pFun pFunPtr = (pFun)GetProcAddress( (HMODULE)hIns, "?add@@YAHHH@Z");//Dll中Add函数的真正名字,C++中会//自动改名 可以用depend查看Dll if( NULL != pFunPtr) return (*pFunPtr)(x,y);return 0;}然后在你的C程序中调用CallAdd就可以间接调用Add了,如果你要定义Dll中的类变量的话,就在CallDll.cpp中建一个函数,传出一个类变量的指针 收起