Problem with Access-mdb/DAO
Cenedese at indel.ch
Tue Dec 16 09:10:36 CST 2003
>I think I found an error in SysStringLen. Why? Because my application
>started to work a lot better. Why not? I don't know if this is the right fix
>or other stuff is involved (as with the GetWindowLong).
> * The length of the string (in bytes) is contained in a DWORD placed
> * just before the BSTR pointer
> bufferPointer = (DWORD*)str;
> return (int)(*bufferPointer/sizeof(WCHAR));
>If I come here with a string like "Nodes" (normal string length 5) it will
>return (int)(5/2)=2. But 2 is definitely not enough (in WCHAR length). But
>if I do (int)((5+1)/2)=3 my name comes through. And also the other names
>that got truncated. So I would change it to:
> return (int)((*bufferPointer+1)/sizeof(WCHAR));
>Can anybody comment on this? Is this the right fix?
Actually MSDN says about SysStringLen:
Return Value: The number of characters in bstr
Comments: For a BSTR allocated with Sys[Re]AllocStringLen or SysAllocStringByteLen, this function always returns the number of characters specified in the cch parameter at allocation time
So this code looks strange. Either it should return *bufferPointer if
not zero or then a real calculation _fstrlen(str)/sizeof(WCHAR).
Or is MSDN wrong in this case?
More information about the wine-devel