求救!关于在dll中使用非基本控件报错的奇怪问题,问题比较棘手,请各位多帮忙.
纪俊 2005-04-11 09:33:10 下面是dll主文件代码,功能是实现一个插件式的模块
typedef struct PlugInModule{
AnsiString ver ;
AnsiString author ;
AnsiString menuMain;
AnsiString menuChild;
AnsiString description;
} PlugInModule ;
extern "C" __declspec(dllexport) PlugInModule __stdcall getModuleInfo();
extern "C" __declspec(dllexport) bool __stdcall executeModule();
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
extern "C" __declspec(dllexport) PlugInModule __stdcall getModuleInfo()
{
PlugInModule modelInfo;
modelInfo.ver="1.00";
modelInfo.author="jj";
modelInfo.menuMain="Admin";
modelInfo.menuChild="Admin Database";
modelInfo.description="Admin Database Module";
return modelInfo;
}
//---------------------------------------------------------------------------
extern "C" __declspec(dllexport) bool __stdcall executeModule()
{
MessageBox(0,"^_^","Dll Respond here:",0);
Form1 = new TForm1(NULL);
Form1->ShowModal();//调用Form1
delete Form1;
return 1;
}
此dll被主执行文件动态调用(用LoadLibrary与GetProcAddress得到getModuleInfo()与executeModule()并执行)
在dll中有一Form1,当Form1中只使用按钮、ListBox等基本控件的时候没有问题,但是当在Form1中使用ADO、以及一些其他非基本控件的时候此dll就无法正常调用。
最奇怪的是:getModuleInfo()函数(通过第一次LoadLibrary与GetProcAddress得到)在任何情况下都是好用的,而executeModule()函数(通过第二次LoadLibrary与GetProcAddress得到,错误说****内存不可写)则在后一种情况下出错,但出错点不是Form1->ShowModal()处而是开始第一句都不能执行
请各位大侠救命...