O
oldwolf201
Unregistered / Unconfirmed
GUEST, unregistred user!
我现在想在C++BUILDER下调用VC++写的带界面的DLL。
调用部分程序如下:
TForm1 *Form1;
typedef bool (__stdcall *_netpower)();
typedef int (__stdcall *_maxvalue)(int val);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HINSTANCE hDLL;
_netpower netpower;
// SetResourceHandle(theApp.m_hInstance);
hDLL = LoadLibrary("testdll.dll");
netpower = (_netpower)GetProcAddress(hDLL, "netpower");
netpower();
FreeLibrary(hDLL);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
HINSTANCE hDLL;
_maxvalue maxvalue;
hDLL = LoadLibrary("testdll.dll");
maxvalue = (_maxvalue)GetProcAddress(hDLL, "maxvalue");
int j=maxvalue(1);
ShowMessage(IntToStr(j));
FreeLibrary(hDLL);
}
VC++中NETPOWER和MAXCALUE这两个导出函数实现部分如下:
extern "C" _declspec(dllexport) bool netpower()
{ AfxSetResourceHandle(theApp.m_hInstance);
CTD a;
a.DoModal();
return TRUE;
}
extern "C" _declspec(dllexport) int maxvalue(int val)
{
val=val+2;
return val;
}
其中CTD是一个界面类,目的就是调用DLL,显示此界面。
程序编译通过,测试时,能成功调用简单函数maxvalue但调用显示界面函数NETPOWER失败!
请问该如何修改?
是VC++部分有问题还是C++BUILDER调用部分出错?
调用部分程序如下:
TForm1 *Form1;
typedef bool (__stdcall *_netpower)();
typedef int (__stdcall *_maxvalue)(int val);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HINSTANCE hDLL;
_netpower netpower;
// SetResourceHandle(theApp.m_hInstance);
hDLL = LoadLibrary("testdll.dll");
netpower = (_netpower)GetProcAddress(hDLL, "netpower");
netpower();
FreeLibrary(hDLL);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
HINSTANCE hDLL;
_maxvalue maxvalue;
hDLL = LoadLibrary("testdll.dll");
maxvalue = (_maxvalue)GetProcAddress(hDLL, "maxvalue");
int j=maxvalue(1);
ShowMessage(IntToStr(j));
FreeLibrary(hDLL);
}
VC++中NETPOWER和MAXCALUE这两个导出函数实现部分如下:
extern "C" _declspec(dllexport) bool netpower()
{ AfxSetResourceHandle(theApp.m_hInstance);
CTD a;
a.DoModal();
return TRUE;
}
extern "C" _declspec(dllexport) int maxvalue(int val)
{
val=val+2;
return val;
}
其中CTD是一个界面类,目的就是调用DLL,显示此界面。
程序编译通过,测试时,能成功调用简单函数maxvalue但调用显示界面函数NETPOWER失败!
请问该如何修改?
是VC++部分有问题还是C++BUILDER调用部分出错?