The information in this article applies to:
SYMPTOMSCalling Open() on the CFile pointer returned from COleDataObject::GetFileData() may return EMFILE. Usually, this will happen after repeated drag and drop operations and subsequent calls to GetFileData(). It is also possible to see memory leaks upon termination of the application, specifically, of memory blocks the size of a CFile object. CAUSE
The documentation for COleDataObject::GetFileData() does not mention that
the returned CFile pointer is owned by the caller. Therefore, it is the
responsibility of the caller to call Close() on or simply delete that
pointer. The reason for the EMFILE return code is that the files opened in
the drag and drop operation are never closed and therefore the system
handles are exhausted. Memory leaks are caused by not deleting the CFile
objects that were dynamically allocated by GetFileData().
RESOLUTIONRemember to delete the CFile pointer returned from GetFileData() after using it. Sample CodeThe following OnDrop() function definition illustrates the correct cleanup after using the CFile pointer returned from GetFileData().
Additional query words: cfile delete stgm_hfile tymed_file
Keywords : kbole kbMFC kbVC |
Last Reviewed: February 2, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |