在我的应用程序中,我调用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处理泄漏
发布评论