Regards,
Ramesh M.
The Sysxxxx functions are specifically for BSTRs not wide character
strings (they're not the same). A BSTR has its allocated size stored
before the string itself, wcslen will be counting the characters to
the first NULL.
Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.
Thanks,
Ramesh M.
David Lowndes <dav...@mvps.org> wrote in message
news:uq4josg4bjstn6he0...@4ax.com...
Ramesh M. <Rame...@VeriFone.com> wrote in message
news:eyOEYfg$$GA.293@cppssbbsa04...
>
> What does the following statement mean?
> "BSTR has its allocated size stored before the string itself"
> When I saw the memory of the BSTR variable, it has shown only the
characters
> of the string.
> Where will the length be actually stored in the memory?
>
in the 4 bytes prior to the string...
For example, concider the following
BSTR tmp = SysAllocString( L"123" );
tmp will appear to have the contents 0x31 0x00 0x32 0x00 0x33 0x00, but
actually 10 bytes were allocated and if you back up in memory, you will find
it is preceded by 0x06 0x00 0x00 0x00.
> Thanks,
> Ramesh M.
>
> David Lowndes <dav...@mvps.org> wrote in message
> news:uq4josg4bjstn6he0...@4ax.com...
> > >Is there any difference between wcslen() and SysStringLen() fn.
> > >Sometimes, SysStringLen() returns 0 when wcslen() returns the proper
> length
> > >for the same string.
> >
> > The Sysxxxx functions are specifically for BSTRs not wide character
> > strings (they're not the same). A BSTR has its allocated size stored
> > before the string itself, wcslen will be counting the characters to
> > the first NULL.
> >
> > Dave
> > --
[snip]
in addition, it is not required for BSTRs to be NULL terminated. Using
wcslen on BSTRs can lead to problems....
I think Andrew's reply explains the situation as well as I could.
Thanks a lot.
Ramesh
Andrew E. Walldorff <andy.wa...@daytonrcsREMOVE.com> wrote in message
news:398ab...@nebula.superior.net...
> See inline...
>
> Ramesh M. <Rame...@VeriFone.com> wrote in message
> news:eyOEYfg$$GA.293@cppssbbsa04...
> >
> > What does the following statement mean?