|
Dynamic library code:
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;
}
Calling code:
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, "Dynamic library loading failed", "", 0);
} |
|