6.3.15 Closing a Client Application

A client application should use the OleRelease function to remove all objects from memory when it shuts down. If the library returns the value OLE_WAIT_FOR_RELEASE instead of OLE_OK, the client should not quit. The client can perform many cleanup tasks while waiting for the OLE_RELEASE notification—for example, it can close files, free memory, and hide windows.

The OLE_RELEASE notification to the client's callback function indicates that an operation has finished in a server application, but it does not identify the operation or indicate whether the operation was successful. A client application can call the OleQueryReleaseStatus function to determine whether an operation has been completed for a specified object. The OleQueryReleaseMethod function indicates the nature of the operation that has finished for a specified object. To discover the error value for the operation, the client can call the OleQueryReleaseError function.

If a client owns the clipboard when it quits, it should make sure that the data on the clipboard is complete and in the correct order.