回复:负载库 [英] Re: Loadlibrary
问题描述
大家好, typedef
在我的win32应用程序中,我使用Loadlibrary加载了一个dll.它执行得很好,但是当我使用FreeLibrary()函数卸载该dll时,它会卸载该dll,但是在卸载该dll之后给出类似无法从0x00234fe8读取project.exe中某个位置的位置"的异常.
我认为此异常的原因与dll ao应用程序的属性有关,但我无法找到确切的原因.
任何人都知道为什么发生此异常.
应用程序代码如下:
Hi All, typedef
In my win32 application I loaded a dll using Loadlibrary.
It executes fine but when I unload the dll using FreeLibrary() function it unload the dll but after unloading the dll it gives an exception like "unable to read from 0x00234fe8 something location in project.exe".
I think reson of this exception is related with the properties of our dll ao application, but I unable to find exact reson.
Anyone has an idea why this exception occured.
code of application is given below:
int main()
int main()
{
imortFunction mul;
int结果;
imortFunction mul;
int result;
HINSTANCE hinstLib = LoadLibrary(TEXT " C:\\ new_myproject \\ mydll.dll" )) ;
HINSTANCE hinstLib = LoadLibrary(TEXT"C:\\new_myproject\\mydll.dll"));
if (hinstLib == NULL)
if (hinstLib == NULL)
{
printf( &;错误:无法加载DLL \ n"" );
printf("ERROR: unable to load DLL\n");
返回 1;
return 1;
}
mul =(importFunction)GetProcAddress(hinstLib, "mul" );
mul = (importFunction)GetProcAddress(hinstLib, "mul");
如果 (mul == NULL)
if (mul == NULL)
{
printf( "错误:无法找到DLL函数\ n" );
printf("ERROR: unable to find DLL function\n");
FreeLibrary(hinstLib);
FreeLibrary(hinstLib);
返回 1;
return 1;
}
//调用函数.
// Call function.
result = mul(1,2);
result = mul(1, 2);
//卸载DLL文件
// Unload DLL file
FreeLibrary(hinstLib);
FreeLibrary(hinstLib);
printf( "结果是:%d \ n" ,结果); //此处发生异常
printf("The result is: %d\n", result); // exception occured here
返回 0;
return 0;
}
在上一个printf()中,它给出了异常.任何人都知道发生此异常的原因.是否需要在dll或应用程序中设置任何属性? br>
请先谢谢.
}
In last printf() it gives exception.Anyone has an idea why this exception occured.Is there any property which I need to set in dll or application?
Thanks in advance.
推荐答案
我会冒险猜测堆栈损坏.您如何从DLL导出功能?
I would hazard a guess at stack corruption. How are you exporting the function from the DLL?
这篇关于回复:负载库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!