2 * handling of SHELL32.DLL OLE-Objects
4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Juergen Schmied <juergen.schmied@metronet.de>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #include "undocshell.h"
34 #include "wine/unicode.h"
35 #include "shell32_main.h"
37 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(shell);
43 DWORD WINAPI SHCLSIDFromStringA (LPCSTR clsid, CLSID *id);
44 extern HRESULT WINAPI IFSFolder_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
46 const WCHAR sShell32[12] = {'S','H','E','L','L','3','2','.','D','L','L','\0'};
47 const WCHAR sOLE32[10] = {'O','L','E','3','2','.','D','L','L','\0'};
49 HINSTANCE hShellOle32 = 0;
50 /**************************************************************************
51 * Default ClassFactory types
53 typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject);
54 IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst);
56 /* this table contains all CLSID's of shell32 objects */
59 LPFNCREATEINSTANCE lpfnCI;
60 } InterfaceTable[4] = {
61 {&CLSID_ShellFSFolder, &IFSFolder_Constructor},
62 {&CLSID_ShellDesktop, &ISF_Desktop_Constructor},
63 {&CLSID_ShellLink, &IShellLink_Constructor},
67 /*************************************************************************
68 * __CoCreateInstance [internal]
71 * wraper for late bound call to OLE32.DLL
74 HRESULT (WINAPI *pCoCreateInstance)(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv) = NULL;
76 void * __GetExternalFunc(HMODULE * phModule, LPCWSTR szModuleName, LPCSTR szProcName)
78 if (!*phModule) *phModule = GetModuleHandleW(szModuleName);
79 if (!*phModule) *phModule = LoadLibraryW(szModuleName);
80 if (*phModule) return GetProcAddress(*phModule, szProcName);
84 HRESULT __CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
86 if(!pCoCreateInstance) pCoCreateInstance = __GetExternalFunc(&hShellOle32, sOLE32, "CoCreateInstance");
87 if(!pCoCreateInstance) return E_FAIL;
88 return pCoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, ppv);
91 /*************************************************************************
92 * SHCoCreateInstance [SHELL32.102]
98 /* FIXME: this should be SHLWAPI.24 since we can't yet import by ordinal */
100 DWORD WINAPI __SHGUIDToStringW (REFGUID guid, LPWSTR str)
102 WCHAR sFormat[52] = {'{','%','0','8','l','x','-','%','0','4',
103 'x','-','%','0','4','x','-','%','0','2',
104 'x','%','0','2','x','-','%','0','2','x',
105 '%','0','2','x','%','0','2','x','%','0',
106 '2','x','%','0','2','x','%','0','2','x',
109 return wsprintfW ( str, sFormat,
110 guid->Data1, guid->Data2, guid->Data3,
111 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
112 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
116 LRESULT WINAPI SHCoCreateInstance(
125 CLSID * myclsid = (CLSID*)clsid;
126 WCHAR sKeyName[MAX_PATH];
127 const WCHAR sCLSID[7] = {'C','L','S','I','D','\\','\0'};
129 const WCHAR sInProcServer32[16] ={'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2','\0'};
130 const WCHAR sLoadWithoutCOM[15] ={'L','o','a','d','W','i','t','h','o','u','t','C','O','M','\0'};
131 WCHAR sDllPath[MAX_PATH];
134 BOOLEAN bLoadFromShell32 = FALSE;
135 BOOLEAN bLoadWithoutCOM = FALSE;
136 IClassFactory * pcf = NULL;
138 /* if the clsid is a string, convert it */
141 if (!aclsid) return REGDB_E_CLASSNOTREG;
142 SHCLSIDFromStringA(aclsid, &iid);
146 TRACE("(%p,\n\tCLSID:\t%s, unk:%p\n\tIID:\t%s,%p)\n",
147 aclsid,debugstr_guid(myclsid),pUnkOuter,debugstr_guid(refiid),ppv);
149 /* we look up the dll path in the registry */
150 __SHGUIDToStringW(myclsid, sClassID);
151 lstrcpyW(sKeyName, sCLSID);
152 lstrcatW(sKeyName, sClassID);
153 lstrcatW(sKeyName, sInProcServer32);
155 if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, sKeyName, 0, KEY_READ, &hKey)) {
156 dwSize = sizeof(sDllPath);
157 SHQueryValueExW(hKey, NULL, 0,0, sDllPath, &dwSize );
159 /* if a special registry key is set we loading a shell extension without help of OLE32 */
160 bLoadWithoutCOM = (ERROR_SUCCESS == SHQueryValueExW(hKey, sLoadWithoutCOM, 0, 0, 0, 0));
162 /* if the com object is inside shell32 omit use of ole32 */
163 bLoadFromShell32 = (0==lstrcmpiW( PathFindFileNameW(sDllPath), sShell32));
167 /* since we can't find it in the registry we try internally */
168 bLoadFromShell32 = TRUE;
171 TRACE("WithoutCom=%u FromShell=%u\n", bLoadWithoutCOM, bLoadFromShell32);
173 /* now we create a instance */
176 if (bLoadFromShell32) {
177 if (! SUCCEEDED(SHELL32_DllGetClassObject(myclsid, &IID_IClassFactory,(LPVOID*)&pcf))) {
178 ERR("LoadFromShell failed for CLSID=%s\n", debugstr_guid(myclsid));
180 } else if (bLoadWithoutCOM) {
182 /* load a external dll without ole32 */
184 typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv);
185 DllGetClassObjectFunc DllGetClassObject;
187 if ((hLibrary = LoadLibraryExW(sDllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH)) == 0) {
188 ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath));
189 hres = E_ACCESSDENIED;
191 } else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"))) {
192 ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath));
193 FreeLibrary( hLibrary );
194 hres = E_ACCESSDENIED;
196 } else if (! SUCCEEDED(hres = DllGetClassObject(myclsid, &IID_IClassFactory, (LPVOID*)&pcf))) {
197 TRACE("GetClassObject failed 0x%08lx\n", hres);
203 /* load a external dll in the usual way */
204 hres = __CoCreateInstance(myclsid, pUnkOuter, CLSCTX_INPROC_SERVER, refiid, ppv);
208 /* here we should have a ClassFactory */
209 if (!pcf) return E_ACCESSDENIED;
211 hres = IClassFactory_CreateInstance(pcf, pUnkOuter, refiid, ppv);
212 IClassFactory_Release(pcf);
216 ERR("failed (0x%08lx) to create \n\tCLSID:\t%s\n\tIID:\t%s\n",
217 hres, debugstr_guid(myclsid), debugstr_guid(refiid));
218 ERR("class not found in registry\n");
221 TRACE("-- instance: %p\n",*ppv);
225 /*************************************************************************
226 * DllGetClassObject [SHELL32.128]
228 HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
230 HRESULT hres = E_OUTOFMEMORY;
231 IClassFactory * pcf = NULL;
234 TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
236 if (!ppv) return E_INVALIDARG;
239 /* search our internal interface table */
240 for(i=0;InterfaceTable[i].riid;i++) {
241 if(IsEqualIID(InterfaceTable[i].riid, rclsid)) {
242 TRACE("index[%u]\n", i);
243 pcf = IDefClF_fnConstructor(InterfaceTable[i].lpfnCI, &shell32_ObjCount, NULL);
248 FIXME("failed for CLSID=%s\n", debugstr_guid(rclsid));
249 return CLASS_E_CLASSNOTAVAILABLE;
252 hres = IClassFactory_QueryInterface(pcf, iid, ppv);
253 IClassFactory_Release(pcf);
255 TRACE("-- pointer to class factory: %p\n",*ppv);
259 /*************************************************************************
260 * SHCLSIDFromString [SHELL32.147]
263 * exported by ordinal
265 DWORD WINAPI SHCLSIDFromStringA (LPCSTR clsid, CLSID *id)
268 TRACE("(%p(%s) %p)\n", clsid, clsid, id);
269 if (!MultiByteToWideChar( CP_ACP, 0, clsid, -1, buffer, sizeof(buffer)/sizeof(WCHAR) ))
270 return CO_E_CLASSSTRING;
271 return CLSIDFromString( buffer, id );
273 DWORD WINAPI SHCLSIDFromStringW (LPWSTR clsid, CLSID *id)
275 TRACE("(%p(%s) %p)\n", clsid, debugstr_w(clsid), id);
276 return CLSIDFromString(clsid, id);
278 DWORD WINAPI SHCLSIDFromStringAW (LPVOID clsid, CLSID *id)
280 if (SHELL_OsIsUnicode())
281 return SHCLSIDFromStringW (clsid, id);
282 return SHCLSIDFromStringA (clsid, id);
285 /*************************************************************************
286 * Shell Memory Allocator
289 /* set the vtable later */
290 extern ICOM_VTABLE(IMalloc) VT_Shell_IMalloc32;
292 /* this is the static object instance */
294 ICOM_VFIELD(IMalloc);
298 _ShellMalloc Shell_Malloc = { &VT_Shell_IMalloc32,1};
300 /* this is the global allocator of shell32 */
301 IMalloc * ShellTaskAllocator = NULL;
303 /******************************************************************************
304 * IShellMalloc_QueryInterface [VTABLE]
306 static HRESULT WINAPI IShellMalloc_fnQueryInterface(LPMALLOC iface, REFIID refiid, LPVOID *obj)
308 TRACE("(%s,%p)\n",debugstr_guid(refiid),obj);
310 if (IsEqualIID(refiid, &IID_IUnknown) || IsEqualIID(refiid, &IID_IMalloc)) {
311 *obj = (LPMALLOC) &Shell_Malloc;
314 return E_NOINTERFACE;
317 /******************************************************************************
318 * IShellMalloc_AddRefRelease [VTABLE]
320 static ULONG WINAPI IShellMalloc_fnAddRefRelease(LPMALLOC iface)
325 /******************************************************************************
326 * IShellMalloc_Alloc [VTABLE]
328 static LPVOID WINAPI IShellMalloc_fnAlloc(LPMALLOC iface, DWORD cb)
332 addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb);
333 TRACE("(%p,%ld);\n",addr,cb);
337 /******************************************************************************
338 * IShellMalloc_Realloc [VTABLE]
340 static LPVOID WINAPI IShellMalloc_fnRealloc(LPMALLOC iface, LPVOID pv, DWORD cb)
346 addr = (LPVOID) LocalReAlloc((HANDLE) pv, cb, GMEM_ZEROINIT | GMEM_MOVEABLE);
348 LocalFree((HANDLE) pv);
353 addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb);
359 TRACE("(%p->%p,%ld)\n",pv,addr,cb);
363 /******************************************************************************
364 * IShellMalloc_Free [VTABLE]
366 static VOID WINAPI IShellMalloc_fnFree(LPMALLOC iface, LPVOID pv)
369 LocalFree((HANDLE) pv);
372 /******************************************************************************
373 * IShellMalloc_GetSize [VTABLE]
375 static DWORD WINAPI IShellMalloc_fnGetSize(LPMALLOC iface, LPVOID pv)
377 DWORD cb = (DWORD) LocalSize((HANDLE)pv);
378 TRACE("(%p,%ld)\n", pv, cb);
382 /******************************************************************************
383 * IShellMalloc_DidAlloc [VTABLE]
385 static INT WINAPI IShellMalloc_fnDidAlloc(LPMALLOC iface, LPVOID pv)
391 /******************************************************************************
392 * IShellMalloc_HeapMinimize [VTABLE]
394 static VOID WINAPI IShellMalloc_fnHeapMinimize(LPMALLOC iface)
399 static ICOM_VTABLE(IMalloc) VT_Shell_IMalloc32 =
401 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
402 IShellMalloc_fnQueryInterface,
403 IShellMalloc_fnAddRefRelease,
404 IShellMalloc_fnAddRefRelease,
405 IShellMalloc_fnAlloc,
406 IShellMalloc_fnRealloc,
408 IShellMalloc_fnGetSize,
409 IShellMalloc_fnDidAlloc,
410 IShellMalloc_fnHeapMinimize
413 /*************************************************************************
414 * SHGetMalloc [SHELL32.@]
415 * returns the interface to shell malloc.
418 * uses OLE32.CoGetMalloc if OLE32.DLL is already loaded.
419 * if not it uses a internal implementations as fallback.
421 DWORD WINAPI SHGetMalloc(LPMALLOC *lpmal)
423 HRESULT (WINAPI *pCoGetMalloc)(DWORD,LPMALLOC *);
426 TRACE("(%p)\n", lpmal);
428 if (!ShellTaskAllocator)
430 hOle32 = GetModuleHandleA("OLE32.DLL");
432 pCoGetMalloc = (void*) GetProcAddress(hOle32, "CoGetMalloc");
433 if (pCoGetMalloc) pCoGetMalloc(MEMCTX_TASK, &ShellTaskAllocator);
434 TRACE("got ole32 IMalloc\n");
436 if(!ShellTaskAllocator) {
437 ShellTaskAllocator = (IMalloc* ) &Shell_Malloc;
438 TRACE("use fallback allocator\n");
441 *lpmal = ShellTaskAllocator;
445 /*************************************************************************
446 * SHAlloc [SHELL32.196]
449 * exported by ordinal
451 LPVOID WINAPI SHAlloc(DWORD len)
456 if (!ShellTaskAllocator) SHGetMalloc(&ppv);
458 ret = (LPVOID) IMalloc_Alloc(ShellTaskAllocator, len);
459 if(ret) ZeroMemory(ret, len); /*FIXME*/
460 TRACE("%lu bytes at %p\n",len, ret);
464 /*************************************************************************
465 * SHFree [SHELL32.195]
468 * exported by ordinal
470 void WINAPI SHFree(LPVOID pv)
475 if (!ShellTaskAllocator) SHGetMalloc(&ppv);
476 IMalloc_Free(ShellTaskAllocator, pv);
479 /*************************************************************************
480 * SHGetDesktopFolder [SHELL32.@]
482 DWORD WINAPI SHGetDesktopFolder(IShellFolder **psf)
485 TRACE("%p->(%p)\n",psf,*psf);
487 if(!psf) return E_INVALIDARG;
489 hres = ISF_Desktop_Constructor(NULL, &IID_IShellFolder,(LPVOID*)psf);
491 TRACE("-- %p->(%p)\n",psf, *psf);
495 /**************************************************************************
496 * Default ClassFactory Implementation
498 * SHCreateDefClassObject
501 * helper function for dll's without a own classfactory
502 * a generic classfactory is returned
503 * when the CreateInstance of the cf is called the callback is executed
508 ICOM_VFIELD(IClassFactory);
511 LPFNCREATEINSTANCE lpfnCI;
512 const IID * riidInst;
513 ULONG * pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */
516 static ICOM_VTABLE(IClassFactory) dclfvt;
518 /**************************************************************************
519 * IDefClF_fnConstructor
522 IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
526 lpclf = (IDefClFImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl));
528 ICOM_VTBL(lpclf) = &dclfvt;
529 lpclf->lpfnCI = lpfnCI;
530 lpclf->pcRefDll = pcRefDll;
532 if (pcRefDll) InterlockedIncrement(pcRefDll);
533 lpclf->riidInst = riidInst;
535 TRACE("(%p)\n\tIID:\t%s\n",lpclf, debugstr_guid(riidInst));
536 return (LPCLASSFACTORY)lpclf;
538 /**************************************************************************
539 * IDefClF_fnQueryInterface
541 static HRESULT WINAPI IDefClF_fnQueryInterface(
542 LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
544 ICOM_THIS(IDefClFImpl,iface);
546 TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
550 if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory)) {
552 InterlockedIncrement(&This->ref);
556 TRACE("-- E_NOINTERFACE\n");
557 return E_NOINTERFACE;
559 /******************************************************************************
562 static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface)
564 ICOM_THIS(IDefClFImpl,iface);
565 TRACE("(%p)->(count=%lu)\n",This,This->ref);
567 return InterlockedIncrement(&This->ref);
569 /******************************************************************************
572 static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface)
574 ICOM_THIS(IDefClFImpl,iface);
575 TRACE("(%p)->(count=%lu)\n",This,This->ref);
577 if (!InterlockedDecrement(&This->ref))
579 if (This->pcRefDll) InterlockedDecrement(This->pcRefDll);
581 TRACE("-- destroying IClassFactory(%p)\n",This);
582 HeapFree(GetProcessHeap(),0,This);
587 /******************************************************************************
588 * IDefClF_fnCreateInstance
590 static HRESULT WINAPI IDefClF_fnCreateInstance(
591 LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
593 ICOM_THIS(IDefClFImpl,iface);
595 TRACE("%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnkOuter,debugstr_guid(riid),ppvObject);
599 if ( This->riidInst==NULL ||
600 IsEqualCLSID(riid, This->riidInst) ||
601 IsEqualCLSID(riid, &IID_IUnknown) )
603 return This->lpfnCI(pUnkOuter, riid, ppvObject);
606 ERR("unknown IID requested\n\tIID:\t%s\n",debugstr_guid(riid));
607 return E_NOINTERFACE;
609 /******************************************************************************
610 * IDefClF_fnLockServer
612 static HRESULT WINAPI IDefClF_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
614 ICOM_THIS(IDefClFImpl,iface);
615 TRACE("%p->(0x%x), not implemented\n",This, fLock);
619 static ICOM_VTABLE(IClassFactory) dclfvt =
621 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
622 IDefClF_fnQueryInterface,
625 IDefClF_fnCreateInstance,
629 /******************************************************************************
630 * SHCreateDefClassObject [SHELL32.70]
632 HRESULT WINAPI SHCreateDefClassObject(
635 LPFNCREATEINSTANCE lpfnCI, /* [in] create instance callback entry */
636 LPDWORD pcRefDll, /* [in/out] ref count of the dll */
637 REFIID riidInst) /* [in] optional interface to the instance */
641 TRACE("\n\tIID:\t%s %p %p %p \n\tIIDIns:\t%s\n",
642 debugstr_guid(riid), ppv, lpfnCI, pcRefDll, debugstr_guid(riidInst));
644 if (! IsEqualCLSID(riid, &IID_IClassFactory) ) return E_NOINTERFACE;
645 if (! (pcf = IDefClF_fnConstructor(lpfnCI, pcRefDll, riidInst))) return E_OUTOFMEMORY;
650 /*************************************************************************
651 * DragAcceptFiles [SHELL32.54]
653 void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
657 if( !IsWindow(hWnd) ) return;
658 exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE);
660 exstyle |= WS_EX_ACCEPTFILES;
662 exstyle &= ~WS_EX_ACCEPTFILES;
663 SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle);
666 /*************************************************************************
667 * DragFinish [SHELL32.80]
669 void WINAPI DragFinish(HDROP h)
672 GlobalFree((HGLOBAL)h);
675 /*************************************************************************
676 * DragQueryPoint [SHELL32.135]
678 BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p)
680 DROPFILES *lpDropFileStruct;
685 lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
687 *p = lpDropFileStruct->pt;
688 bRet = lpDropFileStruct->fNC;
694 /*************************************************************************
695 * DragQueryFile [SHELL32.81]
696 * DragQueryFileA [SHELL32.82]
698 UINT WINAPI DragQueryFileA(
706 DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
708 TRACE("(%08x, %x, %p, %u)\n", hDrop,lFile,lpszFile,lLength);
710 if(!lpDropFileStruct) goto end;
712 lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->pFiles;
714 if(lpDropFileStruct->fWide == TRUE) {
715 LPWSTR lpszFileW = NULL;
718 lpszFileW = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR));
719 if(lpszFileW == NULL) {
723 i = DragQueryFileW(hDrop, lFile, lpszFileW, lLength);
726 WideCharToMultiByte(CP_ACP, 0, lpszFileW, -1, lpszFile, lLength, 0, NULL);
727 HeapFree(GetProcessHeap(), 0, lpszFileW);
734 while (*lpDrop++); /* skip filename */
737 i = (lFile == 0xFFFFFFFF) ? i : 0;
744 if (!lpszFile ) goto end; /* needed buffer size */
745 i = (lLength > i) ? i : lLength;
746 lstrcpynA (lpszFile, lpDrop, i);
752 /*************************************************************************
753 * DragQueryFileW [SHELL32.133]
755 UINT WINAPI DragQueryFileW(
763 DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
765 TRACE("(%08x, %x, %p, %u)\n", hDrop,lFile,lpszwFile,lLength);
767 if(!lpDropFileStruct) goto end;
769 lpwDrop = (LPWSTR) ((LPSTR)lpDropFileStruct + lpDropFileStruct->pFiles);
771 if(lpDropFileStruct->fWide == FALSE) {
772 LPSTR lpszFileA = NULL;
775 lpszFileA = (LPSTR) HeapAlloc(GetProcessHeap(), 0, lLength);
776 if(lpszFileA == NULL) {
780 i = DragQueryFileA(hDrop, lFile, lpszFileA, lLength);
783 MultiByteToWideChar(CP_ACP, 0, lpszFileA, -1, lpszwFile, lLength);
784 HeapFree(GetProcessHeap(), 0, lpszFileA);
792 while (*lpwDrop++); /* skip filename */
795 i = (lFile == 0xFFFFFFFF) ? i : 0;
800 i = strlenW(lpwDrop);
802 if ( !lpszwFile) goto end; /* needed buffer size */
804 i = (lLength > i) ? i : lLength;
805 lstrcpynW (lpszwFile, lpwDrop, i);