2 * Copyright 2010 Jacek Caban for CodeWeavers
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.
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.
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
30 #include <wine/debug.h>
31 #include <wine/unicode.h>
33 #define BUILDVERSION 16535
35 static const WCHAR wshNameW[] = {'W','i','n','d','o','w','s',' ','S','c','r','i','p','t',' ','H','o','s','t',0};
36 static const WCHAR wshVersionW[] = {'5','.','8'};
38 WINE_DEFAULT_DEBUG_CHANNEL(wscript);
40 static HRESULT WINAPI Host_QueryInterface(IHost *iface, REFIID riid, void **ppv)
42 WINE_TRACE("(%s %p)\n", wine_dbgstr_guid(riid), ppv);
44 if(IsEqualGUID(&IID_IUnknown, riid)
45 || IsEqualGUID(&IID_IDispatch, riid)
46 || IsEqualGUID(&IID_IHost, riid)) {
55 static ULONG WINAPI Host_AddRef(IHost *iface)
60 static ULONG WINAPI Host_Release(IHost *iface)
65 static HRESULT WINAPI Host_GetTypeInfoCount(IHost *iface, UINT *pctinfo)
67 WINE_TRACE("(%p)\n", pctinfo);
72 static HRESULT WINAPI Host_GetTypeInfo(IHost *iface, UINT iTInfo, LCID lcid,
75 WINE_TRACE("(%x %x %p\n", iTInfo, lcid, ppTInfo);
77 ITypeInfo_AddRef(host_ti);
82 static HRESULT WINAPI Host_GetIDsOfNames(IHost *iface, REFIID riid, LPOLESTR *rgszNames,
83 UINT cNames, LCID lcid, DISPID *rgDispId)
85 WINE_TRACE("(%s %p %d %x %p)\n", wine_dbgstr_guid(riid), rgszNames,
86 cNames, lcid, rgDispId);
88 return ITypeInfo_GetIDsOfNames(host_ti, rgszNames, cNames, rgDispId);
91 static HRESULT WINAPI Host_Invoke(IHost *iface, DISPID dispIdMember, REFIID riid,
92 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
93 EXCEPINFO *pExcepInfo, UINT *puArgErr)
95 WINE_TRACE("(%d %p %p)\n", dispIdMember, pDispParams, pVarResult);
97 return ITypeInfo_Invoke(host_ti, iface, dispIdMember, wFlags, pDispParams,
98 pVarResult, pExcepInfo, puArgErr);
101 static HRESULT WINAPI Host_get_Name(IHost *iface, BSTR *out_Name)
103 WINE_TRACE("(%p)\n", out_Name);
105 if(!(*out_Name = SysAllocString(wshNameW)))
106 return E_OUTOFMEMORY;
110 static HRESULT WINAPI Host_get_Application(IHost *iface, IDispatch **out_Dispatch)
112 WINE_FIXME("(%p)\n", out_Dispatch);
116 static HRESULT WINAPI Host_get_FullName(IHost *iface, BSTR *out_Path)
118 WCHAR fullPath[MAX_PATH];
120 WINE_TRACE("(%p)\n", out_Path);
122 if(GetModuleFileNameW(NULL, fullPath, sizeof(fullPath)/sizeof(WCHAR)) == 0)
124 if(!(*out_Path = SysAllocString(fullPath)))
125 return E_OUTOFMEMORY;
129 static HRESULT WINAPI Host_get_Path(IHost *iface, BSTR *out_Path)
131 WCHAR path[MAX_PATH];
135 WINE_TRACE("(%p)\n", out_Path);
137 if(GetModuleFileNameW(NULL, path, sizeof(path)/sizeof(WCHAR)) == 0)
139 pos = strrchrW(path, '\\');
140 howMany = pos - path;
141 if(!(*out_Path = SysAllocStringLen(path, howMany)))
142 return E_OUTOFMEMORY;
146 static HRESULT WINAPI Host_get_Interactive(IHost *iface, VARIANT_BOOL *out_Interactive)
148 WINE_FIXME("(%p)\n", out_Interactive);
152 static HRESULT WINAPI Host_put_Interactive(IHost *iface, VARIANT_BOOL v)
154 WINE_FIXME("(%x)\n", v);
158 static HRESULT WINAPI Host_Quit(IHost *iface, int ExitCode)
160 WINE_FIXME("(%d)\n", ExitCode);
164 static HRESULT WINAPI Host_get_ScriptName(IHost *iface, BSTR *out_ScriptName)
168 WINE_TRACE("(%p)\n", out_ScriptName);
170 scriptName = strrchrW(scriptFullName, '\\');
172 if(!(*out_ScriptName = SysAllocString(scriptName)))
173 return E_OUTOFMEMORY;
177 static HRESULT WINAPI Host_get_ScriptFullName(IHost *iface, BSTR *out_ScriptFullName)
179 WINE_FIXME("(%p)\n", out_ScriptFullName);
183 static HRESULT WINAPI Host_get_Arguments(IHost *iface, IArguments2 **out_Arguments)
185 WINE_FIXME("(%p)\n", out_Arguments);
189 static HRESULT WINAPI Host_get_Version(IHost *iface, BSTR *out_Version)
191 WINE_TRACE("(%p)\n", out_Version);
193 if(!(*out_Version = SysAllocString(wshVersionW)))
194 return E_OUTOFMEMORY;
198 static HRESULT WINAPI Host_get_BuildVersion(IHost *iface, int *out_Build)
200 WINE_TRACE("(%p)\n", out_Build);
202 *out_Build = BUILDVERSION;
206 static HRESULT WINAPI Host_get_Timeout(IHost *iface, LONG *out_Timeout)
208 WINE_FIXME("(%p)\n", out_Timeout);
212 static HRESULT WINAPI Host_put_Timeout(IHost *iface, LONG v)
214 WINE_FIXME("(%d)\n", v);
218 static HRESULT WINAPI Host_CreateObject(IHost *iface, BSTR ProgID, BSTR Prefix,
219 IDispatch **out_Dispatch)
221 WINE_FIXME("(%s %s %p)\n", wine_dbgstr_w(ProgID), wine_dbgstr_w(Prefix), out_Dispatch);
225 static HRESULT WINAPI Host_Echo(IHost *iface, SAFEARRAY *args)
227 WINE_FIXME("(%p)\n", args);
231 static HRESULT WINAPI Host_GetObject(IHost *iface, BSTR Pathname, BSTR ProgID,
232 BSTR Prefix, IDispatch **out_Dispatch)
234 WINE_FIXME("(%s %s %s %p)\n", wine_dbgstr_w(Pathname), wine_dbgstr_w(ProgID),
235 wine_dbgstr_w(Prefix), out_Dispatch);
239 static HRESULT WINAPI Host_DisconnectObject(IHost *iface, IDispatch *Object)
241 WINE_FIXME("(%p)\n", Object);
245 static HRESULT WINAPI Host_Sleep(IHost *iface, LONG Time)
247 WINE_FIXME("(%d)\n", Time);
251 static HRESULT WINAPI Host_ConnectObject(IHost *iface, IDispatch *Object, BSTR Prefix)
253 WINE_FIXME("(%p %s)\n", Object, wine_dbgstr_w(Prefix));
257 static HRESULT WINAPI Host_get_StdIn(IHost *iface, ITextStream **ppts)
259 WINE_FIXME("(%p)\n", ppts);
263 static HRESULT WINAPI Host_get_StdOut(IHost *iface, ITextStream **ppts)
265 WINE_FIXME("(%p)\n", ppts);
269 static HRESULT WINAPI Host_get_StdErr(IHost *iface, ITextStream **ppts)
271 WINE_FIXME("(%p)\n", ppts);
275 static const IHostVtbl HostVtbl = {
279 Host_GetTypeInfoCount,
284 Host_get_Application,
287 Host_get_Interactive,
288 Host_put_Interactive,
291 Host_get_ScriptFullName,
294 Host_get_BuildVersion,
300 Host_DisconnectObject,
308 IHost host_obj = { &HostVtbl };