|
动态库代码:
extern "C" __declspec(dllexport) HWND __stdcall CreateCW(HWND);
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
HWND __stdcall CreateCW(HWND MainWindowHandle)
{
Application->Handle = MainWindowHandle;
Form2 = new TForm2(NULL);
SetParent(Form2->Handle,MainWindowHandle);
Form2->ShowModal();
return Form2->Handle;
}
调用代码:
HINSTANCE hInstance;
__showWindow show;
if(hInstance == NULL)
{
hInstance = LoadLibrary( "Project2.dll" );
}
if(hInstance != NULL)
{
MessageBox(NULL, "BEGIN", "",0);
show = (__showWindow)GetProcAddress(hInstance, "CreateCW");
if(NULL != show )
{
hCwnd = show(Form1->Handle );
}
else
{
MessageBox(NULL , "HANSHUJIAZAISHIBAI ","", 0);
}
}
else
{
MessageBox(NULL, "动态库加载失败","", 0);
}
|
|