Jump to content

DosFreeModule (OS/2 1.x): Difference between revisions

From EDM2
No edit summary
Ak120 (talk | contribs)
mNo edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[image:legacy.png]]
This call frees the reference to a dynamic link module for a process. When the dynamic link module is no longer needed by any process, the module is freed from system memory.


==Description==
This call frees the reference to a dynamic link module for a process. When the dynamic link module is no longer needed by any process, the module is freed from system memory.
==Syntax==
==Syntax==
<PRE>
  DosFreeModule (ModuleHandle)
  DosFreeModule


    (ModuleHandle)
</PRE>
==Parameters==
==Parameters==
; ModuleHandle (HMODULE) - input : Handle returned by DosLoadModule.
;ModuleHandle (HMODULE) - input : Handle returned by DosLoadModule.
 
==Return Code==
==Return Code==
rc (USHORT) - return
;rc (USHORT) - return:Return code descriptions are:
 
*0 NO_ERROR
Return code descriptions are:
*6 ERROR_INVALID_HANDLE
 
*12 ERROR_INVALID_ACCESS
* 0   NO_ERROR  
*95 ERROR_INTERRUPT
* 6       ERROR_INVALID_HANDLE  
* 12       ERROR_INVALID_ACCESS  
* 95       ERROR_INTERRUPT


==Remarks==
==Remarks==
The module identified by the handle must be loaded through DosLoadModule. An error is returned if the handle is invalid.
The module identified by the handle must be loaded through [[DosLoadModule (OS/2 1.x)|DosLoadModule]]. An error is returned if the handle is invalid.


If any exit list routines were registered as a result of this module being loaded, the module may not be freed and ERROR_INVALID_ACCESS may be returned.
If any exit list routines were registered as a result of this module being loaded, the module may not be freed and ERROR_INVALID_ACCESS may be returned.


When DosFreeModule returns to the caller, the module handle is no longer valid and is not used to reference the dynamic link module. Procedure entry addresses returned for this module are no longer valid and cause a protection fault if they are invoked.  
When DosFreeModule returns to the caller, the module handle is no longer valid and is not used to reference the dynamic link module. Procedure entry addresses returned for this module are no longer valid and cause a protection fault if they are invoked.
==Example Code==
 
=== C Binding===
==Bindings==
===C===
<PRE>
<PRE>
#define INCL_DOSMODULEMGR
#define INCL_DOSMODULEMGR


USHORT  rc = DosFreeModule(ModuleHandle);
USHORT  rc = DosFreeModule(ModuleHandle);
HMODULE ModuleHandle;  /* Module handle */
USHORT  rc;            /* return code */
</PRE>
===MASM===
<PRE>
EXTRN  DosFreeModule:FAR
INCL_DOSMODULEMGR  EQU 1


HMODULE          ModuleHandle; /* Module handle */
PUSH  WORD    ModuleHandle ;Module handle
CALL  DosFreeModule


USHORT          rc;            /* return code */
Returns WORD
</PRE>
</PRE>
This example tries to load module ABCD. The system searches LIBPATH. If unsuccessful, the system tries to to load the module from the program's directory (in case the user forgot to update LIBPATH).
 
==Example==
This example tries to load module ABCD. The system searches LIBPATH. If unsuccessful, the system tries to load the module from the program's directory (in case the user forgot to update LIBPATH).
<PRE>
<PRE>
#define INCL_DOSMODULEMGR
#define INCL_DOSMODULEMGR
Line 49: Line 55:
USHORT  rc;
USHORT  rc;


   if (DosLoadModule(LoadError,               /* Object name buffer */
   if (DosLoadModule(LoadError,             /* Object name buffer */
                     sizeof(LoadError),       /* Length of object name
                     sizeof(LoadError),     /* Length of object name buffer */
                                                  buffer */
                     MODULE_NAME,           /* Module name string */
                     MODULE_NAME,             /* Module name string */
                     &ModuleHandle) == 2)   /* Module handle */
                     &ModuleHandle) == 2)     /* Module handle */
       rc = DosLoadModule(LoadError,         /* Object name buffer */
       rc = DosLoadModule(LoadError,           /* Object name buffer */
                         sizeof(LoadError), /* Length of object name buffer */
                         sizeof(LoadError),   /* Length of object name
                         FULL_MODULE_NAME,   /* Module name string */
                                                  buffer */
                         &ModuleHandle);     /* Module handle */
                         FULL_MODULE_NAME,     /* Module name string */
   rc = DosFreeModule(ModuleHandle);         /* Module handle */
                         &ModuleHandle);       /* Module handle */
   rc = DosFreeModule(ModuleHandle);           /* Module handle */
 
</PRE>
===MASM Binding===
<PRE>
EXTRN  DosFreeModule:FAR
INCL_DOSMODULEMGR  EQU 1
 
PUSH  WORD    ModuleHandle  ;Module handle
CALL  DosFreeModule
 
Returns WORD
</PRE>
</PRE>
==Related Functions==
*


[[Category:The OS/2 API Project]]
[[Category:Dos16]]

Latest revision as of 02:11, 26 January 2020

This call frees the reference to a dynamic link module for a process. When the dynamic link module is no longer needed by any process, the module is freed from system memory.

Syntax

DosFreeModule (ModuleHandle)

Parameters

ModuleHandle (HMODULE) - input
Handle returned by DosLoadModule.

Return Code

rc (USHORT) - return
Return code descriptions are:
  • 0 NO_ERROR
  • 6 ERROR_INVALID_HANDLE
  • 12 ERROR_INVALID_ACCESS
  • 95 ERROR_INTERRUPT

Remarks

The module identified by the handle must be loaded through DosLoadModule. An error is returned if the handle is invalid.

If any exit list routines were registered as a result of this module being loaded, the module may not be freed and ERROR_INVALID_ACCESS may be returned.

When DosFreeModule returns to the caller, the module handle is no longer valid and is not used to reference the dynamic link module. Procedure entry addresses returned for this module are no longer valid and cause a protection fault if they are invoked.

Bindings

C

#define INCL_DOSMODULEMGR

USHORT  rc = DosFreeModule(ModuleHandle);
HMODULE ModuleHandle;  /* Module handle */

USHORT  rc;            /* return code */

MASM

EXTRN  DosFreeModule:FAR
INCL_DOSMODULEMGR   EQU 1

PUSH   WORD    ModuleHandle  ;Module handle
CALL   DosFreeModule

Returns WORD

Example

This example tries to load module ABCD. The system searches LIBPATH. If unsuccessful, the system tries to load the module from the program's directory (in case the user forgot to update LIBPATH).

#define INCL_DOSMODULEMGR

#define MODULE_NAME "abcd"
#define FULL_MODULE_NAME "\\nifty\\abcd.dll"

CHAR    LoadError[100];
HMODULE ModuleHandle;
USHORT  rc;

   if (DosLoadModule(LoadError,              /* Object name buffer */
                     sizeof(LoadError),      /* Length of object name buffer */
                     MODULE_NAME,            /* Module name string */
                     &ModuleHandle) == 2)    /* Module handle */
      rc = DosLoadModule(LoadError,          /* Object name buffer */
                         sizeof(LoadError),  /* Length of object name buffer */
                         FULL_MODULE_NAME,   /* Module name string */
                         &ModuleHandle);     /* Module handle */
   rc = DosFreeModule(ModuleHandle);         /* Module handle */