On Thu, 20 Nov 2008 08:46:12 +0100, "Fred Zwarts" <F.Zwarts@KVI.nl>
wrote:
Quote:
>"Chunekit Pong" <worlman385@yahoo.comwrote in message news:f54ai4l6o3hdj8k2j0as78nhm0166ndt4r@4ax.com...
Quote:
>>I have a BYTE array -
>BYTE const* pbBinary
>
>You don't have a BYTE array, you have a pointer to BYTE.
>(What is a BYTE?)
>
Quote:
>>
>I would like to know how many bytes in that byte array
>>
>but if I do - sizeof(* pbBinary); - then I got 1
>but if I do - sizeof( pbBinary); - then I got 4
>>
>I am sure the array has hundreds of bytes
>>
>how can I do that?
>
>Without other information you can't.
>
The whole code is like this - the purpose is to convert binary file
into a Base64 string
=================
typedef unsigned char BYTE;
std::ifstream file1("c:/test2.png");
// read from test2.png into BYTE array
std::vector<BYTEbytes(
(std::istreambuf_iterator<char>(file1))
, (std::istreambuf_iterator<char>())
);
if(bytes.empty())
; // no bytes have been read
BYTE const* pbBinary = &bytes[0];
int size = sizeof(pbBinary);
unsigned long ulEncLen = 0;
char *pEncOut = NULL;
BOOL fRet = ::CryptBinaryToString( pbBinary, size,
CRYPT_STRING_BASE64, pEncOut, &ulEncLen );
====================
BOOL WINAPI CryptBinaryToString(
__in const BYTE *pbBinary,
__in DWORD cbBinary,
__in DWORD dwFlags,
__out_opt LPTSTR pszString,
__inout DWORD *pcchString
);