Set OLE Request Timeout from C++

自闭症网瘾萝莉.ら 提交于 2019-12-04 23:05:52

问题


I am instantiating a local COM server using CoCreateInstance. Sometimes the application providing the server takes a long time to start. When this happens, Windows pops a dialog box like this:

Server Busy

The action cannot be completed because the other program is busy. Choose 'Switch To' to activate the busy program and correct the problem.

[Switch To...] [Retry] [Cancel]

I have found mention of a Visual Basic property on the Application object, OleRequestPendingTimeout, that can be used to control the time before this dialog comes up. I can't find any good documentation on this or an equivalent that is useful from C++. Can anyone point me in the right direction?


回答1:


If you're using MFC, we used to do stuff like this:

// prevent the damned "Server Busy" dialog.
AfxOleGetMessageFilter()->EnableBusyDialog(0);
AfxOleGetMessageFilter()->EnableNotRespondingDialog(0); 



回答2:


Have a look at IMessageFilter and CoRegisterMessageFilter.




回答3:


To increase timeout call:

AfxOleGetMessageFilter()->SetMessagePendingDelay(nTimeout);

See details here How to prevent the OLE Server Busy dialog box from appearing during a lengthy COM operation



来源:https://stackoverflow.com/questions/282091/set-ole-request-timeout-from-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!