I have a module for C ++ which receives data from the WMI module asynchronously. But if you ask him a few times in a row, I get this error and get an answer only on the first call. How can I fix this?
Security must be initialized prior to the transmission or reception parameters.
Changes can not be made after the initialization.
Just run into this problem today. This error message means CoInitializeSecurity has already been called (it should be called only once per process).
I fix it by adding a flag indicating whether CoInitializeSecurity has been called or not, this flag is set when CoInitializeSecurity is called the first time, by checking the flag the subsequent calls can be avoided.
Considering multithreading you may need to add an exclusive lock to this code block.