push 73336d9f381967eae40f391d78198b916ed9848d
[wine/hacks.git] / dlls / jscript / jscript_main.c
blobdea26ca1aed915a5b1c31194f0d70c51b7f63364
1 /*
2 * Copyright 2008 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
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winreg.h"
30 #include "ole2.h"
31 #include "advpub.h"
33 #include "initguid.h"
34 #include "activscp.h"
35 #include "activaut.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(jscript);
41 static const CLSID CLSID_JScript =
42 {0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
43 static const CLSID CLSID_JScriptAuthor =
44 {0xf414c261,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
45 static const CLSID CLSID_JScriptEncode =
46 {0xf414c262,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
48 static HINSTANCE jscript_hinstance;
50 /******************************************************************
51 * DllMain (jscript.@)
53 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
55 TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpv);
57 switch(fdwReason)
59 case DLL_WINE_PREATTACH:
60 return FALSE; /* prefer native version */
61 case DLL_PROCESS_ATTACH:
62 DisableThreadLibraryCalls(hInstDLL);
63 jscript_hinstance = hInstDLL;
64 break;
67 return TRUE;
70 /***********************************************************************
71 * DllGetClassObject (jscript.@)
73 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
75 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
76 return CLASS_E_CLASSNOTAVAILABLE;
79 /***********************************************************************
80 * DllCanUnloadNow (jscript.@)
82 HRESULT WINAPI DllCanUnloadNow(void)
84 FIXME("()\n");
85 return S_FALSE;
88 /***********************************************************************
89 * register_inf
92 #define INF_SET_ID(id) \
93 do \
94 { \
95 static CHAR name[] = #id; \
97 pse[i].pszName = name; \
98 clsids[i++] = &id; \
99 } while (0)
101 static HRESULT register_inf(BOOL doregister)
103 HRESULT hres;
104 HMODULE hAdvpack;
105 HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
106 STRTABLEA strtable;
107 STRENTRYA pse[7];
108 static CLSID const *clsids[7];
109 int i = 0;
111 static const WCHAR advpackW[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
113 INF_SET_ID(CLSID_JScript);
114 INF_SET_ID(CLSID_JScriptAuthor);
115 INF_SET_ID(CLSID_JScriptEncode);
116 INF_SET_ID(CATID_ActiveScript);
117 INF_SET_ID(CATID_ActiveScriptParse);
118 INF_SET_ID(CATID_ActiveScriptEncode);
119 INF_SET_ID(CATID_ActiveScriptAuthor);
121 for(i = 0; i < sizeof(pse)/sizeof(pse[0]); i++) {
122 pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, 39);
123 sprintf(pse[i].pszValue, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
124 clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
125 clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
126 clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
129 strtable.cEntries = sizeof(pse)/sizeof(pse[0]);
130 strtable.pse = pse;
132 hAdvpack = LoadLibraryW(advpackW);
133 pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
135 hres = pRegInstall(jscript_hinstance, doregister ? "RegisterDll" : "UnregisterDll", &strtable);
137 for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++)
138 HeapFree(GetProcessHeap(), 0, pse[i].pszValue);
140 return hres;
143 #undef INF_SET_CLSID
145 /***********************************************************************
146 * DllRegisterServer (jscript.@)
148 HRESULT WINAPI DllRegisterServer(void)
150 TRACE("()\n");
151 return register_inf(TRUE);
154 /***********************************************************************
155 * DllUnregisterServer (jscript.@)
157 HRESULT WINAPI DllUnregisterServer(void)
159 TRACE("()\n");
160 return register_inf(FALSE);