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 #include "wine/obj_dragdrophelper.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(shell);
45 DWORD WINAPI SHCLSIDFromStringA (LPCSTR clsid, CLSID *id);
46 extern HRESULT WINAPI IFSFolder_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
48 const WCHAR sShell32[12] = {'S','H','E','L','L','3','2','.','D','L','L','\0'};
49 const WCHAR sOLE32[10] = {'O','L','E','3','2','.','D','L','L','\0'};
51 HINSTANCE hShellOle32 = 0;
52 /**************************************************************************
53 * Default ClassFactory types
55 typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject);
56 IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst);
58 /* this table contains all CLSID's of shell32 objects */
61 LPFNCREATEINSTANCE lpfnCI;
62 } InterfaceTable[6] = {
63 {&CLSID_ShellFSFolder, &IFSFolder_Constructor},
64 {&CLSID_MyComputer, &ISF_MyComputer_Constructor},
65 {&CLSID_ShellDesktop, &ISF_Desktop_Constructor},
66 {&CLSID_ShellLink, &IShellLink_Constructor},
67 {&CLSID_DragDropHelper, &IDropTargetHelper_Constructor},
71 /*************************************************************************
72 * __CoCreateInstance [internal]
75 * wraper for late bound call to OLE32.DLL
78 HRESULT (WINAPI *pCoCreateInstance)(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv) = NULL;
80 void * __GetExternalFunc(HMODULE * phModule, LPCWSTR szModuleName, LPCSTR szProcName)
82 if (!*phModule) *phModule = GetModuleHandleW(szModuleName);
83 if (!*phModule) *phModule = LoadLibraryW(szModuleName);
84 if (*phModule) return GetProcAddress(*phModule, szProcName);
88 HRESULT __CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
90 if(!pCoCreateInstance) pCoCreateInstance = __GetExternalFunc(&hShellOle32, sOLE32, "CoCreateInstance");
91 if(!pCoCreateInstance) return E_FAIL;
92 return pCoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, ppv);
95 /*************************************************************************
96 * SHCoCreateInstance [SHELL32.102]
102 /* FIXME: this should be SHLWAPI.24 since we can't yet import by ordinal */
104 DWORD WINAPI __SHGUIDToStringW (REFGUID guid, LPWSTR str)
106 WCHAR sFormat[52] = {'{','%','0','8','l','x','-','%','0','4',
107 'x','-','%','0','4','x','-','%','0','2',
108 'x','%','0','2','x','-','%','0','2','x',
109 '%','0','2','x','%','0','2','x','%','0',
110 '2','x','%','0','2','x','%','0','2','x',
113 return wsprintfW ( str, sFormat,
114 guid->Data1, guid->Data2, guid->Data3,
115 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
116 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
120 /************************************************************************/
122 LRESULT WINAPI SHCoCreateInstance(
131 CLSID * myclsid = (CLSID*)clsid;
132 WCHAR sKeyName[MAX_PATH];
133 const WCHAR sCLSID[7] = {'C','L','S','I','D','\\','\0'};
135 const WCHAR sInProcServer32[16] ={'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2','\0'};
136 const WCHAR sLoadWithoutCOM[15] ={'L','o','a','d','W','i','t','h','o','u','t','C','O','M','\0'};
137 WCHAR sDllPath[MAX_PATH];
140 BOOLEAN bLoadFromShell32 = FALSE;
141 BOOLEAN bLoadWithoutCOM = FALSE;
142 IClassFactory * pcf = NULL;
144 if(!ppv) return E_POINTER;
147 /* if the clsid is a string, convert it */
150 if (!aclsid) return REGDB_E_CLASSNOTREG;
151 SHCLSIDFromStringA(aclsid, &iid);
155 TRACE("(%p,%s,unk:%p,%s,%p)\n",
156 aclsid,shdebugstr_guid(myclsid),pUnkOuter,shdebugstr_guid(refiid),ppv);
158 /* we look up the dll path in the registry */
159 __SHGUIDToStringW(myclsid, sClassID);
160 lstrcpyW(sKeyName, sCLSID);
161 lstrcatW(sKeyName, sClassID);
162 lstrcatW(sKeyName, sInProcServer32);
164 if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, sKeyName, 0, KEY_READ, &hKey)) {
165 dwSize = sizeof(sDllPath);
166 SHQueryValueExW(hKey, NULL, 0,0, sDllPath, &dwSize );
168 /* if a special registry key is set, we load a shell extension without help of OLE32 */
169 bLoadWithoutCOM = (ERROR_SUCCESS == SHQueryValueExW(hKey, sLoadWithoutCOM, 0, 0, 0, 0));
171 /* if the com object is inside shell32, omit use of ole32 */
172 bLoadFromShell32 = (0==lstrcmpiW( PathFindFileNameW(sDllPath), sShell32));
176 /* since we can't find it in the registry we try internally */
177 bLoadFromShell32 = TRUE;
180 TRACE("WithoutCom=%u FromShell=%u\n", bLoadWithoutCOM, bLoadFromShell32);
182 /* now we create a instance */
183 if (bLoadFromShell32) {
184 if (! SUCCEEDED(SHELL32_DllGetClassObject(myclsid, &IID_IClassFactory,(LPVOID*)&pcf))) {
185 ERR("LoadFromShell failed for CLSID=%s\n", shdebugstr_guid(myclsid));
187 } else if (bLoadWithoutCOM) {
189 /* load a external dll without ole32 */
191 typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv);
192 DllGetClassObjectFunc DllGetClassObject;
194 if ((hLibrary = LoadLibraryExW(sDllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH)) == 0) {
195 ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath));
196 hres = E_ACCESSDENIED;
198 } else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"))) {
199 ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath));
200 FreeLibrary( hLibrary );
201 hres = E_ACCESSDENIED;
203 } else if (! SUCCEEDED(hres = DllGetClassObject(myclsid, &IID_IClassFactory, (LPVOID*)&pcf))) {
204 TRACE("GetClassObject failed 0x%08lx\n", hres);
210 /* load a external dll in the usual way */
211 hres = __CoCreateInstance(myclsid, pUnkOuter, CLSCTX_INPROC_SERVER, refiid, ppv);
215 /* here we should have a ClassFactory */
216 if (!pcf) return E_ACCESSDENIED;
218 hres = IClassFactory_CreateInstance(pcf, pUnkOuter, refiid, ppv);
219 IClassFactory_Release(pcf);
223 ERR("failed (0x%08lx) to create CLSID:%s IID:%s\n",
224 hres, shdebugstr_guid(myclsid), shdebugstr_guid(refiid));
225 ERR("class not found in registry\n");
228 TRACE("-- instance: %p\n",*ppv);
232 /*************************************************************************
233 * DllGetClassObject [SHELL32.128]
235 HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
237 HRESULT hres = E_OUTOFMEMORY;
238 IClassFactory * pcf = NULL;
241 TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid),shdebugstr_guid(iid));
243 if (!ppv) return E_INVALIDARG;
246 /* search our internal interface table */
247 for(i=0;InterfaceTable[i].riid;i++) {
248 if(IsEqualIID(InterfaceTable[i].riid, rclsid)) {
249 TRACE("index[%u]\n", i);
250 pcf = IDefClF_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL);
255 FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid));
256 return CLASS_E_CLASSNOTAVAILABLE;
259 hres = IClassFactory_QueryInterface(pcf, iid, ppv);
260 IClassFactory_Release(pcf);
262 TRACE("-- pointer to class factory: %p\n",*ppv);
266 /*************************************************************************
267 * SHCLSIDFromString [SHELL32.147]
270 * exported by ordinal
272 DWORD WINAPI SHCLSIDFromStringA (LPCSTR clsid, CLSID *id)
275 TRACE("(%p(%s) %p)\n", clsid, clsid, id);
276 if (!MultiByteToWideChar( CP_ACP, 0, clsid, -1, buffer, sizeof(buffer)/sizeof(WCHAR) ))
277 return CO_E_CLASSSTRING;
278 return CLSIDFromString( buffer, id );
280 DWORD WINAPI SHCLSIDFromStringW (LPWSTR clsid, CLSID *id)
282 TRACE("(%p(%s) %p)\n", clsid, debugstr_w(clsid), id);
283 return CLSIDFromString(clsid, id);
285 DWORD WINAPI SHCLSIDFromStringAW (LPVOID clsid, CLSID *id)
287 if (SHELL_OsIsUnicode())
288 return SHCLSIDFromStringW (clsid, id);
289 return SHCLSIDFromStringA (clsid, id);
292 /*************************************************************************
293 * Shell Memory Allocator
296 /* set the vtable later */
297 extern ICOM_VTABLE(IMalloc) VT_Shell_IMalloc32;
299 /* this is the static object instance */
301 ICOM_VFIELD(IMalloc);
305 _ShellMalloc Shell_Malloc = { &VT_Shell_IMalloc32,1};
307 /* this is the global allocator of shell32 */
308 IMalloc * ShellTaskAllocator = NULL;
310 /******************************************************************************
311 * IShellMalloc_QueryInterface [VTABLE]
313 static HRESULT WINAPI IShellMalloc_fnQueryInterface(LPMALLOC iface, REFIID refiid, LPVOID *obj)
315 TRACE("(%s,%p)\n",shdebugstr_guid(refiid),obj);
316 if (IsEqualIID(refiid, &IID_IUnknown) || IsEqualIID(refiid, &IID_IMalloc)) {
317 *obj = (LPMALLOC) &Shell_Malloc;
320 return E_NOINTERFACE;
323 /******************************************************************************
324 * IShellMalloc_AddRefRelease [VTABLE]
326 static ULONG WINAPI IShellMalloc_fnAddRefRelease(LPMALLOC iface)
331 /******************************************************************************
332 * IShellMalloc_Alloc [VTABLE]
334 static LPVOID WINAPI IShellMalloc_fnAlloc(LPMALLOC iface, DWORD cb)
338 addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb);
339 TRACE("(%p,%ld);\n",addr,cb);
343 /******************************************************************************
344 * IShellMalloc_Realloc [VTABLE]
346 static LPVOID WINAPI IShellMalloc_fnRealloc(LPMALLOC iface, LPVOID pv, DWORD cb)
352 addr = (LPVOID) LocalReAlloc((HANDLE) pv, cb, GMEM_ZEROINIT | GMEM_MOVEABLE);
354 LocalFree((HANDLE) pv);
359 addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb);
365 TRACE("(%p->%p,%ld)\n",pv,addr,cb);
369 /******************************************************************************
370 * IShellMalloc_Free [VTABLE]
372 static VOID WINAPI IShellMalloc_fnFree(LPMALLOC iface, LPVOID pv)
375 LocalFree((HANDLE) pv);
378 /******************************************************************************
379 * IShellMalloc_GetSize [VTABLE]
381 static DWORD WINAPI IShellMalloc_fnGetSize(LPMALLOC iface, LPVOID pv)
383 DWORD cb = (DWORD) LocalSize((HANDLE)pv);
384 TRACE("(%p,%ld)\n", pv, cb);
388 /******************************************************************************
389 * IShellMalloc_DidAlloc [VTABLE]
391 static INT WINAPI IShellMalloc_fnDidAlloc(LPMALLOC iface, LPVOID pv)
397 /******************************************************************************
398 * IShellMalloc_HeapMinimize [VTABLE]
400 static VOID WINAPI IShellMalloc_fnHeapMinimize(LPMALLOC iface)
405 static ICOM_VTABLE(IMalloc) VT_Shell_IMalloc32 =
407 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
408 IShellMalloc_fnQueryInterface,
409 IShellMalloc_fnAddRefRelease,
410 IShellMalloc_fnAddRefRelease,
411 IShellMalloc_fnAlloc,
412 IShellMalloc_fnRealloc,
414 IShellMalloc_fnGetSize,
415 IShellMalloc_fnDidAlloc,
416 IShellMalloc_fnHeapMinimize
419 /*************************************************************************
420 * SHGetMalloc [SHELL32.@]
421 * returns the interface to shell malloc.
424 * uses OLE32.CoGetMalloc if OLE32.DLL is already loaded.
425 * if not it uses a internal implementations as fallback.
427 DWORD WINAPI SHGetMalloc(LPMALLOC *lpmal)
429 HRESULT (WINAPI *pCoGetMalloc)(DWORD,LPMALLOC *);
432 TRACE("(%p)\n", lpmal);
434 if (!ShellTaskAllocator)
436 hOle32 = GetModuleHandleA("OLE32.DLL");
438 pCoGetMalloc = (void*) GetProcAddress(hOle32, "CoGetMalloc");
439 if (pCoGetMalloc) pCoGetMalloc(MEMCTX_TASK, &ShellTaskAllocator);
440 TRACE("got ole32 IMalloc\n");
442 if(!ShellTaskAllocator) {
443 ShellTaskAllocator = (IMalloc* ) &Shell_Malloc;
444 TRACE("use fallback allocator\n");
447 *lpmal = ShellTaskAllocator;
451 /*************************************************************************
452 * SHAlloc [SHELL32.196]
455 * exported by ordinal
457 LPVOID WINAPI SHAlloc(DWORD len)
462 if (!ShellTaskAllocator) SHGetMalloc(&ppv);
464 ret = (LPVOID) IMalloc_Alloc(ShellTaskAllocator, len);
465 TRACE("%lu bytes at %p\n",len, ret);
469 /*************************************************************************
470 * SHFree [SHELL32.195]
473 * exported by ordinal
475 void WINAPI SHFree(LPVOID pv)
480 if (!ShellTaskAllocator) SHGetMalloc(&ppv);
481 IMalloc_Free(ShellTaskAllocator, pv);
484 /*************************************************************************
485 * SHGetDesktopFolder [SHELL32.@]
487 DWORD WINAPI SHGetDesktopFolder(IShellFolder **psf)
492 if(!psf) return E_INVALIDARG;
494 hres = ISF_Desktop_Constructor(NULL, &IID_IShellFolder,(LPVOID*)psf);
496 TRACE("-- %p->(%p)\n",psf, *psf);
499 /**************************************************************************
500 * Default ClassFactory Implementation
502 * SHCreateDefClassObject
505 * helper function for dll's without a own classfactory
506 * a generic classfactory is returned
507 * when the CreateInstance of the cf is called the callback is executed
512 ICOM_VFIELD(IClassFactory);
515 LPFNCREATEINSTANCE lpfnCI;
516 const IID * riidInst;
517 ULONG * pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */
520 static ICOM_VTABLE(IClassFactory) dclfvt;
522 /**************************************************************************
523 * IDefClF_fnConstructor
526 IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
530 lpclf = (IDefClFImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl));
532 ICOM_VTBL(lpclf) = &dclfvt;
533 lpclf->lpfnCI = lpfnCI;
534 lpclf->pcRefDll = pcRefDll;
536 if (pcRefDll) InterlockedIncrement(pcRefDll);
537 lpclf->riidInst = riidInst;
539 TRACE("(%p)%s\n",lpclf, shdebugstr_guid(riidInst));
540 return (LPCLASSFACTORY)lpclf;
542 /**************************************************************************
543 * IDefClF_fnQueryInterface
545 static HRESULT WINAPI IDefClF_fnQueryInterface(
546 LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
548 ICOM_THIS(IDefClFImpl,iface);
550 TRACE("(%p)->(%s)\n",This,shdebugstr_guid(riid));
554 if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory)) {
556 InterlockedIncrement(&This->ref);
560 TRACE("-- E_NOINTERFACE\n");
561 return E_NOINTERFACE;
563 /******************************************************************************
566 static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface)
568 ICOM_THIS(IDefClFImpl,iface);
569 TRACE("(%p)->(count=%lu)\n",This,This->ref);
571 return InterlockedIncrement(&This->ref);
573 /******************************************************************************
576 static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface)
578 ICOM_THIS(IDefClFImpl,iface);
579 TRACE("(%p)->(count=%lu)\n",This,This->ref);
581 if (!InterlockedDecrement(&This->ref))
583 if (This->pcRefDll) InterlockedDecrement(This->pcRefDll);
585 TRACE("-- destroying IClassFactory(%p)\n",This);
586 HeapFree(GetProcessHeap(),0,This);
591 /******************************************************************************
592 * IDefClF_fnCreateInstance
594 static HRESULT WINAPI IDefClF_fnCreateInstance(
595 LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
597 ICOM_THIS(IDefClFImpl,iface);
599 TRACE("%p->(%p,%s,%p)\n",This,pUnkOuter,shdebugstr_guid(riid),ppvObject);
603 if ( This->riidInst==NULL ||
604 IsEqualCLSID(riid, This->riidInst) ||
605 IsEqualCLSID(riid, &IID_IUnknown) )
607 return This->lpfnCI(pUnkOuter, riid, ppvObject);
610 ERR("unknown IID requested %s\n",shdebugstr_guid(riid));
611 return E_NOINTERFACE;
613 /******************************************************************************
614 * IDefClF_fnLockServer
616 static HRESULT WINAPI IDefClF_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
618 ICOM_THIS(IDefClFImpl,iface);
619 TRACE("%p->(0x%x), not implemented\n",This, fLock);
623 static ICOM_VTABLE(IClassFactory) dclfvt =
625 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
626 IDefClF_fnQueryInterface,
629 IDefClF_fnCreateInstance,
633 /******************************************************************************
634 * SHCreateDefClassObject [SHELL32.70]
636 HRESULT WINAPI SHCreateDefClassObject(
639 LPFNCREATEINSTANCE lpfnCI, /* [in] create instance callback entry */
640 LPDWORD pcRefDll, /* [in/out] ref count of the dll */
641 REFIID riidInst) /* [in] optional interface to the instance */
645 TRACE("%s %p %p %p %s\n",
646 shdebugstr_guid(riid), ppv, lpfnCI, pcRefDll, shdebugstr_guid(riidInst));
648 if (! IsEqualCLSID(riid, &IID_IClassFactory) ) return E_NOINTERFACE;
649 if (! (pcf = IDefClF_fnConstructor(lpfnCI, pcRefDll, riidInst))) return E_OUTOFMEMORY;
654 /*************************************************************************
655 * DragAcceptFiles [SHELL32.54]
657 void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
661 if( !IsWindow(hWnd) ) return;
662 exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE);
664 exstyle |= WS_EX_ACCEPTFILES;
666 exstyle &= ~WS_EX_ACCEPTFILES;
667 SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle);
670 /*************************************************************************
671 * DragFinish [SHELL32.80]
673 void WINAPI DragFinish(HDROP h)
676 GlobalFree((HGLOBAL)h);
679 /*************************************************************************
680 * DragQueryPoint [SHELL32.135]
682 BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p)
684 DROPFILES *lpDropFileStruct;
689 lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
691 *p = lpDropFileStruct->pt;
692 bRet = lpDropFileStruct->fNC;
698 /*************************************************************************
699 * DragQueryFile [SHELL32.81]
700 * DragQueryFileA [SHELL32.82]
702 UINT WINAPI DragQueryFileA(
710 DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
712 TRACE("(%p, %x, %p, %u)\n", hDrop,lFile,lpszFile,lLength);
714 if(!lpDropFileStruct) goto end;
716 lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->pFiles;
718 if(lpDropFileStruct->fWide == TRUE) {
719 LPWSTR lpszFileW = NULL;
722 lpszFileW = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR));
723 if(lpszFileW == NULL) {
727 i = DragQueryFileW(hDrop, lFile, lpszFileW, lLength);
730 WideCharToMultiByte(CP_ACP, 0, lpszFileW, -1, lpszFile, lLength, 0, NULL);
731 HeapFree(GetProcessHeap(), 0, lpszFileW);
738 while (*lpDrop++); /* skip filename */
741 i = (lFile == 0xFFFFFFFF) ? i : 0;
748 if (!lpszFile ) goto end; /* needed buffer size */
749 i = (lLength > i) ? i : lLength;
750 lstrcpynA (lpszFile, lpDrop, i);
756 /*************************************************************************
757 * DragQueryFileW [SHELL32.133]
759 UINT WINAPI DragQueryFileW(
767 DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
769 TRACE("(%p, %x, %p, %u)\n", hDrop,lFile,lpszwFile,lLength);
771 if(!lpDropFileStruct) goto end;
773 lpwDrop = (LPWSTR) ((LPSTR)lpDropFileStruct + lpDropFileStruct->pFiles);
775 if(lpDropFileStruct->fWide == FALSE) {
776 LPSTR lpszFileA = NULL;
779 lpszFileA = (LPSTR) HeapAlloc(GetProcessHeap(), 0, lLength);
780 if(lpszFileA == NULL) {
784 i = DragQueryFileA(hDrop, lFile, lpszFileA, lLength);
787 MultiByteToWideChar(CP_ACP, 0, lpszFileA, -1, lpszwFile, lLength);
788 HeapFree(GetProcessHeap(), 0, lpszFileA);
796 while (*lpwDrop++); /* skip filename */
799 i = (lFile == 0xFFFFFFFF) ? i : 0;
804 i = strlenW(lpwDrop);
806 if ( !lpszwFile) goto end; /* needed buffer size */
808 i = (lLength > i) ? i : lLength;
809 lstrcpynW (lpszwFile, lpwDrop, i);