1 | //////////////////////////////////////////////////////////// |
---|
2 | // Copyright (C) Roman Ryltsov, 2006-2014 |
---|
3 | // Created by Roman Ryltsov roman@alax.info |
---|
4 | // |
---|
5 | // A permission to use the source code is granted as long as reference to |
---|
6 | // source website http://alax.info is retained. |
---|
7 | |
---|
8 | #include "stdafx.h" |
---|
9 | #include "Module.h" |
---|
10 | |
---|
11 | INT Syntax() |
---|
12 | { |
---|
13 | _tprintf(_T("Syntax: MediaDetSnapshot [options]") _T("\n")); |
---|
14 | //_tprintf(_T("Options:") _T("\n")); |
---|
15 | //_tprintf(_T(" ") _T("-vd:device-name Use specific video source device") _T("\n")); |
---|
16 | //_tprintf(_T(" ") _T("-vf:format-name Use specific video format") _T("\n")); |
---|
17 | //_tprintf(_T(" ") _T("-ad:device-name Use specific audio source device") _T("\n")); |
---|
18 | //_tprintf(_T(" ") _T("-af:format-name Use specific audio format") _T("\n")); |
---|
19 | //_tprintf(_T(" ") _T("-ot:output-file-type Output Windows Media file type: av (default), a or v") _T("\n")); |
---|
20 | //_tprintf(_T(" ") _T("-o:output-file-name Write output into Windows Media file") _T("\n")); |
---|
21 | return 1; |
---|
22 | } |
---|
23 | |
---|
24 | //////////////////////////////////////////////////////////// |
---|
25 | // Main |
---|
26 | |
---|
27 | int _tmain(int argc, _TCHAR* argv[]) |
---|
28 | { |
---|
29 | _ATLTRY |
---|
30 | { |
---|
31 | CModule Module; |
---|
32 | #pragma region Parse Command Line |
---|
33 | for(INT nIndex = 1; nIndex < argc; nIndex++) |
---|
34 | { |
---|
35 | CString sArgument = argv[nIndex]; |
---|
36 | _A(!sArgument.IsEmpty()); |
---|
37 | #pragma region Switches |
---|
38 | if(_tcschr(_T("-/"), sArgument[0])) |
---|
39 | { |
---|
40 | sArgument.Delete(0); |
---|
41 | #pragma region Switch Value/Specification |
---|
42 | const INT nSeparatorPosition = sArgument.Find(_T(':')); |
---|
43 | CString sArgumentValue; |
---|
44 | BOOL bIntegerArgumentValueValid = FALSE; |
---|
45 | INT nIntegerArgumentValue = 0; |
---|
46 | if(nSeparatorPosition > 0) |
---|
47 | { |
---|
48 | sArgumentValue = sArgument.Mid(nSeparatorPosition + 1); |
---|
49 | sArgument = sArgument.Left(nSeparatorPosition); |
---|
50 | if(!sArgumentValue.IsEmpty()) |
---|
51 | bIntegerArgumentValueValid = AtlStringToInteger(sArgumentValue, nIntegerArgumentValue); |
---|
52 | } |
---|
53 | #pragma endregion |
---|
54 | //if(sArgument.CompareNoCase(_T("o")) == 0) // Output File Name |
---|
55 | //{ |
---|
56 | // Module.m_sOutputName = sArgumentValue; |
---|
57 | // continue; |
---|
58 | //} |
---|
59 | } |
---|
60 | #pragma endregion |
---|
61 | if(sArgument.GetLength() >= 2 && sArgument[0] == _T('"') && sArgument[sArgument.GetLength() - 1] == _T('"')) |
---|
62 | sArgument = sArgument.Mid(1, sArgument.GetLength() - 2); |
---|
63 | if(_tcslen(Module.m_sPath)) |
---|
64 | return Syntax(); |
---|
65 | Module.m_sPath = (LPCTSTR) sArgument; |
---|
66 | } |
---|
67 | #pragma endregion |
---|
68 | if(!_tcslen(Module.m_sPath)) |
---|
69 | return Syntax(); |
---|
70 | Module.WinMain(SW_SHOWNORMAL); |
---|
71 | } |
---|
72 | _ATLCATCH(Exception) |
---|
73 | { |
---|
74 | if(FAILED((HRESULT) Exception)) |
---|
75 | _tprintf(_T("Error 0x%08X: %s\n"), (HRESULT) Exception, Ds::FormatResult(Exception).TrimRight(_T("\t\n\r ."))); //AtlFormatSystemMessage(Exception).TrimRight(_T("\t\n\r ."))); |
---|
76 | return (INT) (HRESULT) Exception; |
---|
77 | } |
---|
78 | _ATLCATCHALL() |
---|
79 | { |
---|
80 | _tprintf(_T("Fatal Error\n")); |
---|
81 | return (INT) E_FAIL; |
---|
82 | } |
---|
83 | return 0; |
---|
84 | } |
---|
85 | |
---|