4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2003 Mike McCormack
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #include "wine/unicode.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
43 DEFINE_GUID( CLSID_MozillaBrowser
, 0x1339B54C,0x3453,0x11D2,0x93,0xB9,0x00,0x00,0x00,0x00,0x00,0x00);
45 typedef HRESULT (WINAPI
*fnGetClassObject
)(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
);
46 typedef BOOL (WINAPI
*fnCanUnloadNow
)();
51 /* convert a guid to a wide character string */
52 static void MSHTML_guid2wstr( const GUID
*guid
, LPWSTR wstr
)
56 sprintf(str
, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
57 guid
->Data1
, guid
->Data2
, guid
->Data3
,
58 guid
->Data4
[0], guid
->Data4
[1], guid
->Data4
[2], guid
->Data4
[3],
59 guid
->Data4
[4], guid
->Data4
[5], guid
->Data4
[6], guid
->Data4
[7] );
60 MultiByteToWideChar( CP_ACP
, 0, str
, -1, wstr
, 40 );
63 static BOOL
MSHTML_GetMozctlPath( LPWSTR szPath
, DWORD sz
)
68 static const WCHAR szPre
[] = {
69 'S','o','f','t','w','a','r','e','\\',
70 'C','l','a','s','s','e','s','\\',
71 'C','L','S','I','D','\\',0 };
72 static const WCHAR szPost
[] = {
73 '\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2',0 };
74 WCHAR szRegPath
[(sizeof(szPre
)+sizeof(szPost
))/sizeof(WCHAR
)+40];
76 strcpyW( szRegPath
, szPre
);
77 MSHTML_guid2wstr( &CLSID_MozillaBrowser
, &szRegPath
[strlenW(szRegPath
)] );
78 strcatW( szRegPath
, szPost
);
80 TRACE("key = %s\n", debugstr_w( szRegPath
) );
82 r
= RegOpenKeyW( HKEY_LOCAL_MACHINE
, szRegPath
, &hkey
);
83 if( r
!= ERROR_SUCCESS
)
86 r
= RegQueryValueExW( hkey
, NULL
, NULL
, &type
, (LPBYTE
)szPath
, &sz
);
87 ret
= ( r
== ERROR_SUCCESS
) && ( type
== REG_SZ
);
93 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
95 WCHAR szPath
[MAX_PATH
];
98 case DLL_PROCESS_ATTACH
:
99 if( !MSHTML_GetMozctlPath( szPath
, sizeof szPath
) )
101 MESSAGE("You need to install the Mozilla ActiveX control to\n");
102 MESSAGE("use Wine's builtin MSHTML dll.\n");
105 hMozCtl
= LoadLibraryExW(szPath
, NULL
, LOAD_WITH_ALTERED_SEARCH_PATH
);
108 ERR("Can't load the Mozilla ActiveX control\n");
112 case DLL_PROCESS_DETACH
:
113 FreeLibrary( hMozCtl
);
119 HRESULT WINAPI
MSHTML_DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
122 fnGetClassObject pGetClassObject
;
124 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
126 if( !IsEqualGUID( &CLSID_HTMLDocument
, rclsid
) )
127 WARN("Unknown class %s\n", debugstr_guid(rclsid
) );
129 pGetClassObject
= (fnGetClassObject
) GetProcAddress( hMozCtl
, "DllGetClassObject" );
130 if( !pGetClassObject
)
131 return CLASS_E_CLASSNOTAVAILABLE
;
132 r
= pGetClassObject( &CLSID_MozillaBrowser
, iid
, ppv
);
134 TRACE("r = %08lx *ppv = %p\n", r
, *ppv
);
139 BOOL WINAPI
MSHTML_DllCanUnloadNow(void)
141 fnCanUnloadNow pCanUnloadNow
;
146 pCanUnloadNow
= (fnCanUnloadNow
) GetProcAddress( hMozCtl
, "DllCanUnloadNow" );
151 TRACE("r = %d\n", r
);
156 /* appears to have the same prototype as WinMain */
157 INT WINAPI
RunHTMLApplication( HINSTANCE hinst
, HINSTANCE hPrevInst
,
158 LPCSTR szCmdLine
, INT nCmdShow
)
160 FIXME("%p %p %s %d\n", hinst
, hPrevInst
, debugstr_a(szCmdLine
), nCmdShow
);
164 /***********************************************************************
165 * DllInstall (MSHTML.@)
167 HRESULT WINAPI
MSHTML_DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
169 FIXME("stub %d %s: returning S_OK\n", bInstall
, debugstr_w(cmdline
));
173 /***********************************************************************
174 * DllRegisterServer (MSHTML.@)
176 HRESULT WINAPI
MSHTML_DllRegisterServer(void)
178 FIXME("stub: returning S_OK\n");