//***************************************************************************** // // Microsoft Windows Media // Copyright ( C) Microsoft Corporation. All rights reserved. // // FileName: main.cpp // // Abstract: Parse the parameters and call CWMVCopy::Copy // //***************************************************************************** #include #include #include "wmvcopy.h" //------------------------------------------------------------------------------ // Name: ConvertTCharToWChar() // Desc: Converts a TCHAR string to a WCHAR string. The caller must release // the memory of pwszOutput by calling delete[] pwszOutput. //------------------------------------------------------------------------------ HRESULT ConvertTCharToWChar( LPCTSTR ptszInput, __out LPWSTR * pwszOutput ) { int cchOutput = 0; if( NULL == ptszInput || NULL == pwszOutput ) { return( E_INVALIDARG ); } // // Get output buffer size // #ifdef UNICODE cchOutput = wcslen( ptszInput ) + 1; #else //UNICODE cchOutput = MultiByteToWideChar( CP_ACP, 0, ptszInput, -1, NULL, 0 ); if( 0 == cchOutput ) { return( HRESULT_FROM_WIN32( GetLastError() ) ); } #endif // UNICODE *pwszOutput = new WCHAR[ cchOutput ]; if( NULL == *pwszOutput) { return( E_OUTOFMEMORY ); } #ifdef UNICODE wcsncpy_s( *pwszOutput, cchOutput, ptszInput, cchOutput - 1); #else //UNICODE if( 0 == MultiByteToWideChar( CP_ACP, 0, ptszInput, -1, *pwszOutput, cchOutput ) ) { SAFE_ARRAYDELETE( *pwszOutput ); return( HRESULT_FROM_WIN32( GetLastError() ) ); } #endif // UNICODE return( S_OK ); } //------------------------------------------------------------------------------ // Name: Usage() // Desc: Shows the command-line usage if the user gives incorrect arguments. //------------------------------------------------------------------------------ void Usage() { _tprintf( _T( "Usage: wmvcopy -i -o -d