在DLL里使用多线程的问题?????
Artas 2003-11-10 04:27:26 我的程序要调用我自己写的一个DLL,在这个DLL里再使用线程处理一些数据,有关DLL(包括多线程的代码)都在DLL.CPP文件里,代码如下:
//---------------------------------------------------------------------------
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
//---------------------------------------------------------------------------
// Important note about DLL memory management when your DLL uses the
// static version of the RunTime Library:
//
// If your DLL exports any functions that pass String objects (or structs/
// classes containing nested Strings) as parameter or function results,
// you will need to add the library MEMMGR.LIB to both the DLL project and
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
// if any other projects which use the DLL will be performing new or delete
// operations on any non-TObject-derived classes which are exported from the
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
// the file BORLNDMM.DLL should be deployed along with your DLL.
//
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
// ShortString parameters.
//
// If your DLL uses the dynamic version of the RTL, you do not need to
// explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------
class TMyThread : public TThread
{
private:
void __fastcall Execute(void);
public:
__fastcall TMyThread(void);
};
void __fastcall ThreadDone(TObject *Sender);// 线程结束时执行的函数
//-----------------------------------------------------------------------
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//-----------------------------------------------------------------------
__fastcall TMyThread::TMyThread()
: TThread(false)
{
}
//-----------------------------------------------------------------------
void __fastcall TMyThread::Execute()
{
ShowMessage("Execute");
}
//-----------------------------------------------------------------------
void __fastcall ThreadDone(TObject *Sender)
{
ShowMessage("ThreadDone");
}
//-----------------------------------------------------------------------
extern "C" __declspec(dllexport) void __stdcall Test()
{
TMyThread *MyThread = new TMyThread;
MyThread->OnTerminate = ThreadDone;
}
//-----------------------------------------------------------------------
一编译就是显示如下错误:
[C++ Error] Unit1.cpp(66): E2034 Cannot convert 'void (_fastcall *)(TObject *)' to 'void (_fastcall * (_closure )(TObject *))(TObject *)'
不知道怎么改??????????????????????