求在动态链接库中控件事件的动态加载方法。
/////////dll 文件。///////////
#include <vcl.h>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.ComCtrls.hpp>
#include <IdCustomTCPServer.hpp>
#include <IdTCPServer.hpp>
#include <IdSocks.hpp>
#include <IdSchedulerOfThreadPool.hpp>
#pragma hdrstop
extern "C" __declspec(dllexport) void __stdcall CatchScreenInition(UnicodeString ,UnicodeString);
extern "C" __declspec(dllexport) void __stdcall CatchScreenDestroy(void);
#pragma argsused
TIdTCPServer *cScreen;
TIdSchedulerOfThreadPool *sThreadPool;
typedef void __stdcall CatchScreenExecute(TIdContext *AContext);
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//----------------------------------------
void __stdcall CatchScreenDestroy(void)
{
delete sThreadPool;
delete cScreen;
}
//----------------------------------------
void __stdcall CatchScreenInition(UnicodeString srvport,UnicodeString srvip)
{
cScreen =new TIdTCPServer(NULL);
sThreadPool=new TIdSchedulerOfThreadPool(NULL);
cScreen->Scheduler= sThreadPool;
cScreen->TerminateWaitTime=5000;
cScreen->MaxConnections=1000;
sThreadPool->MaxThreads=5000;
cScreen->Bindings->Clear();
cScreen->Bindings->Add()->IP=srvip;
cScreen->Bindings->Add()->Port = StrToInt(srvport);
cScreen->OnExecute=CatchScreenExecute;//这里是错误。
cScreen->Active=true;
}
//---------------------------------------
void __stdcall CatchScreenExecute(TIdContext *AContext)
{
}