MDIChild into a DLL

I need to put a MDI Child into a DLL. The EXE, if needed, will call
the dll and the MDI Child will be created.

I read that the EXE needs to pass the Application and Screen to the DLL. The
DLL must save it in the Initialization section and set it back in the
Finalization.

I tried this but I receive an Access Violation (error 216).

How can I do it? I agree a few example of code.

Thanks.