hi,
i'm new to visual c++. i have problems converting from data type BSTR to data type char. problem occurs when compiling to a release version, not to a debug version.
here's the code
STDMETHODIMP CPassword::Validate(BSTR bstrLogID, BSTR bstrPassword, BSTR *pbstrMessage)
{
char *pCommand = NULL;
char *pszResults = NULL;
int iLength = 0;
static char acfparm[1024];
CComBSTR m_bstrParam;
CComBSTR m_bstrMessage;
_bstr_t bstrtParam;
_bstr_t bstrtACF2HostIP;
pszResults = (char *)calloc(1, 1024);
m_bstrParam.Empty();
m_bstrParam.Append("PASSCHK,"
m_bstrParam.AppendBSTR(m_bstrACF2Client);
m_bstrParam.Append(","
m_bstrParam.AppendBSTR(bstrLogID);
m_bstrParam.Append(","
m_bstrParam.AppendBSTR(bstrPassword);
bstrtParam = m_bstrParam.Copy(); //first compilation occurs here
memset(acfparm, '\0', sizeof(acfparm));
strcat (acfparm, bstrtParam.operator char *());
pCommand = _strdup(acfparm);
iLength = strlen(pCommand);
bstrtACF2HostIP = m_bstrACF2HostIP.Copy();
pszResults = Send_To_SI_ex(pCommand, iLength,
bstrtACF2HostIP.operator char *(), 390, NULL);
free(pCommand);
m_bstrMessage.Empty();
m_bstrMessage.Append(pszResults);
*pbstrMessage = m_bstrMessage.Copy();
return S_OK;
}
thanks,
clark
i'm new to visual c++. i have problems converting from data type BSTR to data type char. problem occurs when compiling to a release version, not to a debug version.
here's the code
STDMETHODIMP CPassword::Validate(BSTR bstrLogID, BSTR bstrPassword, BSTR *pbstrMessage)
{
char *pCommand = NULL;
char *pszResults = NULL;
int iLength = 0;
static char acfparm[1024];
CComBSTR m_bstrParam;
CComBSTR m_bstrMessage;
_bstr_t bstrtParam;
_bstr_t bstrtACF2HostIP;
pszResults = (char *)calloc(1, 1024);
m_bstrParam.Empty();
m_bstrParam.Append("PASSCHK,"
m_bstrParam.AppendBSTR(m_bstrACF2Client);
m_bstrParam.Append(","
m_bstrParam.AppendBSTR(bstrLogID);
m_bstrParam.Append(","
m_bstrParam.AppendBSTR(bstrPassword);
bstrtParam = m_bstrParam.Copy(); //first compilation occurs here
memset(acfparm, '\0', sizeof(acfparm));
strcat (acfparm, bstrtParam.operator char *());
pCommand = _strdup(acfparm);
iLength = strlen(pCommand);
bstrtACF2HostIP = m_bstrACF2HostIP.Copy();
pszResults = Send_To_SI_ex(pCommand, iLength,
bstrtACF2HostIP.operator char *(), 390, NULL);
free(pCommand);
m_bstrMessage.Empty();
m_bstrMessage.Append(pszResults);
*pbstrMessage = m_bstrMessage.Copy();
return S_OK;
}
thanks,
clark