Jacek Caban : wscript.exe: Added engine lookup implementation.
Alexandre Julliard
julliard at winehq.org
Wed Jul 28 10:45:09 CDT 2010
Module: wine
Branch: master
Commit: 28efdcb52140bb0e9924f4d38976e43f9d4cbfa3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=28efdcb52140bb0e9924f4d38976e43f9d4cbfa3
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Jul 27 15:52:05 2010 +0200
wscript.exe: Added engine lookup implementation.
---
programs/wscript/Makefile.in | 2 +-
programs/wscript/main.c | 58 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 1 deletions(-)
diff --git a/programs/wscript/Makefile.in b/programs/wscript/Makefile.in
index 8d208ba..36d25f7 100644
--- a/programs/wscript/Makefile.in
+++ b/programs/wscript/Makefile.in
@@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = wscript.exe
APPMODE = -mwindows -municode
-IMPORTS =
+IMPORTS = ole32 advapi32
EXTRADEFS = -DWINE_NO_UNICODE_MACROS
C_SRCS = \
diff --git a/programs/wscript/main.c b/programs/wscript/main.c
index 33e14e9..5169b74 100644
--- a/programs/wscript/main.c
+++ b/programs/wscript/main.c
@@ -20,13 +20,71 @@
#include <windef.h>
#include <winbase.h>
+#include <winreg.h>
+#include <ole2.h>
#include <wine/debug.h>
+#include <wine/unicode.h>
WINE_DEFAULT_DEBUG_CHANNEL(wscript);
+static BOOL get_engine_clsid(const WCHAR *ext, CLSID *clsid)
+{
+ WCHAR fileid[64], progid[64];
+ DWORD res;
+ LONG size;
+ HKEY hkey;
+ HRESULT hres;
+
+ static const WCHAR script_engineW[] =
+ {'\\','S','c','r','i','p','t','E','n','g','i','n','e',0};
+
+ res = RegOpenKeyW(HKEY_CLASSES_ROOT, ext, &hkey);
+ if(res != ERROR_SUCCESS)
+ return FALSE;
+
+ size = sizeof(fileid)/sizeof(WCHAR);
+ res = RegQueryValueW(hkey, NULL, fileid, &size);
+ RegCloseKey(hkey);
+ if(res != ERROR_SUCCESS)
+ return FALSE;
+
+ WINE_TRACE("fileid is %s\n", wine_dbgstr_w(fileid));
+
+ strcatW(fileid, script_engineW);
+ res = RegOpenKeyW(HKEY_CLASSES_ROOT, fileid, &hkey);
+ if(res != ERROR_SUCCESS)
+ return FALSE;
+
+ size = sizeof(progid)/sizeof(WCHAR);
+ res = RegQueryValueW(hkey, NULL, progid, &size);
+ RegCloseKey(hkey);
+ if(res != ERROR_SUCCESS)
+ return FALSE;
+
+ WINE_TRACE("ProgID is %s\n", wine_dbgstr_w(progid));
+
+ hres = CLSIDFromProgID(progid, clsid);
+ return SUCCEEDED(hres);
+}
+
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR cmdline, int cmdshow)
{
+ const WCHAR *ext;
+ CLSID clsid;
+
WINE_FIXME("(%p %p %s %x)\n", hInst, hPrevInst, wine_dbgstr_w(cmdline), cmdshow);
+
+ if(!*cmdline)
+ return 1;
+
+ ext = strchrW(cmdline, '.');
+ if(!ext)
+ ext = cmdline;
+ if(!get_engine_clsid(ext, &clsid)) {
+ WINE_FIXME("Could not fine engine for %s\n", wine_dbgstr_w(ext));
+ return 1;
+ }
+
return 0;
}
More information about the wine-cvs
mailing list