跟 VC 好象没有什么很大区别呀!
我使用的是 BCB3.0,调试通过以下程序:
在 Exe 中加入 Dll 用 implib 生成的 lib 文件
//DllProject.cpp
#include <vcl.h>
#pragma hdrstop
#include "fsDllForm.h" //这个是打开一个空的窗口
USEFORM("fsDllForm.cpp", DllForm);
//---------------------------------------------------------------------------
class __declspec(dllexport) __stdcall RetDllClass
{
public:
RetDllClass();
void CreateAForm();
TDllForm *DllForm;
} ;
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
return 1;
}
//---------------------------------------------------------------------------
RetDllClass::RetDllClass()
{
}
//---------------------------------------------------------------------------
void RetDllClass::CreateAForm()
{
DllForm = new TDllForm(Application);
DllForm->Show();
}
//---------------------------------------------------------------------------
//Exe.h
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "fsDllForm.h"
//---------------------------------------------------------------------------
__declspec(dllexport) class __stdcall RetDllClass
{
public:
RetDllClass();
void CreateAForm();
TDllForm *DllForm;
};
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
RetDllClass *RetDll ;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
//ExeMainForm.cpp
void __fastcall TForm1::Button1Click(TObject *Sender)
{
RetDll = new RetDllClass();
RetDll->CreateAForm();
}
//---------------------------------------------------------------------------