使用MAPI处理泄漏

编程入门 行业动态 更新时间:2024-10-27 21:18:01
本文介绍了使用MAPI处理泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的应用程序中,我调用MAPILOGONEX来创建MAPI会话。

In my application i am calling MAPILOGONEX to create a MAPI session.

但是当我们调用mapisession的release()函数时,它是,关闭MAPI hadle并且应用程序显示句柄泄漏。

But when we call the release() function for mapisession ,it does,t close the MAPI hadle and the application shows handle leak.

代码示例: -

MAPILogonEx(0,

MAPILogonEx( 0,

个人资料, pwd, MAPI_EXPLICIT_PROFILE | MAPI_NEW_SESSION | API_EXTENDED,& MAPISession);

if(MAPISession)

{

MAPISession - > 注销(0,0,0);

MAPISession ->Logoff(0,0, 0);

MAPISession - > Release();

MAPISession ->Release();

}

这是一个已知的问题吗?任何指针或引用(任何修补程序等)

Is this an know issue? any pointer or reference ( any hotfix etc)

谢谢,

Jayesh Sharma

Jayesh Sharma

推荐答案

Jayesh,

Jayesh,

请尝试以下代码,并告诉我您是否可以重现该问题。这里的关键是你需要使用hres进行验证。

Try the following code and let me know whether you can reproduce the issue or not. Here the keything is you need to validate using hres.

bool CreateProfileWithMAPILogonEx() { HRESULT hRes = S_OK; //从MAPI通话中返回代码。 LPMAPISESSION lpSession = NULL; // MAPI会话指针。 //初始化MAPI。 if(FAILED(hRes = MAPIInitialize(NULL))) { cout<<"初始化MAPI时出错。 hRes = 0x"<< hex<< hRes<<< dec<< endl; 返回FALSE; } //指示用户点击"新建"按钮按钮。 cout<<"当\"选择个人资料\"时出现对话框,单击\"New\"按钮" <<"以配置新的个人资料。"<<< endl; //调用MAPILogonEx以显示配置文件选择器对话框。 if(FAILED(hRes = MAPILogonEx)(NULL,b $ b NULL, NULL, MAPI_LOGON_UI, & lpSession)))) { cout<<<"登录时出错。 hRes = 0x"<< hex<< hRes<<< dec<< endl; 返回FALSE; } //注销会话。 if(FAILED(hRes = lpSession-> Logoff(0,0,0))) { cout<<<"错误注销。 hRes = 0x"<< hex<< hRes<< dec<< endl; } //释放会话。 lpSession-> Release(); //取消初始化MAPI。 MAPIUninitialize(); // true,表示成功。 返回TRUE; }

bool CreateProfileWithMAPILogonEx() { HRESULT hRes = S_OK; // Return code from MAPI calls. LPMAPISESSION lpSession = NULL; // MAPI Session pointer. // Initialize MAPI. if (FAILED(hRes = MAPIInitialize(NULL))) { cout<<"Error initializing MAPI. hRes = 0x"<<hex<<hRes<<dec<<endl; return FALSE; } // Instruct user to click the "New" button. cout<<"When the \"Choose Profile\" dialog appears, click the \"New\" button" <<"to configure a new profile."<<endl; // Call MAPILogonEx to display the profile chooser dialog box. if (FAILED(hRes = MAPILogonEx(NULL, NULL, NULL, MAPI_LOGON_UI, &lpSession))) { cout<<"Error logging on. hRes = 0x"<<hex<<hRes<<dec<<endl; return FALSE; } // Log off the session. if (FAILED(hRes = lpSession->Logoff(0,0,0))) { cout<<"Error logging off. hRes = 0x"<<hex<<hRes<<dec<<endl; } // Release the session. lpSession->Release(); // Uninitialize MAPI. MAPIUninitialize(); // true, which indicates success. return TRUE; }

更多推荐

使用MAPI处理泄漏

本文发布于:2023-05-25 07:30:22,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MAPI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!