我可以在不先初始化 COM 的情况下使用 ShellExecute()
吗?
最佳答案
documentation有你问题的答案:
Because ShellExecute can delegate execution to Shell extensions (data sources, context menu handlers, verb implementations) that are activated using Component Object Model (COM), COM should be initialized before ShellExecute is called. Some Shell extensions require the COM single-threaded apartment (STA) type. In that case, COM should be initialized as shown here:
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)
There are certainly instances where ShellExecute does not use one of these types of Shell extension and those instances would not require COM to be initialized at all. Nonetheless, it is good practice to always initalize COM before using this function.
不想听起来太居高临下,有一点是要确保您始终从上到下阅读文档。
关于c - 使用ShellExecute()时是否需要初始化COM?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31189867/