aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Bal/test/examples/TestEngine/ExampleTestEngine.cpp
blob: fc1938feeb96a8dab140115c6c3f933d082605f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.

#include "precomp.h"

int __cdecl wmain(int argc, LPWSTR argv[])
{
    HRESULT hr = S_OK;
    BOOL fComInitialized = FALSE;
    BOOL fShowUsage = FALSE;

    // initialize COM
    hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
    ExitOnFailure(hr, "Failed to initialize COM.");
    fComInitialized = TRUE;

    ConsoleInitialize();

    if (argc != 4)
    {
        fShowUsage = TRUE;
    }
    else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"reload", -1))
    {
        hr = RunReloadEngine(argv[2], argv[3]);
    }
    else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"shutdown", -1))
    {
        hr = RunShutdownEngine(argv[2], argv[3]);
    }
    else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"waitforquit", -1))
    {
        hr = RunWaitForQuitEngine(argv[2], argv[3]);
    }
    else
    {
        fShowUsage = TRUE;
    }

    if (fShowUsage)
    {
        ConsoleWriteError(hr = E_INVALIDARG, CONSOLE_COLOR_RED, "Usage: Example.TestEngine.exe {reload|shutdown|waitforquit} Bundle.exe BA.dll");
    }

    ConsoleUninitialize();

LExit:
    if (fComInitialized)
    {
        ::CoUninitialize();
    }

    return hr;
}