📄 readfromstream.cpp
字号:
//*****************************************************************************
//
// Microsoft Windows Media
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// FileName: ReadFromStream.cpp
//
// Abstract: Defines the entry point for the console application.
//
//*****************************************************************************
#include "stdafx.h"
#include "Reader.h"
HRESULT CommandLineParser( int argc, TCHAR* argv[], TCHAR** ptszInput );
void Usage();
//------------------------------------------------------------------------------
// Name: _tmain()
// Desc: Entry point for the application.
//------------------------------------------------------------------------------
int __cdecl _tmain( int argc, TCHAR* argv[] )
{
log.Init(true,NULL,"流化");
log.Enable(true);
CReader* pReader = NULL;
HRESULT hr = S_OK;
TCHAR* ptszInput = NULL;
log.DebugOut("_tmain");
//
// Process the command line options
//
hr = CommandLineParser( argc, argv, &ptszInput );
if( FAILED( hr ) )
{
return( hr );
}
//
// Initialize COM
//
hr = CoInitialize( NULL );
if( FAILED( hr ) )
{
printf( "CoInitialize() failed (hr=%#X).", hr );
return( -1 );
}
do
{
//
// Use CReader to read from the input file
//
pReader = new CReader;
if( NULL == pReader )
{
printf( "Could not create CReader object.\n" );
return( -1 );
}
hr = pReader->Open( ptszInput );
if( FAILED( hr ) )
{
break;
}
hr = pReader->Start();
if( FAILED( hr ) )
{
break;
}
hr = pReader->Close();
if( FAILED( hr ) )
{
break;
}
}
while( FALSE );
SAFE_RELEASE( pReader );
CoUninitialize();
return( 0 );
}
//------------------------------------------------------------------------------
// Name: Usage()
// Desc: Displays the command-line usage.
//------------------------------------------------------------------------------
void Usage()
{
printf( "ReadFromStream -i <InFile>\n" );
printf( "\tInFile:\tThe input Windows Media Format file (WMA/WMV/ASF) name\n\n" );
return;
}
//------------------------------------------------------------------------------
// Name: CommandLineParser()
// Desc: Validates the arguments and gets the name of the input file.
//------------------------------------------------------------------------------
HRESULT CommandLineParser( int argc, TCHAR* argv[], TCHAR** ptszInput )
{
if( ( argc < 1 ) ||
( NULL == argv ) ||
( NULL == ptszInput ) )
{
return( E_INVALIDARG );
}
HRESULT hr = S_OK;
TCHAR* ptszMode = NULL;
*ptszInput = NULL;
for( int i = 1; i < argc; i++ )
{
if( 0 == _tcsicmp( argv[i], _T( "-i" ) ) )
{
i++;
if( i == argc )
{
Usage();
return( E_INVALIDARG );
}
*ptszInput = argv[i];
continue;
}
}
if ( NULL == *ptszInput )
{
Usage();
return( E_INVALIDARG );
}
return( S_OK );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -