Simple question about Paramter size in CreateParameter

From: Alan Pong (alanpong_at_hkstar.com)
Date: 08/25/04


Date: 25 Aug 2004 05:37:49 -0700

win2k, vc++6

const char pattern[8] = "abcdefgh";
_variant_t v;
v.SetString(pattern); //ALWAYS create a double-byted unicode string

size = (sizeof(buffer) + 1) * 2 // is it correct ?????

_CommandPtr pCommand;
pCommand.CreateInstance (__uuidof (Command));
pCommand->CreateParameter( _bstr_t ("pattern"), adChar, adParamInput,
size, v);

v encapsulates a BSTR which is a unicode string which has
zero-terminated character at the end. And also "adChar" is defined as
"A String value (DBTYPE_STR or Null-terminated ASCII character
string)".

So, the memory allocated to this string and the Parameter size is:

(sizeof(buffer)+1) * 2 = (8+1) * 2 = 18 bytes

Am I correct?

Thanks.
Rgds.
Alan
--END



Relevant Pages