This sample encodes data to Base64 from a file to a memory buffer
VC++ |
Copy Code |
// This code uses the #import directive. // Put the following line at the beginning of your module #import "XCEEDBEN.DLL" no_namespace named_guids
CoInitialize( NULL );
try { IXceedBinaryEncodingPtr piBinEncoder;
piBinEncoder.CreateInstance( CLSID_XceedBinaryEncoding ); piBinEncoder->License( _bstr_t( L"your license key ) );
IXceedBase64EncodingFormatPtr piBase64Encode; piBase64Encode.CreateInstance( CLSID_XceedBase64EncodingFormat );
piBinEncoder->EncodingFormat = IXceedEncodeDataPtr( piBase64Encode );
BYTE* pcData = NULL; DWORD dwDataSize; DWORD dwBytesRead;
piBinEncoder->ReadFile( "c:\\temp\\source.txt", 0, 0, bfpEncode, TRUE, &dwBytesRead, &pcData, &dwDataSize );
MessageBox( NULL, "Encoding successful!", "Encoding result", MB_OK );
CoTaskMemFree( pcData ); } catch( const _com_error& xErr ) { char szMsg[250]; wsprintf( szMsg, "Error %08x\n%s", xErr.Error(),(char*)xErr.Description() ); MessageBox( NULL, szMsg, "Error", MB_OK ); } catch( ... ) { MessageBox( NULL, "Unknown error", "Error", MB_OK ); }
CoUninitialize(); |