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
21 #define BUILDVERSION 16535
23 static const WCHAR wshNameW
[] = {'W','i','n','d','o','w','s',' ','S','c','r','i','p','t',' ','H','o','s','t',0};
24 static const WCHAR wshVersionW
[] = {'5','.','8'};
26 VARIANT_BOOL wshInteractive
=
33 static HRESULT WINAPI
Host_QueryInterface(IHost
*iface
, REFIID riid
, void **ppv
)
35 WINE_TRACE("(%s %p)\n", wine_dbgstr_guid(riid
), ppv
);
37 if(IsEqualGUID(&IID_IUnknown
, riid
)
38 || IsEqualGUID(&IID_IDispatch
, riid
)
39 || IsEqualGUID(&IID_IHost
, riid
)) {
48 static ULONG WINAPI
Host_AddRef(IHost
*iface
)
53 static ULONG WINAPI
Host_Release(IHost
*iface
)
58 static HRESULT WINAPI
Host_GetTypeInfoCount(IHost
*iface
, UINT
*pctinfo
)
60 WINE_TRACE("(%p)\n", pctinfo
);
65 static HRESULT WINAPI
Host_GetTypeInfo(IHost
*iface
, UINT iTInfo
, LCID lcid
,
68 WINE_TRACE("(%x %x %p\n", iTInfo
, lcid
, ppTInfo
);
70 ITypeInfo_AddRef(host_ti
);
75 static HRESULT WINAPI
Host_GetIDsOfNames(IHost
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
76 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
78 WINE_TRACE("(%s %p %d %x %p)\n", wine_dbgstr_guid(riid
), rgszNames
,
79 cNames
, lcid
, rgDispId
);
81 return ITypeInfo_GetIDsOfNames(host_ti
, rgszNames
, cNames
, rgDispId
);
84 static HRESULT WINAPI
Host_Invoke(IHost
*iface
, DISPID dispIdMember
, REFIID riid
,
85 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
86 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
88 WINE_TRACE("(%d %p %p)\n", dispIdMember
, pDispParams
, pVarResult
);
90 return ITypeInfo_Invoke(host_ti
, iface
, dispIdMember
, wFlags
, pDispParams
,
91 pVarResult
, pExcepInfo
, puArgErr
);
94 static HRESULT WINAPI
Host_get_Name(IHost
*iface
, BSTR
*out_Name
)
96 WINE_TRACE("(%p)\n", out_Name
);
98 if(!(*out_Name
= SysAllocString(wshNameW
)))
103 static HRESULT WINAPI
Host_get_Application(IHost
*iface
, IDispatch
**out_Dispatch
)
105 WINE_TRACE("(%p)\n", out_Dispatch
);
107 *out_Dispatch
= (IDispatch
*)&host_obj
;
111 static HRESULT WINAPI
Host_get_FullName(IHost
*iface
, BSTR
*out_Path
)
113 WCHAR fullPath
[MAX_PATH
];
115 WINE_TRACE("(%p)\n", out_Path
);
117 if(GetModuleFileNameW(NULL
, fullPath
, sizeof(fullPath
)/sizeof(WCHAR
)) == 0)
119 if(!(*out_Path
= SysAllocString(fullPath
)))
120 return E_OUTOFMEMORY
;
124 static HRESULT WINAPI
Host_get_Path(IHost
*iface
, BSTR
*out_Path
)
126 WCHAR path
[MAX_PATH
];
130 WINE_TRACE("(%p)\n", out_Path
);
132 if(GetModuleFileNameW(NULL
, path
, sizeof(path
)/sizeof(WCHAR
)) == 0)
134 pos
= strrchrW(path
, '\\');
135 howMany
= pos
- path
;
136 if(!(*out_Path
= SysAllocStringLen(path
, howMany
)))
137 return E_OUTOFMEMORY
;
141 static HRESULT WINAPI
Host_get_Interactive(IHost
*iface
, VARIANT_BOOL
*out_Interactive
)
143 WINE_TRACE("(%p)\n", out_Interactive
);
145 *out_Interactive
= wshInteractive
;
149 static HRESULT WINAPI
Host_put_Interactive(IHost
*iface
, VARIANT_BOOL v
)
151 WINE_TRACE("(%x)\n", v
);
157 static HRESULT WINAPI
Host_Quit(IHost
*iface
, int ExitCode
)
159 WINE_FIXME("(%d)\n", ExitCode
);
163 static HRESULT WINAPI
Host_get_ScriptName(IHost
*iface
, BSTR
*out_ScriptName
)
167 WINE_TRACE("(%p)\n", out_ScriptName
);
169 scriptName
= strrchrW(scriptFullName
, '\\');
171 if(!(*out_ScriptName
= SysAllocString(scriptName
)))
172 return E_OUTOFMEMORY
;
176 static HRESULT WINAPI
Host_get_ScriptFullName(IHost
*iface
, BSTR
*out_ScriptFullName
)
178 WINE_TRACE("(%p)\n", out_ScriptFullName
);
180 if(!(*out_ScriptFullName
= SysAllocString(scriptFullName
)))
181 return E_OUTOFMEMORY
;
185 static HRESULT WINAPI
Host_get_Arguments(IHost
*iface
, IArguments2
**out_Arguments
)
187 WINE_TRACE("(%p)\n", out_Arguments
);
189 *out_Arguments
= &arguments_obj
;
193 static HRESULT WINAPI
Host_get_Version(IHost
*iface
, BSTR
*out_Version
)
195 WINE_TRACE("(%p)\n", out_Version
);
197 if(!(*out_Version
= SysAllocString(wshVersionW
)))
198 return E_OUTOFMEMORY
;
202 static HRESULT WINAPI
Host_get_BuildVersion(IHost
*iface
, int *out_Build
)
204 WINE_TRACE("(%p)\n", out_Build
);
206 *out_Build
= BUILDVERSION
;
210 static HRESULT WINAPI
Host_get_Timeout(IHost
*iface
, LONG
*out_Timeout
)
212 WINE_FIXME("(%p)\n", out_Timeout
);
216 static HRESULT WINAPI
Host_put_Timeout(IHost
*iface
, LONG v
)
218 WINE_FIXME("(%d)\n", v
);
222 static HRESULT WINAPI
Host_CreateObject(IHost
*iface
, BSTR ProgID
, BSTR Prefix
,
223 IDispatch
**out_Dispatch
)
229 TRACE("(%s %s %p)\n", wine_dbgstr_w(ProgID
), wine_dbgstr_w(Prefix
), out_Dispatch
);
231 if(Prefix
&& *Prefix
) {
232 FIXME("Prefix %s not supported\n", debugstr_w(Prefix
));
236 hres
= CLSIDFromProgID(ProgID
, &guid
);
240 hres
= CoCreateInstance(&guid
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_LOCAL_SERVER
|CLSCTX_REMOTE_SERVER
,
241 &IID_IUnknown
, (void**)&unk
);
245 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatch
, (void**)out_Dispatch
);
246 IUnknown_Release(unk
);
250 static HRESULT WINAPI
Host_Echo(IHost
*iface
, SAFEARRAY
*args
)
252 WINE_FIXME("(%p)\n", args
);
256 static HRESULT WINAPI
Host_GetObject(IHost
*iface
, BSTR Pathname
, BSTR ProgID
,
257 BSTR Prefix
, IDispatch
**out_Dispatch
)
259 WINE_FIXME("(%s %s %s %p)\n", wine_dbgstr_w(Pathname
), wine_dbgstr_w(ProgID
),
260 wine_dbgstr_w(Prefix
), out_Dispatch
);
264 static HRESULT WINAPI
Host_DisconnectObject(IHost
*iface
, IDispatch
*Object
)
266 WINE_FIXME("(%p)\n", Object
);
270 static HRESULT WINAPI
Host_Sleep(IHost
*iface
, LONG Time
)
272 WINE_FIXME("(%d)\n", Time
);
276 static HRESULT WINAPI
Host_ConnectObject(IHost
*iface
, IDispatch
*Object
, BSTR Prefix
)
278 WINE_FIXME("(%p %s)\n", Object
, wine_dbgstr_w(Prefix
));
282 static HRESULT WINAPI
Host_get_StdIn(IHost
*iface
, ITextStream
**ppts
)
284 WINE_FIXME("(%p)\n", ppts
);
288 static HRESULT WINAPI
Host_get_StdOut(IHost
*iface
, ITextStream
**ppts
)
290 WINE_FIXME("(%p)\n", ppts
);
294 static HRESULT WINAPI
Host_get_StdErr(IHost
*iface
, ITextStream
**ppts
)
296 WINE_FIXME("(%p)\n", ppts
);
300 static const IHostVtbl HostVtbl
= {
304 Host_GetTypeInfoCount
,
309 Host_get_Application
,
312 Host_get_Interactive
,
313 Host_put_Interactive
,
316 Host_get_ScriptFullName
,
319 Host_get_BuildVersion
,
325 Host_DisconnectObject
,
333 IHost host_obj
= { &HostVtbl
};