Weird string problem. "Marilyn" is OK but not "0,6"
- From: "Fredrik Wahlgren" <fredrik.p.wahlgren@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 11 Feb 2006 22:41:56 +0100
Hi
I have just made an ATL component which I intend to use as a means of
providing extra functionality to an MFC program such that it can implement
functions that are urgently needed without having to replace the exe with a
new version. Our customers won't allow this but they will allow a new COM
component. If the exe doesn't implement the function, the ATL component
might do so.The program is essentially an interpreter. Unfortunately, all
parameters are passed as strings internally. The idea that I have is to let
the ATL component have a single interface where the first parameter is the
name of the function and the rest are the actual parameters. In order to try
out the idea, I created a very simple internal function that adds two
floating point numbers, passed as strings. The return value would also be a
string. I called it like this
sSum = pFunc->xFunc(L"SUM", L"0,1", L"0,2"", L"0,3");
The result should be the string "0,6". All I get is garbage unless I call it
like this:
pFunc->raw_xFunc(L"SUM", L"0,1", L"0,2"", L"0,3", &sSum);
The really strange thing is that if I disregard the parameters and hardcode
the return value to be "0,6", I still have the same problem..
It seems as if ATL is trying to interpret the string somehow and fails
miserably.
I eventually changed the code like this:
STDMETHODIMP Cextra::xFunc(BSTR sName, BSTR p1, BSTR p2, BSTR p3, BSTR*
sRet){
CComBSTR s;
s = L"Marilyn";
*sRet = s.Detach();
return S_OK;
}
Now I know for sure that I don't have any problems with the conversion and
calculation but it still won't work if I change the return string to "0,6".
What's happening???
Best Regards,
Fredrik
.
- Follow-Ups:
- Re: Weird string problem. "Marilyn" is OK but not "0,6"
- From: Igor Tandetnik
- Re: Weird string problem. "Marilyn" is OK but not "0,6"
- Prev by Date: Re: How to create Multiple interfaces for a class in ATL. ?
- Next by Date: Re: Weird string problem. "Marilyn" is OK but not "0,6"
- Previous by thread: How to create Multiple interfaces for a class in ATL. ?
- Next by thread: Re: Weird string problem. "Marilyn" is OK but not "0,6"
- Index(es):