Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 1 | /* |
Juergen Schmied | cd390f3 | 1998-12-14 14:51:27 +0000 | [diff] [blame] | 2 | * handling of SHELL32.DLL OLE-Objects |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright 1997 Marcus Meissner |
| 5 | * Copyright 1998 Juergen Schmied <juergen.schmied@metronet.de> |
| 6 | * |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 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. |
| 11 | * |
| 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. |
| 16 | * |
| 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 |
Jonathan Ernst | 360a3f9 | 2006-05-18 14:49:52 +0200 | [diff] [blame] | 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
Patrik Stridvall | bc38d6b | 2001-07-20 18:00:00 +0000 | [diff] [blame] | 22 | #include "config.h" |
| 23 | |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 24 | #include <stdarg.h> |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 25 | #include <stdlib.h> |
| 26 | #include <string.h> |
Juergen Schmied | 8e7cb4d | 1999-03-25 10:57:12 +0000 | [diff] [blame] | 27 | |
Francois Gouget | 486d020 | 2004-10-07 03:06:48 +0000 | [diff] [blame] | 28 | #define COBJMACROS |
Piotr Caban | bfaae9b | 2010-11-16 14:58:03 +0100 | [diff] [blame] | 29 | #define NONAMELESSUNION |
Francois Gouget | 486d020 | 2004-10-07 03:06:48 +0000 | [diff] [blame] | 30 | |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 31 | #include "windef.h" |
| 32 | #include "winbase.h" |
François Gouget | dea3d78 | 2001-01-02 21:00:46 +0000 | [diff] [blame] | 33 | #include "shellapi.h" |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 34 | #include "wingdi.h" |
| 35 | #include "winuser.h" |
Patrik Stridvall | bc38d6b | 2001-07-20 18:00:00 +0000 | [diff] [blame] | 36 | #include "shlobj.h" |
Juergen Schmied | ba28ba1 | 1999-01-23 14:12:48 +0000 | [diff] [blame] | 37 | #include "shlguid.h" |
Alexander Morozov | 8b30849 | 2011-01-18 21:35:41 +0300 | [diff] [blame] | 38 | #include "shldisp.h" |
Juergen Schmied | 8e7cb4d | 1999-03-25 10:57:12 +0000 | [diff] [blame] | 39 | #include "winreg.h" |
| 40 | #include "winerror.h" |
Marcus Meissner | 317af32 | 1999-02-17 13:51:06 +0000 | [diff] [blame] | 41 | |
Alexandre Julliard | 3954117 | 2001-08-16 18:49:56 +0000 | [diff] [blame] | 42 | #include "undocshell.h" |
Patrik Stridvall | bc38d6b | 2001-07-20 18:00:00 +0000 | [diff] [blame] | 43 | #include "wine/unicode.h" |
Juergen Schmied | 8e7cb4d | 1999-03-25 10:57:12 +0000 | [diff] [blame] | 44 | #include "shell32_main.h" |
| 45 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 46 | #include "wine/debug.h" |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 47 | #include "shlwapi.h" |
Juergen Schmied | 1e5ec88 | 2002-07-24 01:56:03 +0000 | [diff] [blame] | 48 | #include "debughlp.h" |
Patrik Stridvall | bc38d6b | 2001-07-20 18:00:00 +0000 | [diff] [blame] | 49 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 50 | WINE_DEFAULT_DEBUG_CHANNEL(shell); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 51 | |
Alexandre Julliard | 366fcaf | 2008-12-03 12:09:17 +0100 | [diff] [blame] | 52 | extern INT WINAPI SHStringFromGUIDW(REFGUID guid, LPWSTR lpszDest, INT cchMax); /* shlwapi.24 */ |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 53 | |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 54 | /************************************************************************** |
| 55 | * Default ClassFactory types |
| 56 | */ |
| 57 | typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject); |
Andrew Talbot | dfe3d5b | 2007-02-06 22:05:10 +0000 | [diff] [blame] | 58 | static IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst); |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 59 | |
Frédéric Delanoy | 7e30960 | 2011-08-02 22:20:32 +0200 | [diff] [blame] | 60 | /* this table contains all CLSIDs of shell32 objects */ |
Alexandre Julliard | 7a0396a | 2006-06-12 13:44:21 +0200 | [diff] [blame] | 61 | static const struct { |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 62 | REFIID riid; |
| 63 | LPFNCREATEINSTANCE lpfnCI; |
Martin Fuchs | dd46d6d | 2004-03-27 01:42:22 +0000 | [diff] [blame] | 64 | } InterfaceTable[] = { |
Nikolay Sivov | da32b07 | 2010-04-06 11:55:10 +0400 | [diff] [blame] | 65 | |
| 66 | {&CLSID_AutoComplete, IAutoComplete_Constructor}, |
| 67 | {&CLSID_ControlPanel, IControlPanel_Constructor}, |
| 68 | {&CLSID_DragDropHelper, IDropTargetHelper_Constructor}, |
| 69 | {&CLSID_FolderShortcut, FolderShortcut_Constructor}, |
Andrew Talbot | 93f656b | 2008-07-06 13:00:42 +0100 | [diff] [blame] | 70 | {&CLSID_MyComputer, ISF_MyComputer_Constructor}, |
Nikolay Sivov | da32b07 | 2010-04-06 11:55:10 +0400 | [diff] [blame] | 71 | {&CLSID_MyDocuments, MyDocuments_Constructor}, |
Andrew Talbot | 93f656b | 2008-07-06 13:00:42 +0100 | [diff] [blame] | 72 | {&CLSID_NetworkPlaces, ISF_NetworkPlaces_Constructor}, |
Nikolay Sivov | da32b07 | 2010-04-06 11:55:10 +0400 | [diff] [blame] | 73 | {&CLSID_Printers, Printers_Constructor}, |
| 74 | {&CLSID_QueryAssociations, QueryAssociations_Constructor}, |
| 75 | {&CLSID_RecycleBin, RecycleBin_Constructor}, |
Andrew Talbot | 93f656b | 2008-07-06 13:00:42 +0100 | [diff] [blame] | 76 | {&CLSID_ShellDesktop, ISF_Desktop_Constructor}, |
Nikolay Sivov | da32b07 | 2010-04-06 11:55:10 +0400 | [diff] [blame] | 77 | {&CLSID_ShellFSFolder, IFSFolder_Constructor}, |
Vincent Povirk | e69c663 | 2009-02-18 12:32:32 -0600 | [diff] [blame] | 78 | {&CLSID_ShellItem, IShellItem_Constructor}, |
Andrew Talbot | 93f656b | 2008-07-06 13:00:42 +0100 | [diff] [blame] | 79 | {&CLSID_ShellLink, IShellLink_Constructor}, |
Andrew Talbot | 93f656b | 2008-07-06 13:00:42 +0100 | [diff] [blame] | 80 | {&CLSID_UnixDosFolder, UnixDosFolder_Constructor}, |
Nikolay Sivov | da32b07 | 2010-04-06 11:55:10 +0400 | [diff] [blame] | 81 | {&CLSID_UnixFolder, UnixFolder_Constructor}, |
David Hedberg | d662696 | 2010-08-20 07:45:56 +0200 | [diff] [blame] | 82 | {&CLSID_ExplorerBrowser,ExplorerBrowser_Constructor}, |
Hans Leidekker | e7e1ec6 | 2010-09-23 09:25:57 +0200 | [diff] [blame] | 83 | {&CLSID_KnownFolderManager, KnownFolderManager_Constructor}, |
Alexander Morozov | 8b30849 | 2011-01-18 21:35:41 +0300 | [diff] [blame] | 84 | {&CLSID_Shell, IShellDispatch_Constructor}, |
Nikolay Sivov | da32b07 | 2010-04-06 11:55:10 +0400 | [diff] [blame] | 85 | {NULL, NULL} |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
Mikołaj Zalewski | 8fcc0bd | 2006-09-08 21:11:01 +0200 | [diff] [blame] | 88 | /************************************************************************* |
| 89 | * SHCoCreateInstance [SHELL32.102] |
| 90 | * |
| 91 | * Equivalent to CoCreateInstance. Under Windows 9x this function could sometimes |
| 92 | * use the shell32 built-in "mini-COM" without the need to load ole32.dll - see |
| 93 | * SHLoadOLE for details. |
| 94 | * |
| 95 | * Under wine if a "LoadWithoutCOM" value is present or the object resides in |
| 96 | * shell32.dll the function will load the object manually without the help of ole32 |
| 97 | * |
| 98 | * NOTES |
| 99 | * exported by ordinal |
| 100 | * |
| 101 | * SEE ALSO |
| 102 | * CoCreateInstace, SHLoadOLE |
| 103 | */ |
Vincent Béron | 6c644d6 | 2004-10-19 23:55:15 +0000 | [diff] [blame] | 104 | HRESULT WINAPI SHCoCreateInstance( |
Alexandre Julliard | 72ecbb0 | 2004-01-06 20:42:47 +0000 | [diff] [blame] | 105 | LPCWSTR aclsid, |
| 106 | const CLSID *clsid, |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 107 | LPUNKNOWN pUnkOuter, |
Juergen Schmied | 61adb76 | 1999-07-10 11:48:15 +0000 | [diff] [blame] | 108 | REFIID refiid, |
| 109 | LPVOID *ppv) |
| 110 | { |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 111 | DWORD hres; |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 112 | IID iid; |
Andrew Talbot | 2f4bb7b | 2006-11-14 22:13:36 +0000 | [diff] [blame] | 113 | const CLSID * myclsid = clsid; |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 114 | WCHAR sKeyName[MAX_PATH]; |
| 115 | const WCHAR sCLSID[7] = {'C','L','S','I','D','\\','\0'}; |
| 116 | WCHAR sClassID[60]; |
| 117 | const WCHAR sInProcServer32[16] ={'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2','\0'}; |
| 118 | const WCHAR sLoadWithoutCOM[15] ={'L','o','a','d','W','i','t','h','o','u','t','C','O','M','\0'}; |
| 119 | WCHAR sDllPath[MAX_PATH]; |
Alexandre Julliard | d7892cc | 2007-10-18 15:15:40 +0200 | [diff] [blame] | 120 | HKEY hKey = 0; |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 121 | DWORD dwSize; |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 122 | IClassFactory * pcf = NULL; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 123 | |
Juergen Schmied | 1e5ec88 | 2002-07-24 01:56:03 +0000 | [diff] [blame] | 124 | if(!ppv) return E_POINTER; |
| 125 | *ppv=NULL; |
| 126 | |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 127 | /* if the clsid is a string, convert it */ |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 128 | if (!clsid) |
| 129 | { |
| 130 | if (!aclsid) return REGDB_E_CLASSNOTREG; |
Alexandre Julliard | 72ecbb0 | 2004-01-06 20:42:47 +0000 | [diff] [blame] | 131 | SHCLSIDFromStringW(aclsid, &iid); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 132 | myclsid = &iid; |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 133 | } |
Juergen Schmied | 61adb76 | 1999-07-10 11:48:15 +0000 | [diff] [blame] | 134 | |
Juergen Schmied | 1e5ec88 | 2002-07-24 01:56:03 +0000 | [diff] [blame] | 135 | TRACE("(%p,%s,unk:%p,%s,%p)\n", |
| 136 | aclsid,shdebugstr_guid(myclsid),pUnkOuter,shdebugstr_guid(refiid),ppv); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 137 | |
Alexandre Julliard | d7892cc | 2007-10-18 15:15:40 +0200 | [diff] [blame] | 138 | if (SUCCEEDED(DllGetClassObject(myclsid, &IID_IClassFactory,(LPVOID*)&pcf))) |
| 139 | { |
| 140 | hres = IClassFactory_CreateInstance(pcf, pUnkOuter, refiid, ppv); |
| 141 | IClassFactory_Release(pcf); |
| 142 | goto end; |
| 143 | } |
| 144 | |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 145 | /* we look up the dll path in the registry */ |
Alexandre Julliard | 366fcaf | 2008-12-03 12:09:17 +0100 | [diff] [blame] | 146 | SHStringFromGUIDW(myclsid, sClassID, sizeof(sClassID)/sizeof(WCHAR)); |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 147 | lstrcpyW(sKeyName, sCLSID); |
| 148 | lstrcatW(sKeyName, sClassID); |
| 149 | lstrcatW(sKeyName, sInProcServer32); |
| 150 | |
Alexandre Julliard | d7892cc | 2007-10-18 15:15:40 +0200 | [diff] [blame] | 151 | if (RegOpenKeyExW(HKEY_CLASSES_ROOT, sKeyName, 0, KEY_READ, &hKey)) |
| 152 | return E_ACCESSDENIED; |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 153 | |
Alexandre Julliard | d7892cc | 2007-10-18 15:15:40 +0200 | [diff] [blame] | 154 | /* if a special registry key is set, we load a shell extension without help of OLE32 */ |
| 155 | if (!SHQueryValueExW(hKey, sLoadWithoutCOM, 0, 0, 0, 0)) |
| 156 | { |
Francois Gouget | 93416cd | 2005-03-23 13:15:18 +0000 | [diff] [blame] | 157 | /* load an external dll without ole32 */ |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 158 | HANDLE hLibrary; |
| 159 | typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv); |
| 160 | DllGetClassObjectFunc DllGetClassObject; |
| 161 | |
Alexandre Julliard | d7892cc | 2007-10-18 15:15:40 +0200 | [diff] [blame] | 162 | dwSize = sizeof(sDllPath); |
| 163 | SHQueryValueExW(hKey, NULL, 0,0, sDllPath, &dwSize ); |
| 164 | |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 165 | if ((hLibrary = LoadLibraryExW(sDllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH)) == 0) { |
| 166 | ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath)); |
| 167 | hres = E_ACCESSDENIED; |
| 168 | goto end; |
| 169 | } else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"))) { |
| 170 | ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath)); |
| 171 | FreeLibrary( hLibrary ); |
| 172 | hres = E_ACCESSDENIED; |
| 173 | goto end; |
Michael Stefaniuc | f6baf97 | 2008-10-08 01:32:38 +0200 | [diff] [blame] | 174 | } else if (FAILED(hres = DllGetClassObject(myclsid, &IID_IClassFactory, (LPVOID*)&pcf))) { |
Hans Leidekker | 89e1d29 | 2006-10-07 20:18:14 +0200 | [diff] [blame] | 175 | TRACE("GetClassObject failed 0x%08x\n", hres); |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 176 | goto end; |
| 177 | } |
| 178 | |
Alexandre Julliard | d7892cc | 2007-10-18 15:15:40 +0200 | [diff] [blame] | 179 | hres = IClassFactory_CreateInstance(pcf, pUnkOuter, refiid, ppv); |
| 180 | IClassFactory_Release(pcf); |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 181 | } else { |
| 182 | |
Francois Gouget | 93416cd | 2005-03-23 13:15:18 +0000 | [diff] [blame] | 183 | /* load an external dll in the usual way */ |
Robert Shearman | 77b7f95 | 2004-06-18 00:23:38 +0000 | [diff] [blame] | 184 | hres = CoCreateInstance(myclsid, pUnkOuter, CLSCTX_INPROC_SERVER, refiid, ppv); |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 185 | } |
| 186 | |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 187 | end: |
Alexandre Julliard | d7892cc | 2007-10-18 15:15:40 +0200 | [diff] [blame] | 188 | if (hKey) RegCloseKey(hKey); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 189 | if(hres!=S_OK) |
| 190 | { |
Hans Leidekker | 89e1d29 | 2006-10-07 20:18:14 +0200 | [diff] [blame] | 191 | ERR("failed (0x%08x) to create CLSID:%s IID:%s\n", |
Juergen Schmied | 1e5ec88 | 2002-07-24 01:56:03 +0000 | [diff] [blame] | 192 | hres, shdebugstr_guid(myclsid), shdebugstr_guid(refiid)); |
Juergen Schmied | afe53ed | 1999-11-23 22:31:18 +0000 | [diff] [blame] | 193 | ERR("class not found in registry\n"); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 194 | } |
| 195 | |
Juergen Schmied | afe53ed | 1999-11-23 22:31:18 +0000 | [diff] [blame] | 196 | TRACE("-- instance: %p\n",*ppv); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 197 | return hres; |
| 198 | } |
| 199 | |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 200 | /************************************************************************* |
Francois Gouget | d3aa231 | 2006-02-07 21:18:12 +0100 | [diff] [blame] | 201 | * DllGetClassObject [SHELL32.@] |
| 202 | * SHDllGetClassObject [SHELL32.128] |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 203 | */ |
Alexandre Julliard | d37f0ab | 2005-08-08 17:35:28 +0000 | [diff] [blame] | 204 | HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 205 | { |
| 206 | HRESULT hres = E_OUTOFMEMORY; |
| 207 | IClassFactory * pcf = NULL; |
| 208 | int i; |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 209 | |
Juergen Schmied | 1e5ec88 | 2002-07-24 01:56:03 +0000 | [diff] [blame] | 210 | TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid),shdebugstr_guid(iid)); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 211 | |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 212 | if (!ppv) return E_INVALIDARG; |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 213 | *ppv = NULL; |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 214 | |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 215 | /* search our internal interface table */ |
| 216 | for(i=0;InterfaceTable[i].riid;i++) { |
| 217 | if(IsEqualIID(InterfaceTable[i].riid, rclsid)) { |
| 218 | TRACE("index[%u]\n", i); |
Juergen Schmied | 1e5ec88 | 2002-07-24 01:56:03 +0000 | [diff] [blame] | 219 | pcf = IDefClF_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL); |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 220 | } |
| 221 | } |
Juergen Schmied | cd390f3 | 1998-12-14 14:51:27 +0000 | [diff] [blame] | 222 | |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 223 | if (!pcf) { |
Juergen Schmied | 1e5ec88 | 2002-07-24 01:56:03 +0000 | [diff] [blame] | 224 | FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid)); |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 225 | return CLASS_E_CLASSNOTAVAILABLE; |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 226 | } |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 227 | |
| 228 | hres = IClassFactory_QueryInterface(pcf, iid, ppv); |
| 229 | IClassFactory_Release(pcf); |
| 230 | |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 231 | TRACE("-- pointer to class factory: %p\n",*ppv); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 232 | return hres; |
| 233 | } |
| 234 | |
| 235 | /************************************************************************* |
Juergen Schmied | b18f3d6 | 1999-04-01 10:23:09 +0000 | [diff] [blame] | 236 | * SHCLSIDFromString [SHELL32.147] |
| 237 | * |
Mikołaj Zalewski | 8fcc0bd | 2006-09-08 21:11:01 +0200 | [diff] [blame] | 238 | * Under Windows 9x this was an ANSI version of CLSIDFromString. It also allowed |
| 239 | * to avoid dependency on ole32.dll (see SHLoadOLE for details). |
| 240 | * |
| 241 | * Under Windows NT/2000/XP this is equivalent to CLSIDFromString |
| 242 | * |
Juergen Schmied | b18f3d6 | 1999-04-01 10:23:09 +0000 | [diff] [blame] | 243 | * NOTES |
| 244 | * exported by ordinal |
Mikołaj Zalewski | 8fcc0bd | 2006-09-08 21:11:01 +0200 | [diff] [blame] | 245 | * |
| 246 | * SEE ALSO |
| 247 | * CLSIDFromString, SHLoadOLE |
Juergen Schmied | b18f3d6 | 1999-04-01 10:23:09 +0000 | [diff] [blame] | 248 | */ |
Patrik Stridvall | bc38d6b | 2001-07-20 18:00:00 +0000 | [diff] [blame] | 249 | DWORD WINAPI SHCLSIDFromStringA (LPCSTR clsid, CLSID *id) |
Juergen Schmied | b18f3d6 | 1999-04-01 10:23:09 +0000 | [diff] [blame] | 250 | { |
Alexandre Julliard | 9179103 | 2000-06-23 16:13:33 +0000 | [diff] [blame] | 251 | WCHAR buffer[40]; |
| 252 | TRACE("(%p(%s) %p)\n", clsid, clsid, id); |
| 253 | if (!MultiByteToWideChar( CP_ACP, 0, clsid, -1, buffer, sizeof(buffer)/sizeof(WCHAR) )) |
| 254 | return CO_E_CLASSSTRING; |
| 255 | return CLSIDFromString( buffer, id ); |
Juergen Schmied | b18f3d6 | 1999-04-01 10:23:09 +0000 | [diff] [blame] | 256 | } |
Alexandre Julliard | 72ecbb0 | 2004-01-06 20:42:47 +0000 | [diff] [blame] | 257 | DWORD WINAPI SHCLSIDFromStringW (LPCWSTR clsid, CLSID *id) |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 258 | { |
| 259 | TRACE("(%p(%s) %p)\n", clsid, debugstr_w(clsid), id); |
Mikhail Maroukhine | f930c87 | 2010-03-26 23:59:50 +0600 | [diff] [blame] | 260 | return CLSIDFromString(clsid, id); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 261 | } |
Andrew Talbot | c289a33 | 2007-09-13 09:42:50 +0100 | [diff] [blame] | 262 | DWORD WINAPI SHCLSIDFromStringAW (LPCVOID clsid, CLSID *id) |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 263 | { |
Alexandre Julliard | d586dc9 | 2000-08-14 14:35:01 +0000 | [diff] [blame] | 264 | if (SHELL_OsIsUnicode()) |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 265 | return SHCLSIDFromStringW (clsid, id); |
| 266 | return SHCLSIDFromStringA (clsid, id); |
| 267 | } |
Juergen Schmied | b18f3d6 | 1999-04-01 10:23:09 +0000 | [diff] [blame] | 268 | |
| 269 | /************************************************************************* |
Patrik Stridvall | 8b216b3 | 2001-06-19 18:20:47 +0000 | [diff] [blame] | 270 | * SHGetMalloc [SHELL32.@] |
Jon Griffiths | cd4234a | 2003-03-18 18:35:48 +0000 | [diff] [blame] | 271 | * |
Mikołaj Zalewski | 8fcc0bd | 2006-09-08 21:11:01 +0200 | [diff] [blame] | 272 | * Equivalent to CoGetMalloc(MEMCTX_TASK, ...). Under Windows 9x this function |
| 273 | * could use the shell32 built-in "mini-COM" without the need to load ole32.dll - |
| 274 | * see SHLoadOLE for details. |
Jon Griffiths | cd4234a | 2003-03-18 18:35:48 +0000 | [diff] [blame] | 275 | * |
| 276 | * PARAMS |
| 277 | * lpmal [O] Destination for IMalloc interface. |
| 278 | * |
| 279 | * RETURNS |
| 280 | * Success: S_OK. lpmal contains the shells IMalloc interface. |
| 281 | * Failure. An HRESULT error code. |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 282 | * |
Mikołaj Zalewski | 8fcc0bd | 2006-09-08 21:11:01 +0200 | [diff] [blame] | 283 | * SEE ALSO |
| 284 | * CoGetMalloc, SHLoadOLE |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 285 | */ |
Dimitrie O. Paun | dfa6b12 | 2003-01-03 03:07:21 +0000 | [diff] [blame] | 286 | HRESULT WINAPI SHGetMalloc(LPMALLOC *lpmal) |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 287 | { |
| 288 | TRACE("(%p)\n", lpmal); |
Mikołaj Zalewski | 455991a | 2006-09-08 21:14:52 +0200 | [diff] [blame] | 289 | return CoGetMalloc(MEMCTX_TASK, lpmal); |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | /************************************************************************* |
| 293 | * SHAlloc [SHELL32.196] |
| 294 | * |
Mikołaj Zalewski | 8fcc0bd | 2006-09-08 21:11:01 +0200 | [diff] [blame] | 295 | * Equivalent to CoTaskMemAlloc. Under Windows 9x this function could use |
| 296 | * the shell32 built-in "mini-COM" without the need to load ole32.dll - |
| 297 | * see SHLoadOLE for details. |
| 298 | * |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 299 | * NOTES |
| 300 | * exported by ordinal |
Mikołaj Zalewski | 8fcc0bd | 2006-09-08 21:11:01 +0200 | [diff] [blame] | 301 | * |
| 302 | * SEE ALSO |
| 303 | * CoTaskMemAlloc, SHLoadOLE |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 304 | */ |
| 305 | LPVOID WINAPI SHAlloc(DWORD len) |
| 306 | { |
Mikołaj Zalewski | 455991a | 2006-09-08 21:14:52 +0200 | [diff] [blame] | 307 | LPVOID ret; |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 308 | |
Mikołaj Zalewski | 455991a | 2006-09-08 21:14:52 +0200 | [diff] [blame] | 309 | ret = CoTaskMemAlloc(len); |
Hans Leidekker | 89e1d29 | 2006-10-07 20:18:14 +0200 | [diff] [blame] | 310 | TRACE("%u bytes at %p\n",len, ret); |
Mikołaj Zalewski | 455991a | 2006-09-08 21:14:52 +0200 | [diff] [blame] | 311 | return ret; |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | /************************************************************************* |
| 315 | * SHFree [SHELL32.195] |
| 316 | * |
Mikołaj Zalewski | 8fcc0bd | 2006-09-08 21:11:01 +0200 | [diff] [blame] | 317 | * Equivalent to CoTaskMemFree. Under Windows 9x this function could use |
| 318 | * the shell32 built-in "mini-COM" without the need to load ole32.dll - |
| 319 | * see SHLoadOLE for details. |
| 320 | * |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 321 | * NOTES |
| 322 | * exported by ordinal |
Mikołaj Zalewski | 8fcc0bd | 2006-09-08 21:11:01 +0200 | [diff] [blame] | 323 | * |
| 324 | * SEE ALSO |
| 325 | * CoTaskMemFree, SHLoadOLE |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 326 | */ |
| 327 | void WINAPI SHFree(LPVOID pv) |
| 328 | { |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 329 | TRACE("%p\n",pv); |
Mikołaj Zalewski | 455991a | 2006-09-08 21:14:52 +0200 | [diff] [blame] | 330 | CoTaskMemFree(pv); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 331 | } |
| 332 | |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 333 | /************************************************************************* |
Patrik Stridvall | 8b216b3 | 2001-06-19 18:20:47 +0000 | [diff] [blame] | 334 | * SHGetDesktopFolder [SHELL32.@] |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 335 | */ |
Ge van Geldorp | c390bb2 | 2004-06-28 20:32:53 +0000 | [diff] [blame] | 336 | HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf) |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 337 | { |
Nikolay Sivov | 0f794f9 | 2010-03-21 04:42:59 +0300 | [diff] [blame] | 338 | HRESULT hres; |
| 339 | |
| 340 | TRACE("(%p)\n", psf); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 341 | |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 342 | if(!psf) return E_INVALIDARG; |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 343 | |
Nikolay Sivov | 0f794f9 | 2010-03-21 04:42:59 +0300 | [diff] [blame] | 344 | *psf = NULL; |
| 345 | hres = ISF_Desktop_Constructor(NULL, &IID_IShellFolder, (LPVOID*)psf); |
| 346 | |
| 347 | TRACE("-- %p->(%p) 0x%08x\n", psf, *psf, hres); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 348 | return hres; |
| 349 | } |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 350 | /************************************************************************** |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 351 | * Default ClassFactory Implementation |
| 352 | * |
| 353 | * SHCreateDefClassObject |
| 354 | * |
| 355 | * NOTES |
Francois Gouget | 93416cd | 2005-03-23 13:15:18 +0000 | [diff] [blame] | 356 | * Helper function for dlls without their own classfactory. |
| 357 | * A generic classfactory is returned. |
| 358 | * When the CreateInstance of the cf is called the callback is executed. |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 359 | */ |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 360 | |
| 361 | typedef struct |
| 362 | { |
Michael Stefaniuc | 151b351 | 2010-12-07 11:09:48 +0100 | [diff] [blame] | 363 | IClassFactory IClassFactory_iface; |
Mike McCormack | e28c014 | 2005-07-03 12:03:35 +0000 | [diff] [blame] | 364 | LONG ref; |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 365 | CLSID *rclsid; |
| 366 | LPFNCREATEINSTANCE lpfnCI; |
| 367 | const IID * riidInst; |
Mike McCormack | e28c014 | 2005-07-03 12:03:35 +0000 | [diff] [blame] | 368 | LONG * pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */ |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 369 | } IDefClFImpl; |
| 370 | |
Michael Stefaniuc | 151b351 | 2010-12-07 11:09:48 +0100 | [diff] [blame] | 371 | static inline IDefClFImpl *impl_from_IClassFactory(IClassFactory *iface) |
| 372 | { |
| 373 | return CONTAINING_RECORD(iface, IDefClFImpl, IClassFactory_iface); |
| 374 | } |
| 375 | |
Dmitry Timoshkov | eba47f1 | 2005-06-06 19:50:35 +0000 | [diff] [blame] | 376 | static const IClassFactoryVtbl dclfvt; |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 377 | |
| 378 | /************************************************************************** |
| 379 | * IDefClF_fnConstructor |
| 380 | */ |
| 381 | |
Andrew Talbot | dfe3d5b | 2007-02-06 22:05:10 +0000 | [diff] [blame] | 382 | static IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst) |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 383 | { |
| 384 | IDefClFImpl* lpclf; |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 385 | |
Mike McCormack | 17c3106 | 2005-03-21 11:25:13 +0000 | [diff] [blame] | 386 | lpclf = HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl)); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 387 | lpclf->ref = 1; |
Michael Stefaniuc | 151b351 | 2010-12-07 11:09:48 +0100 | [diff] [blame] | 388 | lpclf->IClassFactory_iface.lpVtbl = &dclfvt; |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 389 | lpclf->lpfnCI = lpfnCI; |
| 390 | lpclf->pcRefDll = pcRefDll; |
| 391 | |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 392 | if (pcRefDll) InterlockedIncrement(pcRefDll); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 393 | lpclf->riidInst = riidInst; |
| 394 | |
Juergen Schmied | 1e5ec88 | 2002-07-24 01:56:03 +0000 | [diff] [blame] | 395 | TRACE("(%p)%s\n",lpclf, shdebugstr_guid(riidInst)); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 396 | return (LPCLASSFACTORY)lpclf; |
| 397 | } |
| 398 | /************************************************************************** |
| 399 | * IDefClF_fnQueryInterface |
| 400 | */ |
| 401 | static HRESULT WINAPI IDefClF_fnQueryInterface( |
| 402 | LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj) |
| 403 | { |
Michael Stefaniuc | 151b351 | 2010-12-07 11:09:48 +0100 | [diff] [blame] | 404 | IDefClFImpl *This = impl_from_IClassFactory(iface); |
Alexandre Julliard | 681c75b | 2000-01-18 05:09:49 +0000 | [diff] [blame] | 405 | |
Juergen Schmied | 1e5ec88 | 2002-07-24 01:56:03 +0000 | [diff] [blame] | 406 | TRACE("(%p)->(%s)\n",This,shdebugstr_guid(riid)); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 407 | |
| 408 | *ppvObj = NULL; |
| 409 | |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 410 | if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory)) { |
| 411 | *ppvObj = This; |
| 412 | InterlockedIncrement(&This->ref); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 413 | return S_OK; |
| 414 | } |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 415 | |
| 416 | TRACE("-- E_NOINTERFACE\n"); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 417 | return E_NOINTERFACE; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 418 | } |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 419 | /****************************************************************************** |
| 420 | * IDefClF_fnAddRef |
| 421 | */ |
| 422 | static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface) |
| 423 | { |
Michael Stefaniuc | 151b351 | 2010-12-07 11:09:48 +0100 | [diff] [blame] | 424 | IDefClFImpl *This = impl_from_IClassFactory(iface); |
James Hawkins | ba92d29 | 2005-01-14 16:02:20 +0000 | [diff] [blame] | 425 | ULONG refCount = InterlockedIncrement(&This->ref); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 426 | |
Hans Leidekker | 89e1d29 | 2006-10-07 20:18:14 +0200 | [diff] [blame] | 427 | TRACE("(%p)->(count=%u)\n", This, refCount - 1); |
James Hawkins | ba92d29 | 2005-01-14 16:02:20 +0000 | [diff] [blame] | 428 | |
| 429 | return refCount; |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 430 | } |
| 431 | /****************************************************************************** |
| 432 | * IDefClF_fnRelease |
| 433 | */ |
| 434 | static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface) |
| 435 | { |
Michael Stefaniuc | 151b351 | 2010-12-07 11:09:48 +0100 | [diff] [blame] | 436 | IDefClFImpl *This = impl_from_IClassFactory(iface); |
James Hawkins | ba92d29 | 2005-01-14 16:02:20 +0000 | [diff] [blame] | 437 | ULONG refCount = InterlockedDecrement(&This->ref); |
Michael Stefaniuc | 151b351 | 2010-12-07 11:09:48 +0100 | [diff] [blame] | 438 | |
Hans Leidekker | 89e1d29 | 2006-10-07 20:18:14 +0200 | [diff] [blame] | 439 | TRACE("(%p)->(count=%u)\n", This, refCount + 1); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 440 | |
James Hawkins | ba92d29 | 2005-01-14 16:02:20 +0000 | [diff] [blame] | 441 | if (!refCount) |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 442 | { |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 443 | if (This->pcRefDll) InterlockedDecrement(This->pcRefDll); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 444 | |
| 445 | TRACE("-- destroying IClassFactory(%p)\n",This); |
| 446 | HeapFree(GetProcessHeap(),0,This); |
| 447 | return 0; |
| 448 | } |
James Hawkins | ba92d29 | 2005-01-14 16:02:20 +0000 | [diff] [blame] | 449 | return refCount; |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 450 | } |
| 451 | /****************************************************************************** |
| 452 | * IDefClF_fnCreateInstance |
| 453 | */ |
| 454 | static HRESULT WINAPI IDefClF_fnCreateInstance( |
| 455 | LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject) |
| 456 | { |
Michael Stefaniuc | 151b351 | 2010-12-07 11:09:48 +0100 | [diff] [blame] | 457 | IDefClFImpl *This = impl_from_IClassFactory(iface); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 458 | |
Juergen Schmied | 1e5ec88 | 2002-07-24 01:56:03 +0000 | [diff] [blame] | 459 | TRACE("%p->(%p,%s,%p)\n",This,pUnkOuter,shdebugstr_guid(riid),ppvObject); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 460 | |
| 461 | *ppvObject = NULL; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 462 | |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 463 | if ( This->riidInst==NULL || |
| 464 | IsEqualCLSID(riid, This->riidInst) || |
| 465 | IsEqualCLSID(riid, &IID_IUnknown) ) |
| 466 | { |
| 467 | return This->lpfnCI(pUnkOuter, riid, ppvObject); |
| 468 | } |
| 469 | |
Juergen Schmied | 1e5ec88 | 2002-07-24 01:56:03 +0000 | [diff] [blame] | 470 | ERR("unknown IID requested %s\n",shdebugstr_guid(riid)); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 471 | return E_NOINTERFACE; |
| 472 | } |
| 473 | /****************************************************************************** |
| 474 | * IDefClF_fnLockServer |
| 475 | */ |
| 476 | static HRESULT WINAPI IDefClF_fnLockServer(LPCLASSFACTORY iface, BOOL fLock) |
| 477 | { |
Michael Stefaniuc | 151b351 | 2010-12-07 11:09:48 +0100 | [diff] [blame] | 478 | IDefClFImpl *This = impl_from_IClassFactory(iface); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 479 | TRACE("%p->(0x%x), not implemented\n",This, fLock); |
| 480 | return E_NOTIMPL; |
| 481 | } |
| 482 | |
Dmitry Timoshkov | eba47f1 | 2005-06-06 19:50:35 +0000 | [diff] [blame] | 483 | static const IClassFactoryVtbl dclfvt = |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 484 | { |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 485 | IDefClF_fnQueryInterface, |
| 486 | IDefClF_fnAddRef, |
| 487 | IDefClF_fnRelease, |
| 488 | IDefClF_fnCreateInstance, |
| 489 | IDefClF_fnLockServer |
| 490 | }; |
| 491 | |
| 492 | /****************************************************************************** |
| 493 | * SHCreateDefClassObject [SHELL32.70] |
| 494 | */ |
| 495 | HRESULT WINAPI SHCreateDefClassObject( |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 496 | REFIID riid, |
| 497 | LPVOID* ppv, |
Patrik Stridvall | 2b3aa61 | 2000-12-01 23:58:28 +0000 | [diff] [blame] | 498 | LPFNCREATEINSTANCE lpfnCI, /* [in] create instance callback entry */ |
Patrik Stridvall | bc38d6b | 2001-07-20 18:00:00 +0000 | [diff] [blame] | 499 | LPDWORD pcRefDll, /* [in/out] ref count of the dll */ |
Patrik Stridvall | 2b3aa61 | 2000-12-01 23:58:28 +0000 | [diff] [blame] | 500 | REFIID riidInst) /* [in] optional interface to the instance */ |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 501 | { |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 502 | IClassFactory * pcf; |
| 503 | |
Juergen Schmied | 1e5ec88 | 2002-07-24 01:56:03 +0000 | [diff] [blame] | 504 | TRACE("%s %p %p %p %s\n", |
| 505 | shdebugstr_guid(riid), ppv, lpfnCI, pcRefDll, shdebugstr_guid(riidInst)); |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 506 | |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 507 | if (! IsEqualCLSID(riid, &IID_IClassFactory) ) return E_NOINTERFACE; |
Mike McCormack | eafa666 | 2005-08-22 09:26:53 +0000 | [diff] [blame] | 508 | if (! (pcf = IDefClF_fnConstructor(lpfnCI, (PLONG)pcRefDll, riidInst))) return E_OUTOFMEMORY; |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 509 | *ppv = pcf; |
| 510 | return NOERROR; |
Juergen Schmied | 6d28b6e | 1999-07-25 12:22:13 +0000 | [diff] [blame] | 511 | } |
| 512 | |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 513 | /************************************************************************* |
Martin Fuchs | d3b5018 | 2005-04-13 15:17:16 +0000 | [diff] [blame] | 514 | * DragAcceptFiles [SHELL32.@] |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 515 | */ |
| 516 | void WINAPI DragAcceptFiles(HWND hWnd, BOOL b) |
| 517 | { |
| 518 | LONG exstyle; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 519 | |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 520 | if( !IsWindow(hWnd) ) return; |
| 521 | exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE); |
| 522 | if (b) |
| 523 | exstyle |= WS_EX_ACCEPTFILES; |
| 524 | else |
| 525 | exstyle &= ~WS_EX_ACCEPTFILES; |
| 526 | SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle); |
| 527 | } |
| 528 | |
| 529 | /************************************************************************* |
Martin Fuchs | d3b5018 | 2005-04-13 15:17:16 +0000 | [diff] [blame] | 530 | * DragFinish [SHELL32.@] |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 531 | */ |
| 532 | void WINAPI DragFinish(HDROP h) |
| 533 | { |
| 534 | TRACE("\n"); |
Michael Stefaniuc | 6c54ad3 | 2009-02-18 22:46:39 +0100 | [diff] [blame] | 535 | GlobalFree(h); |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | /************************************************************************* |
Martin Fuchs | d3b5018 | 2005-04-13 15:17:16 +0000 | [diff] [blame] | 539 | * DragQueryPoint [SHELL32.@] |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 540 | */ |
| 541 | BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p) |
| 542 | { |
Alexandre Julliard | 60e1752 | 2000-09-25 23:56:41 +0000 | [diff] [blame] | 543 | DROPFILES *lpDropFileStruct; |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 544 | BOOL bRet; |
| 545 | |
| 546 | TRACE("\n"); |
| 547 | |
Michael Stefaniuc | b7de266 | 2008-11-05 23:00:50 +0100 | [diff] [blame] | 548 | lpDropFileStruct = GlobalLock(hDrop); |
Alexandre Julliard | 60e1752 | 2000-09-25 23:56:41 +0000 | [diff] [blame] | 549 | |
| 550 | *p = lpDropFileStruct->pt; |
| 551 | bRet = lpDropFileStruct->fNC; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 552 | |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 553 | GlobalUnlock(hDrop); |
| 554 | return bRet; |
| 555 | } |
| 556 | |
| 557 | /************************************************************************* |
Martin Fuchs | d3b5018 | 2005-04-13 15:17:16 +0000 | [diff] [blame] | 558 | * DragQueryFileA [SHELL32.@] |
Markus Amsler | 671738d | 2005-11-10 11:15:22 +0000 | [diff] [blame] | 559 | * DragQueryFile [SHELL32.@] |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 560 | */ |
| 561 | UINT WINAPI DragQueryFileA( |
| 562 | HDROP hDrop, |
| 563 | UINT lFile, |
| 564 | LPSTR lpszFile, |
| 565 | UINT lLength) |
| 566 | { |
| 567 | LPSTR lpDrop; |
| 568 | UINT i = 0; |
Michael Stefaniuc | b7de266 | 2008-11-05 23:00:50 +0100 | [diff] [blame] | 569 | DROPFILES *lpDropFileStruct = GlobalLock(hDrop); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 570 | |
Johan Dahlin | 991fd85 | 2002-11-21 23:56:42 +0000 | [diff] [blame] | 571 | TRACE("(%p, %x, %p, %u)\n", hDrop,lFile,lpszFile,lLength); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 572 | |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 573 | if(!lpDropFileStruct) goto end; |
| 574 | |
Alexandre Julliard | 60e1752 | 2000-09-25 23:56:41 +0000 | [diff] [blame] | 575 | lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->pFiles; |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 576 | |
Alexandre Julliard | ebe3c52 | 2004-12-09 14:07:59 +0000 | [diff] [blame] | 577 | if(lpDropFileStruct->fWide) { |
Sander van Leeuwen | ddf16e0 | 2002-06-10 02:29:09 +0000 | [diff] [blame] | 578 | LPWSTR lpszFileW = NULL; |
| 579 | |
| 580 | if(lpszFile) { |
Mike McCormack | 17c3106 | 2005-03-21 11:25:13 +0000 | [diff] [blame] | 581 | lpszFileW = HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR)); |
Sander van Leeuwen | ddf16e0 | 2002-06-10 02:29:09 +0000 | [diff] [blame] | 582 | if(lpszFileW == NULL) { |
| 583 | goto end; |
| 584 | } |
| 585 | } |
| 586 | i = DragQueryFileW(hDrop, lFile, lpszFileW, lLength); |
| 587 | |
| 588 | if(lpszFileW) { |
| 589 | WideCharToMultiByte(CP_ACP, 0, lpszFileW, -1, lpszFile, lLength, 0, NULL); |
| 590 | HeapFree(GetProcessHeap(), 0, lpszFileW); |
| 591 | } |
| 592 | goto end; |
| 593 | } |
| 594 | |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 595 | while (i++ < lFile) |
| 596 | { |
| 597 | while (*lpDrop++); /* skip filename */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 598 | if (!*lpDrop) |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 599 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 600 | i = (lFile == 0xFFFFFFFF) ? i : 0; |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 601 | goto end; |
| 602 | } |
| 603 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 604 | |
Alexandre Julliard | d586dc9 | 2000-08-14 14:35:01 +0000 | [diff] [blame] | 605 | i = strlen(lpDrop); |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 606 | if (!lpszFile ) goto end; /* needed buffer size */ |
Damjan Jovanovic | 1d5575b | 2007-07-06 07:27:56 +0200 | [diff] [blame] | 607 | lstrcpynA (lpszFile, lpDrop, lLength); |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 608 | end: |
| 609 | GlobalUnlock(hDrop); |
| 610 | return i; |
| 611 | } |
| 612 | |
| 613 | /************************************************************************* |
Martin Fuchs | d3b5018 | 2005-04-13 15:17:16 +0000 | [diff] [blame] | 614 | * DragQueryFileW [SHELL32.@] |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 615 | */ |
| 616 | UINT WINAPI DragQueryFileW( |
| 617 | HDROP hDrop, |
| 618 | UINT lFile, |
| 619 | LPWSTR lpszwFile, |
| 620 | UINT lLength) |
| 621 | { |
| 622 | LPWSTR lpwDrop; |
| 623 | UINT i = 0; |
Michael Stefaniuc | b7de266 | 2008-11-05 23:00:50 +0100 | [diff] [blame] | 624 | DROPFILES *lpDropFileStruct = GlobalLock(hDrop); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 625 | |
Johan Dahlin | 991fd85 | 2002-11-21 23:56:42 +0000 | [diff] [blame] | 626 | TRACE("(%p, %x, %p, %u)\n", hDrop,lFile,lpszwFile,lLength); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 627 | |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 628 | if(!lpDropFileStruct) goto end; |
| 629 | |
Sander van Leeuwen | b7828ac | 2002-06-02 21:23:45 +0000 | [diff] [blame] | 630 | lpwDrop = (LPWSTR) ((LPSTR)lpDropFileStruct + lpDropFileStruct->pFiles); |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 631 | |
Sander van Leeuwen | ddf16e0 | 2002-06-10 02:29:09 +0000 | [diff] [blame] | 632 | if(lpDropFileStruct->fWide == FALSE) { |
| 633 | LPSTR lpszFileA = NULL; |
Juergen Schmied | 23b8087 | 2002-07-02 02:05:17 +0000 | [diff] [blame] | 634 | |
Sander van Leeuwen | ddf16e0 | 2002-06-10 02:29:09 +0000 | [diff] [blame] | 635 | if(lpszwFile) { |
Mike McCormack | 17c3106 | 2005-03-21 11:25:13 +0000 | [diff] [blame] | 636 | lpszFileA = HeapAlloc(GetProcessHeap(), 0, lLength); |
Sander van Leeuwen | ddf16e0 | 2002-06-10 02:29:09 +0000 | [diff] [blame] | 637 | if(lpszFileA == NULL) { |
| 638 | goto end; |
| 639 | } |
| 640 | } |
| 641 | i = DragQueryFileA(hDrop, lFile, lpszFileA, lLength); |
| 642 | |
| 643 | if(lpszFileA) { |
| 644 | MultiByteToWideChar(CP_ACP, 0, lpszFileA, -1, lpszwFile, lLength); |
| 645 | HeapFree(GetProcessHeap(), 0, lpszFileA); |
| 646 | } |
| 647 | goto end; |
| 648 | } |
| 649 | |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 650 | i = 0; |
| 651 | while (i++ < lFile) |
| 652 | { |
| 653 | while (*lpwDrop++); /* skip filename */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 654 | if (!*lpwDrop) |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 655 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 656 | i = (lFile == 0xFFFFFFFF) ? i : 0; |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 657 | goto end; |
| 658 | } |
| 659 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 660 | |
Alexandre Julliard | 60e1752 | 2000-09-25 23:56:41 +0000 | [diff] [blame] | 661 | i = strlenW(lpwDrop); |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 662 | if ( !lpszwFile) goto end; /* needed buffer size */ |
Damjan Jovanovic | 1d5575b | 2007-07-06 07:27:56 +0200 | [diff] [blame] | 663 | lstrcpynW (lpszwFile, lpwDrop, lLength); |
Juergen Schmied | d650903 | 2000-04-28 20:19:03 +0000 | [diff] [blame] | 664 | end: |
| 665 | GlobalUnlock(hDrop); |
| 666 | return i; |
| 667 | } |
Piotr Caban | 14b13f7 | 2010-11-16 14:57:52 +0100 | [diff] [blame] | 668 | |
| 669 | /************************************************************************* |
| 670 | * SHPropStgCreate [SHELL32.685] |
| 671 | */ |
| 672 | HRESULT WINAPI SHPropStgCreate(IPropertySetStorage *psstg, REFFMTID fmtid, |
| 673 | const CLSID *pclsid, DWORD grfFlags, DWORD grfMode, |
| 674 | DWORD dwDisposition, IPropertyStorage **ppstg, UINT *puCodePage) |
| 675 | { |
Piotr Caban | bfaae9b | 2010-11-16 14:58:03 +0100 | [diff] [blame] | 676 | PROPSPEC prop; |
| 677 | PROPVARIANT ret; |
| 678 | HRESULT hres; |
| 679 | |
| 680 | TRACE("%p %s %s %x %x %x %p %p\n", psstg, debugstr_guid(fmtid), debugstr_guid(pclsid), |
| 681 | grfFlags, grfMode, dwDisposition, ppstg, puCodePage); |
| 682 | |
| 683 | hres = IPropertySetStorage_Open(psstg, fmtid, grfMode, ppstg); |
| 684 | |
| 685 | switch(dwDisposition) { |
| 686 | case CREATE_ALWAYS: |
| 687 | if(SUCCEEDED(hres)) { |
| 688 | IPropertyStorage_Release(*ppstg); |
| 689 | hres = IPropertySetStorage_Delete(psstg, fmtid); |
| 690 | if(FAILED(hres)) |
| 691 | return hres; |
| 692 | hres = E_FAIL; |
| 693 | } |
| 694 | |
| 695 | case OPEN_ALWAYS: |
| 696 | case CREATE_NEW: |
| 697 | if(FAILED(hres)) |
| 698 | hres = IPropertySetStorage_Create(psstg, fmtid, pclsid, |
| 699 | grfFlags, grfMode, ppstg); |
| 700 | |
| 701 | case OPEN_EXISTING: |
| 702 | if(FAILED(hres)) |
| 703 | return hres; |
| 704 | |
| 705 | if(puCodePage) { |
| 706 | prop.ulKind = PRSPEC_PROPID; |
| 707 | prop.u.propid = PID_CODEPAGE; |
| 708 | hres = IPropertyStorage_ReadMultiple(*ppstg, 1, &prop, &ret); |
| 709 | if(FAILED(hres) || ret.vt!=VT_I2) |
| 710 | *puCodePage = 0; |
| 711 | else |
| 712 | *puCodePage = ret.u.iVal; |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | return S_OK; |
Piotr Caban | 14b13f7 | 2010-11-16 14:57:52 +0100 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | /************************************************************************* |
| 720 | * SHPropStgReadMultiple [SHELL32.688] |
| 721 | */ |
| 722 | HRESULT WINAPI SHPropStgReadMultiple(IPropertyStorage *pps, UINT uCodePage, |
| 723 | ULONG cpspec, const PROPSPEC *rgpspec, PROPVARIANT *rgvar) |
| 724 | { |
Piotr Caban | c148c04 | 2010-11-16 14:58:13 +0100 | [diff] [blame] | 725 | STATPROPSETSTG stat; |
| 726 | HRESULT hres; |
| 727 | |
| 728 | FIXME("%p %u %u %p %p\n", pps, uCodePage, cpspec, rgpspec, rgvar); |
| 729 | |
| 730 | memset(rgvar, 0, cpspec*sizeof(PROPVARIANT)); |
| 731 | hres = IPropertyStorage_ReadMultiple(pps, cpspec, rgpspec, rgvar); |
| 732 | if(FAILED(hres)) |
| 733 | return hres; |
| 734 | |
| 735 | if(!uCodePage) { |
| 736 | PROPSPEC prop; |
| 737 | PROPVARIANT ret; |
| 738 | |
| 739 | prop.ulKind = PRSPEC_PROPID; |
| 740 | prop.u.propid = PID_CODEPAGE; |
| 741 | hres = IPropertyStorage_ReadMultiple(pps, 1, &prop, &ret); |
| 742 | if(FAILED(hres) || ret.vt!=VT_I2) |
| 743 | return S_OK; |
| 744 | |
| 745 | uCodePage = ret.u.iVal; |
| 746 | } |
| 747 | |
| 748 | hres = IPropertyStorage_Stat(pps, &stat); |
| 749 | if(FAILED(hres)) |
| 750 | return S_OK; |
| 751 | |
| 752 | /* TODO: do something with codepage and stat */ |
| 753 | return S_OK; |
Piotr Caban | 14b13f7 | 2010-11-16 14:57:52 +0100 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | /************************************************************************* |
| 757 | * SHPropStgWriteMultiple [SHELL32.689] |
| 758 | */ |
| 759 | HRESULT WINAPI SHPropStgWriteMultiple(IPropertyStorage *pps, UINT *uCodePage, |
| 760 | ULONG cpspec, const PROPSPEC *rgpspec, PROPVARIANT *rgvar, PROPID propidNameFirst) |
| 761 | { |
Piotr Caban | b490803 | 2010-11-16 14:58:22 +0100 | [diff] [blame] | 762 | STATPROPSETSTG stat; |
| 763 | UINT codepage; |
| 764 | HRESULT hres; |
| 765 | |
| 766 | FIXME("%p %p %u %p %p %d\n", pps, uCodePage, cpspec, rgpspec, rgvar, propidNameFirst); |
| 767 | |
| 768 | hres = IPropertyStorage_Stat(pps, &stat); |
| 769 | if(FAILED(hres)) |
| 770 | return hres; |
| 771 | |
| 772 | if(uCodePage && *uCodePage) |
| 773 | codepage = *uCodePage; |
| 774 | else { |
| 775 | PROPSPEC prop; |
| 776 | PROPVARIANT ret; |
| 777 | |
| 778 | prop.ulKind = PRSPEC_PROPID; |
| 779 | prop.u.propid = PID_CODEPAGE; |
| 780 | hres = IPropertyStorage_ReadMultiple(pps, 1, &prop, &ret); |
| 781 | if(FAILED(hres)) |
| 782 | return hres; |
| 783 | if(ret.vt!=VT_I2 || !ret.u.iVal) |
| 784 | return E_FAIL; |
| 785 | |
| 786 | codepage = ret.u.iVal; |
| 787 | if(uCodePage) |
| 788 | *uCodePage = codepage; |
| 789 | } |
| 790 | |
| 791 | /* TODO: do something with codepage and stat */ |
| 792 | |
| 793 | hres = IPropertyStorage_WriteMultiple(pps, cpspec, rgpspec, rgvar, propidNameFirst); |
| 794 | return hres; |
Piotr Caban | 14b13f7 | 2010-11-16 14:57:52 +0100 | [diff] [blame] | 795 | } |