当前位置:首页 > 其他 > 正文内容

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

2022-03-19其他17960

转载自: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);
 //********************************************************************************************


发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。