--------------------------- Error --------------------------- Not found the kernel library or the kernel library is invalid or the kernel library of this edition does not support DLL! --------------------------- 确定 --------------------------- 现在函数找到了 但是调用函数的时候 提示这个 为什么呢
int *fun;
h = LoadLibrary("ycode.dll");
if(h!=NULL)
{
fun =(int *)GetProcAddress(h,"loadcode");
}找到这么一个代码 头一行 h 就为空
{
// TODO: Add your control notification handler code here
// 动态加载的方法:
// 不需要引入头文件与lib文件,仅需要一个dll即可
// 注意这里的条约调用约定_stdcall不要忘记加(不然会引会esp出错)
typedef int (_stdcall *ADDPROC)(int,int);
typedef int (_stdcall *SUBPROC)(int,int);
HINSTANCE handle;
handle = LoadLibrary("MyDll.dll");
if(handle)
{
// GetProcAddress第二个参数有两种方法:
// 1、通过DLL中的函数名
// 2、通过Depend工具中Ordinal索引值来查看
ADDPROC MyAdd = (ADDPROC)GetProcAddress(handle,"Add");
SUBPROC MySub = (ADDPROC)GetProcAddress(handle,MAKEINTRESOURCE(2));
if( !MyAdd )
{
MessageBox("函数Add地址获取失败!");
return;
}
if( !MySub )
{
MessageBox("函数Sub地址获取失败!");
return;
}
CString str;
str.Format("动态加载: 1+1=%d 1-1=%d",MyAdd(1,1),MySub(1,1));
MessageBox(str);
}
FreeLibrary(handle);
}
如果LoadLibrary()失败,
就使用GetLastError()看看错误是什么 ……
Error
---------------------------
Not found the kernel library or the kernel library is invalid or the kernel library of this edition does not support DLL!
---------------------------
确定
---------------------------
现在函数找到了 但是调用函数的时候 提示这个 为什么呢
wchar_t *wchDllFile = L"需要调用的DLL文件名.DLL";
char *chProcName = "需要调用的函数名";
#pragma const_seg()然后调用函数:HINSTANCE hDllInstance = ::LoadLibrary( wchDllFile );
FARPROC hProc = ::GetProcAddress( hDllInstance, chProcName );然后就可以使用你的函数了,比如:hProc( Param1, Param2 );