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
38 #include "undocshell.h"
39 #include "wine/unicode.h"
40 #include "shell32_main.h"
42 #include "wine/debug.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(shell);
48 extern HRESULT WINAPI IFSFolder_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
50 const WCHAR sShell32[12] = {'S','H','E','L','L','3','2','.','D','L','L','\0'};
51 const WCHAR sOLE32[10] = {'O','L','E','3','2','.','D','L','L','\0'};
53 HINSTANCE hShellOle32 = 0;
54 /**************************************************************************
55 * Default ClassFactory types
57 typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject);
58 IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst);
60 /* this table contains all CLSID's of shell32 objects */
63 LPFNCREATEINSTANCE lpfnCI;
64 } InterfaceTable[6] = {
65 {&CLSID_ShellFSFolder, &IFSFolder_Constructor},
66 {&CLSID_MyComputer, &ISF_MyComputer_Constructor},
67 {&CLSID_ShellDesktop, &ISF_Desktop_Constructor},
68 {&CLSID_ShellLink, &IShellLink_Constructor},
69 {&CLSID_DragDropHelper, &IDropTargetHelper_Constructor},
73 /*************************************************************************
74 * __CoCreateInstance [internal]
77 * wraper for late bound call to OLE32.DLL
80 HRESULT (WINAPI *pCoCreateInstance)(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv) = NULL;
82 void * __GetExternalFunc(HMODULE * phModule, LPCWSTR szModuleName, LPCSTR szProcName)
84 if (!*phModule) *phModule = GetModuleHandleW(szModuleName);
85 if (!*phModule) *phModule = LoadLibraryW(szModuleName);
86 if (*phModule) return GetProcAddress(*phModule, szProcName);
90 HRESULT __CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
92 if(!pCoCreateInstance) pCoCreateInstance = __GetExternalFunc(&hShellOle32, sOLE32, "CoCreateInstance");
93 if(!pCoCreateInstance) return E_FAIL;
94 return pCoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, ppv);
97 /*************************************************************************
98 * SHCoCreateInstance [SHELL32.102]
101 * exported by ordinal
104 /* FIXME: this should be SHLWAPI.24 since we can't yet import by ordinal */
106 DWORD WINAPI __SHGUIDToStringW (REFGUID guid, LPWSTR str)
108 WCHAR sFormat[52] = {'{','%','0','8','l','x','-','%','0','4',
109 'x','-','%','0','4','x','-','%','0','2',
110 'x','%','0','2','x','-','%','0','2','x',
111 '%','0','2','x','%','0','2','x','%','0',
112 '2','x','%','0','2','x','%','0','2','x',
115 return wsprintfW ( str, sFormat,
116 guid->Data1, guid->Data2, guid->Data3,
117 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
118 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
122 /************************************************************************/
124 LRESULT WINAPI SHCoCreateInstance(
133 CLSID * myclsid = (CLSID*)clsid;
134 WCHAR sKeyName[MAX_PATH];
135 const WCHAR sCLSID[7] = {'C','L','S','I','D','\\','\0'};
137 const WCHAR sInProcServer32[16] ={'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2','\0'};
138 const WCHAR sLoadWithoutCOM[15] ={'L','o','a','d','W','i','t','h','o','u','t','C','O','M','\0'};
139 WCHAR sDllPath[MAX_PATH];
142 BOOLEAN bLoadFromShell32 = FALSE;
143 BOOLEAN bLoadWithoutCOM = FALSE;
144 IClassFactory * pcf = NULL;
146 if(!ppv) return E_POINTER;
149 /* if the clsid is a string, convert it */
152 if (!aclsid) return REGDB_E_CLASSNOTREG;
153 SHCLSIDFromStringW(aclsid, &iid);
157 TRACE("(%p,%s,unk:%p,%s,%p)\n",
158 aclsid,shdebugstr_guid(myclsid),pUnkOuter,shdebugstr_guid(refiid),ppv);
160 /* we look up the dll path in the registry */
161 __SHGUIDToStringW(myclsid, sClassID);
162 lstrcpyW(sKeyName, sCLSID);
163 lstrcatW(sKeyName, sClassID);
164 lstrcatW(sKeyName, sInProcServer32);
166 if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, sKeyName, 0, KEY_READ, &hKey)) {
167 dwSize = sizeof(sDllPath);
168 SHQueryValueExW(hKey, NULL, 0,0, sDllPath, &dwSize );
170 /* if a special registry key is set, we load a shell extension without help of OLE32 */
171 bLoadWithoutCOM = (ERROR_SUCCESS == SHQueryValueExW(hKey, sLoadWithoutCOM, 0, 0, 0, 0));
173 /* if the com object is inside shell32, omit use of ole32 */
174 bLoadFromShell32 = (0==lstrcmpiW( PathFindFileNameW(sDllPath), sShell32));
178 /* since we can't find it in the registry we try internally */
179 bLoadFromShell32 = TRUE;
182 TRACE("WithoutCom=%u FromShell=%u\n", bLoadWithoutCOM, bLoadFromShell32);
184 /* now we create a instance */
185 if (bLoadFromShell32) {
186 if (! SUCCEEDED(SHELL32_DllGetClassObject(myclsid, &IID_IClassFactory,(LPVOID*)&pcf))) {
187 ERR("LoadFromShell failed for CLSID=%s\n", shdebugstr_guid(myclsid));
189 } else if (bLoadWithoutCOM) {
191 /* load a external dll without ole32 */
193 typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv);
194 DllGetClassObjectFunc DllGetClassObject;
196 if ((hLibrary = LoadLibraryExW(sDllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH)) == 0) {
197 ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath));
198 hres = E_ACCESSDENIED;
200 } else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"))) {
201 ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath));
202 FreeLibrary( hLibrary );
203 hres = E_ACCESSDENIED;
205 } else if (! SUCCEEDED(hres = DllGetClassObject(myclsid, &IID_IClassFactory, (LPVOID*)&pcf))) {
206 TRACE("GetClassObject failed 0x%08lx\n", hres);
212 /* load a external dll in the usual way */
213 hres = __CoCreateInstance(myclsid, pUnkOuter, CLSCTX_INPROC_SERVER, refiid, ppv);
217 /* here we should have a ClassFactory */
218 if (!pcf) return E_ACCESSDENIED;
220 hres = IClassFactory_CreateInstance(pcf, pUnkOuter, refiid, ppv);
221 IClassFactory_Release(pcf);
225 ERR("failed (0x%08lx) to create CLSID:%s IID:%s\n",
226 hres, shdebugstr_guid(myclsid), shdebugstr_guid(refiid));
227 ERR("class not found in registry\n");
230 TRACE("-- instance: %p\n",*ppv);
234 /*************************************************************************
235 * DllGetClassObject [SHELL32.128]
237 HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
239 HRESULT hres = E_OUTOFMEMORY;
240 IClassFactory * pcf = NULL;
243 TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid),shdebugstr_guid(iid));
245 if (!ppv) return E_INVALIDARG;
248 /* search our internal interface table */
249 for(i=0;InterfaceTable[i].riid;i++) {
250 if(IsEqualIID(InterfaceTable[i].riid, rclsid)) {
251 TRACE("index[%u]\n", i);
252 pcf = IDefClF_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL);
257 FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid));
258 return CLASS_E_CLASSNOTAVAILABLE;
261 hres = IClassFactory_QueryInterface(pcf, iid, ppv);
262 IClassFactory_Release(pcf);
264 TRACE("-- pointer to class factory: %p\n",*ppv);
268 /*************************************************************************
269 * SHCLSIDFromString [SHELL32.147]
272 * exported by ordinal
274 DWORD WINAPI SHCLSIDFromStringA (LPCSTR clsid, CLSID *id)
277 TRACE("(%p(%s) %p)\n", clsid, clsid, id);
278 if (!MultiByteToWideChar( CP_ACP, 0, clsid, -1, buffer, sizeof(buffer)/sizeof(WCHAR) ))
279 return CO_E_CLASSSTRING;
280 return CLSIDFromString( buffer, id );
282 DWORD WINAPI SHCLSIDFromStringW (LPCWSTR clsid, CLSID *id)
284 TRACE("(%p(%s) %p)\n", clsid, debugstr_w(clsid), id);
285 return CLSIDFromString(clsid, id);
287 DWORD WINAPI SHCLSIDFromStringAW (LPVOID clsid, CLSID *id)
289 if (SHELL_OsIsUnicode())
290 return SHCLSIDFromStringW (clsid, id);
291 return SHCLSIDFromStringA (clsid, id);
294 /*************************************************************************
295 * Shell Memory Allocator
298 /* set the vtable later */
299 extern ICOM_VTABLE(IMalloc) VT_Shell_IMalloc32;
301 /* this is the static object instance */
303 ICOM_VFIELD(IMalloc);
307 _ShellMalloc Shell_Malloc = { &VT_Shell_IMalloc32,1};
309 /* this is the global allocator of shell32 */
310 IMalloc * ShellTaskAllocator = NULL;
312 /******************************************************************************
313 * IShellMalloc_QueryInterface [VTABLE]
315 static HRESULT WINAPI IShellMalloc_fnQueryInterface(LPMALLOC iface, REFIID refiid, LPVOID *obj)
317 TRACE("(%s,%p)\n",shdebugstr_guid(refiid),obj);
318 if (IsEqualIID(refiid, &IID_IUnknown) || IsEqualIID(refiid, &IID_IMalloc)) {
319 *obj = (LPMALLOC) &Shell_Malloc;
322 return E_NOINTERFACE;
325 /******************************************************************************
326 * IShellMalloc_AddRefRelease [VTABLE]
328 static ULONG WINAPI IShellMalloc_fnAddRefRelease(LPMALLOC iface)
333 /******************************************************************************
334 * IShellMalloc_Alloc [VTABLE]
336 static LPVOID WINAPI IShellMalloc_fnAlloc(LPMALLOC iface, DWORD cb)
340 addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb);
341 TRACE("(%p,%ld);\n",addr,cb);
345 /******************************************************************************
346 * IShellMalloc_Realloc [VTABLE]
348 static LPVOID WINAPI IShellMalloc_fnRealloc(LPMALLOC iface, LPVOID pv, DWORD cb)
354 addr = (LPVOID) LocalReAlloc((HANDLE) pv, cb, GMEM_ZEROINIT | GMEM_MOVEABLE);
356 LocalFree((HANDLE) pv);
361 addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb);
367 TRACE("(%p->%p,%ld)\n",pv,addr,cb);
371 /******************************************************************************
372 * IShellMalloc_Free [VTABLE]
374 static VOID WINAPI IShellMalloc_fnFree(LPMALLOC iface, LPVOID pv)
377 LocalFree((HANDLE) pv);
380 /******************************************************************************
381 * IShellMalloc_GetSize [VTABLE]
383 static DWORD WINAPI IShellMalloc_fnGetSize(LPMALLOC iface, LPVOID pv)
385 DWORD cb = (DWORD) LocalSize((HANDLE)pv);
386 TRACE("(%p,%ld)\n", pv, cb);
390 /******************************************************************************
391 * IShellMalloc_DidAlloc [VTABLE]
393 static INT WINAPI IShellMalloc_fnDidAlloc(LPMALLOC iface, LPVOID pv)
399 /******************************************************************************
400 * IShellMalloc_HeapMinimize [VTABLE]
402 static VOID WINAPI IShellMalloc_fnHeapMinimize(LPMALLOC iface)
407 static ICOM_VTABLE(IMalloc) VT_Shell_IMalloc32 =
409 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
410 IShellMalloc_fnQueryInterface,
411 IShellMalloc_fnAddRefRelease,
412 IShellMalloc_fnAddRefRelease,
413 IShellMalloc_fnAlloc,
414 IShellMalloc_fnRealloc,
416 IShellMalloc_fnGetSize,
417 IShellMalloc_fnDidAlloc,
418 IShellMalloc_fnHeapMinimize
421 /*************************************************************************
422 * SHGetMalloc [SHELL32.@]
424 * Return the shell IMalloc interface.
427 * lpmal [O] Destination for IMalloc interface.
430 * Success: S_OK. lpmal contains the shells IMalloc interface.
431 * Failure. An HRESULT error code.
434 * This function will use CoGetMalloc() if OLE32.DLL is already loaded.
435 * If not it uses an internal implementation as a fallback.
437 HRESULT WINAPI SHGetMalloc(LPMALLOC *lpmal)
439 HRESULT (WINAPI *pCoGetMalloc)(DWORD,LPMALLOC *);
442 TRACE("(%p)\n", lpmal);
444 if (!ShellTaskAllocator)
446 hOle32 = GetModuleHandleA("OLE32.DLL");
448 pCoGetMalloc = (void*) GetProcAddress(hOle32, "CoGetMalloc");
449 if (pCoGetMalloc) pCoGetMalloc(MEMCTX_TASK, &ShellTaskAllocator);
450 TRACE("got ole32 IMalloc\n");
452 if(!ShellTaskAllocator) {
453 ShellTaskAllocator = (IMalloc* ) &Shell_Malloc;
454 TRACE("use fallback allocator\n");
457 *lpmal = ShellTaskAllocator;
461 /*************************************************************************
462 * SHAlloc [SHELL32.196]
465 * exported by ordinal
467 LPVOID WINAPI SHAlloc(DWORD len)
472 if (!ShellTaskAllocator) SHGetMalloc(&ppv);
474 ret = (LPVOID) IMalloc_Alloc(ShellTaskAllocator, len);
475 TRACE("%lu bytes at %p\n",len, ret);
479 /*************************************************************************
480 * SHFree [SHELL32.195]
483 * exported by ordinal
485 void WINAPI SHFree(LPVOID pv)
490 if (!ShellTaskAllocator) SHGetMalloc(&ppv);
491 IMalloc_Free(ShellTaskAllocator, pv);
494 /*************************************************************************
495 * SHGetDesktopFolder [SHELL32.@]
497 DWORD WINAPI SHGetDesktopFolder(IShellFolder **psf)
502 if(!psf) return E_INVALIDARG;
504 hres = ISF_Desktop_Constructor(NULL, &IID_IShellFolder,(LPVOID*)psf);
506 TRACE("-- %p->(%p)\n",psf, *psf);
509 /**************************************************************************
510 * Default ClassFactory Implementation
512 * SHCreateDefClassObject
515 * helper function for dll's without a own classfactory
516 * a generic classfactory is returned
517 * when the CreateInstance of the cf is called the callback is executed
522 ICOM_VFIELD(IClassFactory);
525 LPFNCREATEINSTANCE lpfnCI;
526 const IID * riidInst;
527 ULONG * pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */
530 static ICOM_VTABLE(IClassFactory) dclfvt;
532 /**************************************************************************
533 * IDefClF_fnConstructor
536 IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
540 lpclf = (IDefClFImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl));
542 lpclf->lpVtbl = &dclfvt;
543 lpclf->lpfnCI = lpfnCI;
544 lpclf->pcRefDll = pcRefDll;
546 if (pcRefDll) InterlockedIncrement(pcRefDll);
547 lpclf->riidInst = riidInst;
549 TRACE("(%p)%s\n",lpclf, shdebugstr_guid(riidInst));
550 return (LPCLASSFACTORY)lpclf;
552 /**************************************************************************
553 * IDefClF_fnQueryInterface
555 static HRESULT WINAPI IDefClF_fnQueryInterface(
556 LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
558 ICOM_THIS(IDefClFImpl,iface);
560 TRACE("(%p)->(%s)\n",This,shdebugstr_guid(riid));
564 if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory)) {
566 InterlockedIncrement(&This->ref);
570 TRACE("-- E_NOINTERFACE\n");
571 return E_NOINTERFACE;
573 /******************************************************************************
576 static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface)
578 ICOM_THIS(IDefClFImpl,iface);
579 TRACE("(%p)->(count=%lu)\n",This,This->ref);
581 return InterlockedIncrement(&This->ref);
583 /******************************************************************************
586 static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface)
588 ICOM_THIS(IDefClFImpl,iface);
589 TRACE("(%p)->(count=%lu)\n",This,This->ref);
591 if (!InterlockedDecrement(&This->ref))
593 if (This->pcRefDll) InterlockedDecrement(This->pcRefDll);
595 TRACE("-- destroying IClassFactory(%p)\n",This);
596 HeapFree(GetProcessHeap(),0,This);
601 /******************************************************************************
602 * IDefClF_fnCreateInstance
604 static HRESULT WINAPI IDefClF_fnCreateInstance(
605 LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
607 ICOM_THIS(IDefClFImpl,iface);
609 TRACE("%p->(%p,%s,%p)\n",This,pUnkOuter,shdebugstr_guid(riid),ppvObject);
613 if ( This->riidInst==NULL ||
614 IsEqualCLSID(riid, This->riidInst) ||
615 IsEqualCLSID(riid, &IID_IUnknown) )
617 return This->lpfnCI(pUnkOuter, riid, ppvObject);
620 ERR("unknown IID requested %s\n",shdebugstr_guid(riid));
621 return E_NOINTERFACE;
623 /******************************************************************************
624 * IDefClF_fnLockServer
626 static HRESULT WINAPI IDefClF_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
628 ICOM_THIS(IDefClFImpl,iface);
629 TRACE("%p->(0x%x), not implemented\n",This, fLock);
633 static ICOM_VTABLE(IClassFactory) dclfvt =
635 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
636 IDefClF_fnQueryInterface,
639 IDefClF_fnCreateInstance,
643 /******************************************************************************
644 * SHCreateDefClassObject [SHELL32.70]
646 HRESULT WINAPI SHCreateDefClassObject(
649 LPFNCREATEINSTANCE lpfnCI, /* [in] create instance callback entry */
650 LPDWORD pcRefDll, /* [in/out] ref count of the dll */
651 REFIID riidInst) /* [in] optional interface to the instance */
655 TRACE("%s %p %p %p %s\n",
656 shdebugstr_guid(riid), ppv, lpfnCI, pcRefDll, shdebugstr_guid(riidInst));
658 if (! IsEqualCLSID(riid, &IID_IClassFactory) ) return E_NOINTERFACE;
659 if (! (pcf = IDefClF_fnConstructor(lpfnCI, pcRefDll, riidInst))) return E_OUTOFMEMORY;
664 /*************************************************************************
665 * DragAcceptFiles [SHELL32.54]
667 void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
671 if( !IsWindow(hWnd) ) return;
672 exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE);
674 exstyle |= WS_EX_ACCEPTFILES;
676 exstyle &= ~WS_EX_ACCEPTFILES;
677 SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle);
680 /*************************************************************************
681 * DragFinish [SHELL32.80]
683 void WINAPI DragFinish(HDROP h)
686 GlobalFree((HGLOBAL)h);
689 /*************************************************************************
690 * DragQueryPoint [SHELL32.135]
692 BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p)
694 DROPFILES *lpDropFileStruct;
699 lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
701 *p = lpDropFileStruct->pt;
702 bRet = lpDropFileStruct->fNC;
708 /*************************************************************************
709 * DragQueryFile [SHELL32.81]
710 * DragQueryFileA [SHELL32.82]
712 UINT WINAPI DragQueryFileA(
720 DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
722 TRACE("(%p, %x, %p, %u)\n", hDrop,lFile,lpszFile,lLength);
724 if(!lpDropFileStruct) goto end;
726 lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->pFiles;
728 if(lpDropFileStruct->fWide == TRUE) {
729 LPWSTR lpszFileW = NULL;
732 lpszFileW = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR));
733 if(lpszFileW == NULL) {
737 i = DragQueryFileW(hDrop, lFile, lpszFileW, lLength);
740 WideCharToMultiByte(CP_ACP, 0, lpszFileW, -1, lpszFile, lLength, 0, NULL);
741 HeapFree(GetProcessHeap(), 0, lpszFileW);
748 while (*lpDrop++); /* skip filename */
751 i = (lFile == 0xFFFFFFFF) ? i : 0;
758 if (!lpszFile ) goto end; /* needed buffer size */
759 i = (lLength > i) ? i : lLength;
760 lstrcpynA (lpszFile, lpDrop, i);
766 /*************************************************************************
767 * DragQueryFileW [SHELL32.133]
769 UINT WINAPI DragQueryFileW(
777 DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
779 TRACE("(%p, %x, %p, %u)\n", hDrop,lFile,lpszwFile,lLength);
781 if(!lpDropFileStruct) goto end;
783 lpwDrop = (LPWSTR) ((LPSTR)lpDropFileStruct + lpDropFileStruct->pFiles);
785 if(lpDropFileStruct->fWide == FALSE) {
786 LPSTR lpszFileA = NULL;
789 lpszFileA = (LPSTR) HeapAlloc(GetProcessHeap(), 0, lLength);
790 if(lpszFileA == NULL) {
794 i = DragQueryFileA(hDrop, lFile, lpszFileA, lLength);
797 MultiByteToWideChar(CP_ACP, 0, lpszFileA, -1, lpszwFile, lLength);
798 HeapFree(GetProcessHeap(), 0, lpszFileA);
806 while (*lpwDrop++); /* skip filename */
809 i = (lFile == 0xFFFFFFFF) ? i : 0;
814 i = strlenW(lpwDrop);
816 if ( !lpszwFile) goto end; /* needed buffer size */
818 i = (lLength > i) ? i : lLength;
819 lstrcpynW (lpszwFile, lpwDrop, i);