Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert BSTR to char and vice versa

Status
Not open for further replies.

cgreynes

Programmer
Feb 28, 2003
29
US
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
 
look in faq207-1044

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top