Dredwick
asked on
ATL COM Object GET property using BSTR
Is this code correct..IE will it product memory leaks?
STDMETHODIMP CUPS::get_m_strLastError(B STR *pVal)
{
AFX_MANAGE_STATE(AfxGetSta ticModuleS tate())
// TODO: Add your implementation code here
SysFreeString(*pVal);
CString strError;
strError="<font style='font-size:10pt;font -family:Ve rdana,Aria l;'>";
strError+=m_strLastError+" </font>\0" ;
int iSize=strError.GetLength() ;
char* str = strError.GetBuffer(iSize);
unsigned short *newstr= NULL;
int iWideSize=MultiByteToWideC har(CP_ACP ,MB_PRECOM POSED,str, -1,newstr, 0);
newstr = new unsigned short[iWideSize];
memset(newstr,0,iWideSize) ;
MultiByteToWideChar(CP_ACP ,MB_PRECOM POSED,str, -1,newstr, iWideSize) ;
*pVal=SysAllocString(newst r);
delete (unsigned short*)newstr;
strError.ReleaseBuffer();
return S_OK;
}
STDMETHODIMP CUPS::get_m_strLastError(B
{
AFX_MANAGE_STATE(AfxGetSta
// TODO: Add your implementation code here
SysFreeString(*pVal);
CString strError;
strError="<font style='font-size:10pt;font
strError+=m_strLastError+"
int iSize=strError.GetLength()
char* str = strError.GetBuffer(iSize);
unsigned short *newstr= NULL;
int iWideSize=MultiByteToWideC
newstr = new unsigned short[iWideSize];
memset(newstr,0,iWideSize)
MultiByteToWideChar(CP_ACP
*pVal=SysAllocString(newst
delete (unsigned short*)newstr;
strError.ReleaseBuffer();
return S_OK;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER