DosReplaceModule replaces an active DLL or EXE by caching the contents of the old module and then copying a new file over the old module's file.
#include <os2.h>
ULONG pszOldModule;
ULONG pszNewModule;
ULONG pszBackupModule;
APIRET rc;
rc = DosReplaceModule(pszOldModule, pszNewModule,
pszBackupModule);