Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 C++ 模块,它异步接收来自 WMI 模块的数据。但是,如果您连续问他几次,我会收到此错误,并且仅在第一次通话时才能得到答复。我怎样才能解决这个问题?
Security must be initialized prior to the transmission or reception parameters. Changes can not be made after the initialization.
今天刚好遇到这个问题。此错误消息意味着CoInitializeSecurity已被调用(每个进程只应调用一次)。
我通过添加一个指示CoInitializeSecurity是否已被调用的标志来修复它,该标志在第一次调用CoInitializeSecurity时设置,通过检查该标志可以避免后续调用。
考虑到多线程,您可能需要向此代码块添加排他锁。