Page 94 - DCAP408_WEB_PROGRAMMING
P. 94

Windows Programming




                    Notes                  UINT  uBytes,  //  new  size  of  block
                                           UINT  uFlags  //  how  to  reallocate  object
                                      );
                                   5.5.1 Parameters


                                   hMem

                                   It determines the local memory object to be reallocated. This handle is returned by either the
                                   LocalAlloc or LocalReAlloc function.

                                   UBytes

                                   It states the new size, in bytes, of the memory block. If this parameter is zero and the uFlags
                                   parameter states the LMEM_MOVEABLE flag, the function returns a handle to a memory object
                                   that is marked as discarded. If uFlagsspecifies the LMEM_MODIFY flag, this parameter is ignored.
                                   uFlags


                                   It specifies how to reallocate the local memory object. If the LMEM_MODIFY flag is specified,
                                   this  parameter modifies the attributes  of the memory object,  and the  uBytes parameter  is
                                   unobserved. Or else, this parameter handles the reallocation of the memory object.
                                   The LMEM_MODIFY flag can be united with either or both of the following flags:

                                            Flag                               Meaning
                                     LMEM_DISCARDABLE   Assigns discardable memory if the LMEM_MODIFY flag is also specified.
                                                        This  flag  is  overlooked,  unless  the  object  was  previously  allocated  as
                                                        movable or the LMEM_MOVEABLE flag is also specified.
                                     LMEM_MOVEABLE      You cannot merge LMEM_MOVEABLE with LMEM_MODIFY to change
                                                        a fixed memory object into a movable one. The function returns an error if
                                                        an application attempts this.

                                   If uFlags does not state LMEM_MODIFY, this parameter can be any mixture of the following
                                   flags:


                                           Flag                                Meaning
                                    LMEM_MOVEABLE      If uBytes is  zero,  discards  a  formerly  movable  and  discardable  memory
                                                       block. If the objects lock count is not zero or the block is not movable and
                                                       discardable, the function fails.
                                                       If uBytes is nonzero, enables the system to move the reallocated block to a
                                                       new  location  without  modifying  the  movable  or  fixed  attribute  of  the
                                                       memory object. If the object is fixed, the handle returned may be dissimilar
                                                       from the handle stated in the hMem parameter. If the object is movable, the
                                                       block  can  be  moved  without  invalidating  the  handle,  even  if  the  object  is
                                                       currently locked by a previous call to the LocalLockfunction. To obtain the
                                                       new address of the memory block, use LocalLock.
                                    LMEM_NOCOMPACT     Avoids memory from being compacted or discarded to satisfy the allocation
                                                       request.
                                    LMEM_ZEROINIT      Causes the supplementary memory contents to be initialized to zero if the
                                                       memory object is growing in size.




          88                                LOVELY PROFESSIONAL UNIVERSITY
   89   90   91   92   93   94   95   96   97   98   99