您的位置:首页 > 其它

避免在MFC程序中调用进程外Com组件出现“由于另一个程序正在运行...”的解决方案

2014-03-09 22:18 645 查看
转载自:http://blog.sina.com.cn/s/blog_8a5f025a01012nm8.html

在App::InitInstance函数中加入

BOOL  App::InitInstance()

{

  CWinAppEx::InitInstance();

 // 初始化 OLE 库

 if (!AfxOleInit())

 {

  AfxMessageBox(IDP_OLE_INIT_FAILED);

  return FALSE;

 }

 //********************************************************************************************

 // 避免调用Excel VBA的时候弹出 “由于另一个程序正在运行...”

 AfxOleGetMessageFilter()-> EnableBusyDialog(FALSE);

 AfxOleGetMessageFilter()-> SetBusyReply(SERVERCALL_RETRYLATER);

 AfxOleGetMessageFilter()-> EnableNotRespondingDialog(TRUE); 

 AfxOleGetMessageFilter()-> SetMessagePendingDelay   (-1);

 //********************************************************************************************
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐