vbscript: Added more IActiveScript tests.
[wine] / dlls / vbscript / vbscript_main.c
1 /*
2  * Copyright 2011 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22
23 #define COBJMACROS
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "initguid.h"
28
29 #include "ole2.h"
30 #include "rpcproxy.h"
31 #include "vbscript.h"
32 #include "vbscript_classes.h"
33
34 #include "wine/debug.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
37
38 static HINSTANCE vbscript_hinstance;
39
40 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
41 {
42     *ppv = NULL;
43
44     if(IsEqualGUID(&IID_IUnknown, riid)) {
45         TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
46         *ppv = iface;
47     }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
48         TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
49         *ppv = iface;
50     }
51
52     if(*ppv) {
53         IUnknown_AddRef((IUnknown*)*ppv);
54         return S_OK;
55     }
56
57     FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
58     return E_NOINTERFACE;
59 }
60
61 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
62 {
63     TRACE("(%p)\n", iface);
64     return 2;
65 }
66
67 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
68 {
69     TRACE("(%p)\n", iface);
70     return 1;
71 }
72
73 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
74 {
75     TRACE("(%p)->(%x)\n", iface, fLock);
76     return S_OK;
77 }
78
79 static const IClassFactoryVtbl VBScriptFactoryVtbl = {
80     ClassFactory_QueryInterface,
81     ClassFactory_AddRef,
82     ClassFactory_Release,
83     VBScriptFactory_CreateInstance,
84     ClassFactory_LockServer
85 };
86
87 static IClassFactory VBScriptFactory = { &VBScriptFactoryVtbl };
88
89 /******************************************************************
90  *              DllMain (vbscript.@)
91  */
92 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
93 {
94     TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpv);
95
96     switch(fdwReason)
97     {
98     case DLL_WINE_PREATTACH:
99         return FALSE;  /* prefer native version */
100     case DLL_PROCESS_ATTACH:
101         DisableThreadLibraryCalls(hInstDLL);
102         vbscript_hinstance = hInstDLL;
103         break;
104     }
105
106     return TRUE;
107 }
108
109 /***********************************************************************
110  *              DllGetClassObject       (vbscript.@)
111  */
112 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
113 {
114     if(IsEqualGUID(&CLSID_VBScript, rclsid)) {
115         TRACE("(CLSID_VBScript %s %p)\n", debugstr_guid(riid), ppv);
116         return IClassFactory_QueryInterface(&VBScriptFactory, riid, ppv);
117     }
118
119     FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
120     return CLASS_E_CLASSNOTAVAILABLE;
121 }
122
123 /***********************************************************************
124  *          DllCanUnloadNow (vbscript.@)
125  */
126 HRESULT WINAPI DllCanUnloadNow(void)
127 {
128     return S_FALSE;
129 }
130
131 /***********************************************************************
132  *          DllRegisterServer (vbscript.@)
133  */
134 HRESULT WINAPI DllRegisterServer(void)
135 {
136     TRACE("()\n");
137     return __wine_register_resources(vbscript_hinstance);
138 }
139
140 /***********************************************************************
141  *          DllUnregisterServer (vbscript.@)
142  */
143 HRESULT WINAPI DllUnregisterServer(void)
144 {
145     TRACE("()\n");
146     return __wine_unregister_resources(vbscript_hinstance);
147 }