From: Jacek Caban Subject: wscript: Added WScript.CreateObject implementation. Message-Id: <534CE11D.5010602@codeweavers.com> Date: Tue, 15 Apr 2014 09:34:53 +0200 --- programs/wscript/host.c | 25 +++++++++++++++++++++++-- programs/wscript/tests/run.js | 8 ++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/programs/wscript/host.c b/programs/wscript/host.c index 2a47ed8..55d4010 100644 --- a/programs/wscript/host.c +++ b/programs/wscript/host.c @@ -236,8 +236,29 @@ static HRESULT WINAPI Host_put_Timeout(IHost *iface, LONG v) static HRESULT WINAPI Host_CreateObject(IHost *iface, BSTR ProgID, BSTR Prefix, IDispatch **out_Dispatch) { - WINE_FIXME("(%s %s %p)\n", wine_dbgstr_w(ProgID), wine_dbgstr_w(Prefix), out_Dispatch); - return E_NOTIMPL; + IUnknown *unk; + GUID guid; + HRESULT hres; + + TRACE("(%s %s %p)\n", wine_dbgstr_w(ProgID), wine_dbgstr_w(Prefix), out_Dispatch); + + if(Prefix && *Prefix) { + FIXME("Prefix %s not supported\n", debugstr_w(Prefix)); + return E_NOTIMPL; + } + + hres = CLSIDFromProgID(ProgID, &guid); + if(FAILED(hres)) + return hres; + + hres = CoCreateInstance(&guid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER|CLSCTX_REMOTE_SERVER, + &IID_IUnknown, (void**)&unk); + if(FAILED(hres)) + return hres; + + hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)out_Dispatch); + IUnknown_Release(unk); + return hres; } static HRESULT WINAPI Host_Echo(IHost *iface, SAFEARRAY *args) diff --git a/programs/wscript/tests/run.js b/programs/wscript/tests/run.js index 8c75d0a..db0d6f9 100644 --- a/programs/wscript/tests/run.js +++ b/programs/wscript/tests/run.js @@ -49,4 +49,12 @@ WScript.Interactive = true; ok(WScript.Interactive === true, "WScript.Interactive = " + WScript.Interactive); ok(WScript.Application === WScript, "WScript.Application = " + WScript.Application); +var obj = WScript.CreateObject("Wine.Test"); +obj.ok(true, "Broken WScript.CreateObject object?"); + +try { + obj = WScript.CreateObject("nonexistent"); + ok(false, "Expected exception for CreateObject('nonexistent')"); +}catch(e) {} + winetest.reportSuccess();