分类: C/C++
2008-06-14 15:18:42
int DoCase(int, long);
则,在调用动态库是有两种方法:
1. 先声明一个与动态库中类型一致的指针函数变量:
int (*DOCASE)(int ,long);//用于指向动态库中的DoCase函数地址
HINSTANCE gLibMyDLL = NULL;
gLibMyDLL = LoadLibrary("test.dll");
if(gLibMyDLL != NULL)
{
//得到函数地址
DOCASE = (int(*)(int,long))GetProcAddress(gLibMyDLL, "DoCase");
}
//调用函数
int s = DOCASE(1,1000);
2.用typedef定义一个指针函数:typedef (*DOCASE)(int ,long);
HINSTANCE gLibMyDLL = NULL;
DOCASE _docase;
gLibMyDLL = LoadLibrary("test.dll");
if(gLibMyDLL != NULL)
{
_docase = (DOCASE)GetProcAddress(gLibMyDll, "DoCase");
}
//调用函数
int s=_docase(1,1000);