GlobalNotify

Syntax

void GlobalNotify(lpNotifyProc)

This function installs a notification procedure for the current task. Windows calls the notification procedure whenever a global memory block allocated with the GMEM_NOTIFY flag is about to be discarded.

Parameter Type/Description  

lpNotifyProc FARPROC Is the procedure instance address of the current task's notification procedure.  

Return Value

None.

Comments

An application must not call GlobalNotify more than once per instance.

Windows does not call the notification procedure when it discards memory belonging to
a DLL.

If the object is discarded, the application must use the GMEM_NOTIFY flag when it recreates the object by calling the GlobalRealloc function. Otherwise, the application will not be notified when the object is discarded again.

If the notification procedure returns a nonzero value, Windows discards the global memory block. If it returns zero, the block is not discarded.

The callback function must use the Pascal calling convention and must be declared FAR. The callback function must reside in a fixed code segment of a DLL.

Callback Function

BOOL FAR PASCAL NotifyProc(hMem)

NotifyProc is a placeholder for the application-supplied function name. Export the name by including it in an EXPORTS statement in the DLL's module-definition statement.

Parameter Type/Description  

hMem HANDLE Identifies the global memory block being discarded.  

Return Value

The function returns a nonzero value if Windows is to discard the memory block, and zero if it should not.

Comments

The callback function is not necessarily called in the context of the application that owns the routine. For this reason, the callback function should not assume the stack segment of the application. The callback function should not call any routine that might move memory.