Xceed Binary Encoding Library Documentation
Examples / Encoding from file to file (VC++ example)
In This Topic
    Encoding from file to file (VC++ example)
    In This Topic

    The first portion of code demonstrates encoding, the second demonstrates decoding.

    VC++ - Encoding Copy Code

    // This sample encodes with the UUEncode format from one file to another 

    // 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 ) ); 

      IXceedUUEncodingFormatPtr piUUEncode; 

      // This will embed the original filename into the encoded data  
      piUUEncode.CreateInstance( CLSID_XceedUUEncodingFormat );  
      piUUEncode->HeaderFilename = "source.txt";   

      piBinEncoder->EncodingFormat = IXceedEncodeDataPtr( piUUEncode );  

      DWORD dwBytesRead; 
      DWORD dwBytesWritten;  

      piBinEncoder->ProcessFile( "c:\\temp\\source.txt", 0, 0, bfpEncode,
                                 TRUE, "c:\\temp\\encoded.uue", FALSE, &dwBytesRead,
                                 &dwBytesWritten );  

      MessageBox( NULL, "Encoding successful!", "Encoding result", MB_OK ); 
    }
    catch( const _com_error& xErr )
    {
      char szMsg[250]; 
      wsprintf( szMsg, "Error 08x\ns", xErr.Error(),(char*)xErr.Description() ); 
      MessageBox( NULL, szMsg, "Error", MB_OK ); 
    }
    catch( ... )
    {
      MessageBox( NULL, "Unknown error", "Error", MB_OK ); 

    CoUninitialize();

    VC++ - Decoding Copy Code

    // This sample decodes UUEncoded data from one file to another 

    // 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 ) ); 

      IXceedUUEncodingFormatPtr piUUEncode; 

      piUUEncode.CreateInstance( CLSID_XceedUUEncodingFormat );  

      piBinEncoder->EncodingFormat = IXceedEncodeDataPtr( piUUEncode );  

      DWORD dwBytesRead; 
      DWORD dwBytesWritten;  

      piBinEncoder->ProcessFile( "c:\\temp\\encoded.uue", 0, 0, bfpDecode,
                                 TRUE, "c:\\temp\\decoded.txt", FALSE, &dwBytesRead,
                                 &dwBytesWritten );   

      // If you only specify a path in the above call (terminated with a \) 
      // the filename that's embedded into the encoded data will be used. 
      MessageBox( NULL, "Decoding successful!", "Decoding result", MB_OK ); 
    }
    catch( const _com_error& xErr )
    {
      char szMsg[50]; 
      wsprintf( szMsg, "Error %08x\n", xErr.Error() ); 
      MessageBox( NULL, szMsg, "Error", MB_OK ); 
    }
    catch( ... )
    {
      MessageBox( NULL, "Unknown error", "Error", MB_OK ); 

    CoUninitialize();