A lot of WSDAPI objects implement IUnknown, so the expose the Release() method. A few more also support Terminate(). What's the difference, and which should you call?
Ultimately, you should always refer to the documentation, as rules for specific objects may differ from the norm. But in most cases, the following guidelines apply:
Often, my cleanup code looks like this:
HRESULT hr = S_OK;IWSDDeviceHost *pDeviceHost = NULL;hr = WSDCreateDeviceHost( ..., &pDeviceHost );// ...initialize and use pDeviceHost...if( NULL != pDeviceHost ){ // Always terminate pDeviceHost if it was successfully created/initialized hr = pDeviceHost->Terminate(); // Optionally print an error if Terminate failed // Always release pDeviceHost, even if Terminate failed pDeviceHost->Release(); pDeviceHost = NULL;}