1 /*****************************************************************************
\r
2 * main.cpp: ActiveX control for VLC
\r
3 *****************************************************************************
\r
4 * Copyright (C) 2005 VideoLAN
\r
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
\r
8 * This program is free software; you can redistribute it and/or modify
\r
9 * it under the terms of the GNU General Public License as published by
\r
10 * the Free Software Foundation; either version 2 of the License, or
\r
11 * (at your option) any later version.
\r
13 * This program is distributed in the hope that it will be useful,
\r
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 * GNU General Public License for more details.
\r
18 * You should have received a copy of the GNU General Public License
\r
19 * along with this program; if not, write to the Free Software
\r
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
\r
21 *****************************************************************************/
\r
27 using namespace std;
\r
29 static LONG i_class_ref= 0;
\r
30 static HINSTANCE h_instance= 0;
\r
32 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
\r
34 HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
\r
38 if( CLSID_VLCPlugin == rclsid )
\r
40 VLCPluginClass *plugin = new VLCPluginClass(&i_class_ref, h_instance);
\r
41 hr = plugin->QueryInterface(riid, ppv);
\r
47 STDAPI DllCanUnloadNow(VOID)
\r
49 return (0 == i_class_ref) ? S_OK: S_FALSE;
\r
52 STDAPI DllRegisterServer(VOID)
\r
57 STDAPI DllUnregisterServer(VOID)
\r
62 #ifdef BUILD_LOCALSERVER
\r
65 ** easier to debug an application than a DLL on cygwin GDB :)
\r
70 STDAPI_(int) WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
\r
74 if( FAILED(OleInitialize(NULL)) )
\r
76 cerr << "cannot initialize OLE" << endl;
\r
80 IUnknown *classProc = NULL;
\r
82 if( FAILED(DllGetClassObject(CLSID_VLCPlugin, IID_IUnknown, (LPVOID *)&classProc)) )
\r
85 DWORD dwRegisterClassObject;
\r
87 if( FAILED(CoRegisterClassObject(CLSID_VLCPlugin, classProc,
\r
88 CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &dwRegisterClassObject)) )
\r
91 DWORD dwRegisterActiveObject;
\r
93 if( FAILED(RegisterActiveObject(classProc, CLSID_VLCPlugin,
\r
94 ACTIVEOBJECT_WEAK, &dwRegisterActiveObject)) )
\r
97 classProc->Release();
\r
100 * Polling messages from event queue
\r
102 while( S_FALSE == DllCanUnloadNow() )
\r
104 while( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
\r
106 if( msg.message == WM_QUIT )
\r
107 break; // Leave the PeekMessage while() loop
\r
109 /*if(TranslateAccelerator(ghwndApp, ghAccel, &msg))
\r
112 TranslateMessage(&msg);
\r
113 DispatchMessage(&msg);
\r
116 if(msg.message == WM_QUIT)
\r
117 break; // Leave the for() loop
\r
122 if( SUCCEEDED(RevokeActiveObject(dwRegisterActiveObject, NULL)) )
\r
123 CoRevokeClassObject(dwRegisterClassObject);
\r
125 // Reached on WM_QUIT message
\r
127 return ((int) msg.wParam);
\r
132 STDAPI_(BOOL) DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpReserved )
\r
134 switch( fdwReason )
\r
136 case DLL_PROCESS_ATTACH:
\r
137 h_instance = (HINSTANCE)hModule;
\r