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