使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 479b1995ef435713c2cf4f0da8de3a6af6c30922
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
ÿþ// dui-demo.cpp : main source file
//
 
#include "stdafx.h"
#include "MainDlg.h"
//ÎNPE‡eöN R} ÿèlaÎN‡eöN R}ï„_MOn
#define RES_TYPE 0
//#define SYSRES_TYPE 0
// #define RES_TYPE 0   //PE
// #define RES_TYPE 1   //ZIP
// #define RES_TYPE 2   //7z
// #define RES_TYPE 2   //‡eöN
//»S‰cYy˜/ec ÿåNMQãNx>f—_÷mqN
#if (RES_TYPE==1)
#include "resprovider-zip\zipresprovider-param.h"
#else 
#if (RES_TYPE==2)
#include "resprovider-7zip\zip7resprovider-param.h"
#endif
#endif
#ifdef _DEBUG
#define SYS_NAMED_RESOURCE _T("soui-sys-resourced.dll")
#else
#define SYS_NAMED_RESOURCE _T("soui-sys-resource.dll")
#endif
 
bool g_bUseConsole = false;
 
//š[IN/UN„vN*NR,UIRESù[aŒ,ROBJ_IN_CPP/fresource.h-Nš[IN„v[0
ROBJ_IN_CPP
 
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int /*nCmdShow*/)
{
    HRESULT hRes = OleInitialize(NULL);
    SASSERT(SUCCEEDED(hRes));
 
    int nRet = 0;
 
    SComMgr *pComMgr = new SComMgr;
    TCHAR szCurrentDir[MAX_PATH] = { 0 };
    GetModuleFileName(NULL, szCurrentDir, sizeof(szCurrentDir));
 
    LPTSTR lpInsertPos = _tcsrchr(szCurrentDir, _T('\\'));
#ifdef _DEBUG
    _tcscpy(lpInsertPos + 1, _T("..\\mbvault"));
#else
    _tcscpy(lpInsertPos + 1, _T("\0"));
#endif
    SetCurrentDirectory(szCurrentDir);
    {
        BOOL bLoaded = FALSE;
        CAutoRefPtr<SOUI::IImgDecoderFactory> pImgDecoderFactory;
        CAutoRefPtr<SOUI::IRenderFactory> pRenderFactory;
        bLoaded = pComMgr->CreateRender_Skia((IObjRef**)&pRenderFactory);
        SASSERT_FMT(bLoaded, _T("load interface [render] failed!"));
        bLoaded = pComMgr->CreateImgDecoder((IObjRef**)&pImgDecoderFactory);
        SASSERT_FMT(bLoaded, _T("load interface [%s] failed!"), _T("imgdecoder"));
 
        pRenderFactory->SetImgDecoderFactory(pImgDecoderFactory);
        SApplication *theApp = new SApplication(pRenderFactory, hInstance);
#ifdef _DEBUG
        //    éb†NÅN(WReleaseHr,gSbSDnRû|ß~Dn(WDEBUG NËYÈ~O(uDLL R}
        { 
            HMODULE hModSysResource = LoadLibrary(SYS_NAMED_RESOURCE);
            if (hModSysResource)
            {
                CAutoRefPtr<IResProvider> sysResProvider;
                CreateResProvider(RES_PE, (IObjRef**)&sysResProvider);
                sysResProvider->Init((WPARAM)hModSysResource, 0);
                theApp->LoadSystemNamedResource(sysResProvider);
                FreeLibrary(hModSysResource);
            }
            else
            {
                SASSERT(0);
            }
        }
#else        
        //ÎNDLL R}û|ß~Dn
        {
            HMODULE hModSysResource = LoadLibrary(SYS_NAMED_RESOURCE);
            if (hModSysResource)
            {
                CAutoRefPtr<IResProvider> sysResProvider;
                CreateResProvider(RES_PE, (IObjRef**)&sysResProvider);
                sysResProvider->Init((WPARAM)hModSysResource, 0);
                theApp->LoadSystemNamedResource(sysResProvider);
                FreeLibrary(hModSysResource);
            }
            else
            {
                SASSERT(0);
            }
        }
#endif
 
        CAutoRefPtr<IResProvider>   pResProvider;
 
#ifdef _DEBUG        
        //    éb†NÅN(WReleaseHr,gSbSDnR(WDEBUG NËYÈ~O(u‡eöN R}
        {
            CreateResProvider(RES_FILE, (IObjRef**)&pResProvider);
            bLoaded = pResProvider->Init((LPARAM)_T("uires"), 0);
            SASSERT(bLoaded); 
        }
#else
        {
            CreateResProvider(RES_PE, (IObjRef**)&pResProvider);
            bLoaded = pResProvider->Init((WPARAM)hInstance, 0);
            SASSERT(bLoaded);
        }
#endif
        theApp->InitXmlNamedID(namedXmlID, ARRAYSIZE(namedXmlID), TRUE);
        theApp->AddResProvider(pResProvider);
 
        CString strCmdLine = GetCommandLine();    
 
        // O(uåw-NÃ_„vˆmo`:g6R
        SNotifyCenter* pNotifyCenter = new SNotifyCenter; 
 
        if( g_bUseConsole )
            AllocConsole();
 
        // BLOCK: Run application
        if( strCmdLine == _T("mbvault") )
        { 
            CMainDlg dlgMain;
            dlgMain.Create(GetActiveWindow());
            dlgMain.SendMessage(WM_INITDIALOG);
            dlgMain.CenterWindow(dlgMain.m_hWnd);
            //dlgMain.ShowWindow(SW_SHOWNORMAL);
            dlgMain.ShowWindow(SW_HIDE);
            nRet = theApp->Run(dlgMain.m_hWnd); 
        } 
        else
        {
            CMainDlg dlgMain;
            dlgMain.Create(GetActiveWindow());
            dlgMain.SendMessage(WM_INITDIALOG);
            dlgMain.CenterWindow(dlgMain.m_hWnd);
            dlgMain.ShowWindow(SW_SHOWNORMAL);
            //dlgMain.ShowWindow(SW_HIDE);
            nRet = theApp->Run(dlgMain.m_hWnd);
        }
 
        // KmՋO(u„v§c6RðS wah 20181110
        if( g_bUseConsole )
           FreeConsole();
 
        delete pNotifyCenter;
        //// BLOCK: Run application
        //{
        //    CMainDlg dlgMain;
        //    dlgMain.Create(GetActiveWindow());
        //    dlgMain.SendMessage(WM_INITDIALOG);
        //    dlgMain.CenterWindow(dlgMain.m_hWnd);
        //    dlgMain.ShowWindow(SW_SHOWNORMAL);
        //    nRet = theApp->Run(dlgMain.m_hWnd);
        //}
 
        delete theApp;
    }
 
    delete pComMgr;
 
    OleUninitialize();
    return nRet;
}