I
icuc88
Unregistered / Unconfirmed
GUEST, unregistred user!
一个Clx的程序,其中调用了dll
但是总是qtintf.dll出错:(
说什么read AboutBox->Caption错了:(
...Error reading AboutBox->Caption:Access violation at....in module 'QTINTF.DLL'...
妈的,什么地方错了?
如果我改为Package, Form可以显示,但是UnloadPackage就出问题了:(
各位老大,帮忙看看什么地方出问题了?
//下面是主程序里面的一个声明和调用
//MainForm.h
class TMainF : public TForm
{
...
private: // User declarations
typedef void __declspec(dllimport) TShowMyForm(TApplication *CallApp);
TShowMyForm *_ShowMyForm;
...
}
//MainForm.cpp
void __fastcall TMainF::AboutActExecute(TObject *Sender)
{
const AnsiString ABOUT_DLL = "about.dll";
HINSTANCE Package = LoadLibrary(ABOUT_DLL.c_str());
if (Package)
{
_ShowMyForm = (TShowMyForm *)GetProcAddress(Package, "_ShowAboutForm");
if (_ShowMyForm)
{
_ShowMyForm(Application);
}
else
{
ShowMessage(SysErrorMessage(GetLastError()));
}
FreeLibrary(Package);
}
else
{
ShowMessage(SysErrorMessage(GetLastError()));
ShowMessage("Unable to load the Package.");
}
}
//下面是about.dll
//aboutFrom.h
...
extern "C"
void __declspec(dllexport)ShowAboutForm(TApplication *CallingApp);
...
//aboutForm.cpp
....
void ShowAboutForm(TApplication *CallingApp)
{
Application = CallingApp;
TAboutBox *_AboutBox = new TAboutBox(Application);
try
{
_AboutBox->ShowModal();
}
__finally
{
delete _AboutBox;
}
}
....
但是总是qtintf.dll出错:(
说什么read AboutBox->Caption错了:(
...Error reading AboutBox->Caption:Access violation at....in module 'QTINTF.DLL'...
妈的,什么地方错了?
如果我改为Package, Form可以显示,但是UnloadPackage就出问题了:(
各位老大,帮忙看看什么地方出问题了?
//下面是主程序里面的一个声明和调用
//MainForm.h
class TMainF : public TForm
{
...
private: // User declarations
typedef void __declspec(dllimport) TShowMyForm(TApplication *CallApp);
TShowMyForm *_ShowMyForm;
...
}
//MainForm.cpp
void __fastcall TMainF::AboutActExecute(TObject *Sender)
{
const AnsiString ABOUT_DLL = "about.dll";
HINSTANCE Package = LoadLibrary(ABOUT_DLL.c_str());
if (Package)
{
_ShowMyForm = (TShowMyForm *)GetProcAddress(Package, "_ShowAboutForm");
if (_ShowMyForm)
{
_ShowMyForm(Application);
}
else
{
ShowMessage(SysErrorMessage(GetLastError()));
}
FreeLibrary(Package);
}
else
{
ShowMessage(SysErrorMessage(GetLastError()));
ShowMessage("Unable to load the Package.");
}
}
//下面是about.dll
//aboutFrom.h
...
extern "C"
void __declspec(dllexport)ShowAboutForm(TApplication *CallingApp);
...
//aboutForm.cpp
....
void ShowAboutForm(TApplication *CallingApp)
{
Application = CallingApp;
TAboutBox *_AboutBox = new TAboutBox(Application);
try
{
_AboutBox->ShowModal();
}
__finally
{
delete _AboutBox;
}
}
....