Cleaning up and Shutting Down a WMI Application
After you set the security levels for your IWbemServices pointer, you can access the various capabilities of WMI. After you finish using WMI, you must shut down your application.
The following procedure describes how to clean up and shut down a WMI application.
To clean up and shut down a WMI application
Release any open COM interfaces.
As with all COM applications, you must call CoUninitialize at the end of your application.
Exit your application.
The following code example shows how to exit a WMI client application.
// The following #include and #define statements need // to be used with this code: // #define _WIN32_DCOM // #include <wbemidl.h> // #pragma comment(lib, "wbemuuid.lib") // pSvc was declared as IWbemServices *pSvc; // pLoc was declared as IWbemLocator *pLoc; pSvc->Release(); pLoc->Release(); CoUninitialize(); return 0; // Program successfully completed.
You have now successfully initialized COM, accessed WMI, and exited your application. For more information, see Example: Creating a WMI Application.