1,222
社区成员




//---------------------------------------------------------------------------
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#include "Unit2.h" //手动添加窗体TForm2
//---------------------------------------------------------------------------
// 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
//---------------------------------------------------------------------------
#pragma argsused
TForm2* For ;
extern "C" _declspec(dllexport) void __stdcall ShowForm();
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
void __stdcall ShowForm()
{
For = new TForm2(NULL);
For->Show();
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("Project2.dll", EntryPoint = "ShowForm")]
static extern void ShowForm();
/*
解决方案资源管理器”里,
右键项目名的属性。
“生成”——“目标平台”
下拉里选中“X86";即可
*/
private void button1_Click(object sender, EventArgs e)
{
ShowForm();
}
}