PRB: Successful LoadResource of Metafile Yields Random DataLast reviewed: November 2, 1995Article ID: Q86429 |
The information in this article applies to:
SYMPTOMSWhen an application for the Microsoft Windows graphical environment calls the LoadResource() function to load a metafile from the application's resources, locks the metafile with the LockResource() function, and uses the metafile, the application receives random data even though the LoadResource() and LockResource() functions indicate successful completion.
CAUSEThe application loaded the metafile previously and when the application freed the metafile, it used the DeleteMetaFile() function to invalidate the metafile handle.
RESOLUTIONModify the code that unloads the metafile from memory to call the FreeResource() function.
MORE INFORMATIONThe LoadResource() and FreeResource() functions change the lock count for a memory block that contains the resource. If the application calls DeleteMetaFile(), Windows does not change the lock count. When the application subsequently calls LoadResource() for the metafile, Windows does not load the metafile because the lock count indicates that it remains in memory. However, the returned memory handle points to the random contents of that memory block. For more information on the resource lock count, query in the Microsoft Knowledge Base on the following words:
multiple and references and LoadResourceMost of the time, an application uses the DeleteMetaFile() function to remove a metafile from memory. This function is appropriate for metafiles created with the CopyMetaFile() or CreateMetaFile() functions, or metafiles loaded from disk with the GetMetaFile() function. However, DeleteMetaFile() does not decrement the lock count of a metafile loaded as a resource.
|
Additional reference words: 3.00 3.10 3.50 3.51 4.00 95 EnumMetaFile
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |