Purpose
DosReplaceModule replaces or caches a module that is in use.
Syntax
#define INCL_DOSMEMMGR #include os2.h>
APIRET APIENTRY DosReplaceModule
Parameters
pszOldModule (PSZ) input
Returns
ulrc (APIRET) returns
DosReplaceModule returns one of the following values
17
Remarks
When a DLL or EXE file is in use by the system, the file is locked. It cannot, therefore, be replaced on the harddisk by a newer copy. DosReplaceModule allows the replacement on the disk of the module while the system continues to run the old module. The contents of the old module file are cached in the swap file by the system and the load module file is closed. A backup copy of the file may be created for recovery purposes should the install program fail. If a backup module is not specified, then no backup will be made. The new module takes the place of the original module on the disk.
Note: The system will continue to use the cached old module until all references to it are released. The next reference to the module will cause a reload from the new module on disk. If a new module is not specified, then the old module file will be cached and the file closed.
Protect mode executable files only can be replaced by DosReplaceModule. It cannot be used for DOS/Windows(R) programs or for data files.
Related Functions
Example Code
int main(int argc, char *argv[], char *envp[]) { APIRET rc=0; PSZ pszOld; PSZ pszNew = NULL; PSZ pszBak = NULL; if (argc==1) { printf("REPMOD oldmod \n"); return rc; } if (argc>1) pszOld = argv[1]; if (argc>2) pszNew = argv[2]; if (argc>3) pszBak = argv[3]; rc = DosReplaceModule(pszOld, pszNew, pszBak); if (rc) printf("DosReplaceModule returned %u\n",rc); else { if (argc==2) printf("%s successfully cached and closed\n", pszOld); else if (argc==3) printf("%s successfully cached and replaced with %s\n", pszOld, pszNew); else if (argc==4) printf("%s successfully copied to %s and replaced with %s\n", pszOld, pszBak, pszNew); } return rc; }