Changes in crossover-wine-src-6.1.0 except for configure
[wine/hacks.git] / dlls / shell32 / shellole.c
blob830c3cdd7c47eb338186b2b73c57bf2c123ba9dd
1 /*
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
24 #include <stdarg.h>
25 #include <stdlib.h>
26 #include <string.h>
28 #define COBJMACROS
30 #include "windef.h"
31 #include "winbase.h"
32 #include "shellapi.h"
33 #include "wingdi.h"
34 #include "winuser.h"
35 #include "shlobj.h"
36 #include "shlguid.h"
37 #include "winreg.h"
38 #include "winerror.h"
40 #include "undocshell.h"
41 #include "wine/unicode.h"
42 #include "shell32_main.h"
44 #include "wine/debug.h"
45 #include "shlwapi.h"
46 #include "debughlp.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(shell);
50 extern HRESULT WINAPI IFSFolder_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
52 static const WCHAR sShell32[12] = {'S','H','E','L','L','3','2','.','D','L','L','\0'};
54 /**************************************************************************
55 * Default ClassFactory types
57 typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject);
58 static IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst);
60 /* this table contains all CLSID's of shell32 objects */
61 static const struct {
62 REFIID riid;
63 LPFNCREATEINSTANCE lpfnCI;
64 } InterfaceTable[] = {
65 {&CLSID_ShellFSFolder, &IFSFolder_Constructor},
66 {&CLSID_MyComputer, &ISF_MyComputer_Constructor},
67 {&CLSID_NetworkPlaces, &ISF_NetworkPlaces_Constructor},
68 {&CLSID_ShellDesktop, &ISF_Desktop_Constructor},
69 {&CLSID_ShellLink, &IShellLink_Constructor},
70 {&CLSID_DragDropHelper, &IDropTargetHelper_Constructor},
71 {&CLSID_ControlPanel, &IControlPanel_Constructor},
72 {&CLSID_AutoComplete, &IAutoComplete_Constructor},
73 {&CLSID_UnixFolder, &UnixFolder_Constructor},
74 {&CLSID_UnixDosFolder, &UnixDosFolder_Constructor},
75 {&CLSID_FolderShortcut, &FolderShortcut_Constructor},
76 {&CLSID_MyDocuments, &MyDocuments_Constructor},
77 {&CLSID_RecycleBin, &RecycleBin_Constructor},
78 {NULL,NULL}
82 /* FIXME: this should be SHLWAPI.24 since we can't yet import by ordinal */
84 DWORD WINAPI __SHGUIDToStringW (REFGUID guid, LPWSTR str)
86 WCHAR sFormat[52] = {'{','%','0','8','l','x','-','%','0','4',
87 'x','-','%','0','4','x','-','%','0','2',
88 'x','%','0','2','x','-','%','0','2','x',
89 '%','0','2','x','%','0','2','x','%','0',
90 '2','x','%','0','2','x','%','0','2','x',
91 '}','\0'};
93 return wsprintfW ( str, sFormat,
94 guid->Data1, guid->Data2, guid->Data3,
95 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
96 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
100 /*************************************************************************
101 * SHCoCreateInstance [SHELL32.102]
103 * Equivalent to CoCreateInstance. Under Windows 9x this function could sometimes
104 * use the shell32 built-in "mini-COM" without the need to load ole32.dll - see
105 * SHLoadOLE for details.
107 * Under wine if a "LoadWithoutCOM" value is present or the object resides in
108 * shell32.dll the function will load the object manually without the help of ole32
110 * NOTES
111 * exported by ordinal
113 * SEE ALSO
114 * CoCreateInstace, SHLoadOLE
116 HRESULT WINAPI SHCoCreateInstance(
117 LPCWSTR aclsid,
118 const CLSID *clsid,
119 LPUNKNOWN pUnkOuter,
120 REFIID refiid,
121 LPVOID *ppv)
123 DWORD hres;
124 IID iid;
125 const CLSID * myclsid = clsid;
126 WCHAR sKeyName[MAX_PATH];
127 const WCHAR sCLSID[7] = {'C','L','S','I','D','\\','\0'};
128 WCHAR sClassID[60];
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];
132 HKEY hKey;
133 DWORD dwSize;
134 BOOLEAN bLoadFromShell32 = FALSE;
135 BOOLEAN bLoadWithoutCOM = FALSE;
136 IClassFactory * pcf = NULL;
138 if(!ppv) return E_POINTER;
139 *ppv=NULL;
141 /* if the clsid is a string, convert it */
142 if (!clsid)
144 if (!aclsid) return REGDB_E_CLASSNOTREG;
145 SHCLSIDFromStringW(aclsid, &iid);
146 myclsid = &iid;
149 TRACE("(%p,%s,unk:%p,%s,%p)\n",
150 aclsid,shdebugstr_guid(myclsid),pUnkOuter,shdebugstr_guid(refiid),ppv);
152 /* we look up the dll path in the registry */
153 __SHGUIDToStringW(myclsid, sClassID);
154 lstrcpyW(sKeyName, sCLSID);
155 lstrcatW(sKeyName, sClassID);
156 lstrcatW(sKeyName, sInProcServer32);
158 if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, sKeyName, 0, KEY_READ, &hKey)) {
159 dwSize = sizeof(sDllPath);
160 SHQueryValueExW(hKey, NULL, 0,0, sDllPath, &dwSize );
162 /* if a special registry key is set, we load a shell extension without help of OLE32 */
163 bLoadWithoutCOM = (ERROR_SUCCESS == SHQueryValueExW(hKey, sLoadWithoutCOM, 0, 0, 0, 0));
165 /* if the com object is inside shell32, omit use of ole32 */
166 bLoadFromShell32 = (0==lstrcmpiW( PathFindFileNameW(sDllPath), sShell32));
168 RegCloseKey (hKey);
169 } else {
170 /* since we can't find it in the registry we try internally */
171 bLoadFromShell32 = TRUE;
174 TRACE("WithoutCom=%u FromShell=%u\n", bLoadWithoutCOM, bLoadFromShell32);
176 /* now we create an instance */
177 if (bLoadFromShell32) {
178 if (! SUCCEEDED(DllGetClassObject(myclsid, &IID_IClassFactory,(LPVOID*)&pcf))) {
179 ERR("LoadFromShell failed for CLSID=%s\n", shdebugstr_guid(myclsid));
181 } else if (bLoadWithoutCOM) {
183 /* load an external dll without ole32 */
184 HANDLE hLibrary;
185 typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv);
186 DllGetClassObjectFunc DllGetClassObject;
188 if ((hLibrary = LoadLibraryExW(sDllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH)) == 0) {
189 ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath));
190 hres = E_ACCESSDENIED;
191 goto end;
192 } else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"))) {
193 ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath));
194 FreeLibrary( hLibrary );
195 hres = E_ACCESSDENIED;
196 goto end;
197 } else if (! SUCCEEDED(hres = DllGetClassObject(myclsid, &IID_IClassFactory, (LPVOID*)&pcf))) {
198 TRACE("GetClassObject failed 0x%08x\n", hres);
199 goto end;
202 } else {
204 /* load an external dll in the usual way */
205 hres = CoCreateInstance(myclsid, pUnkOuter, CLSCTX_INPROC_SERVER, refiid, ppv);
206 goto end;
209 /* here we should have a ClassFactory */
210 if (!pcf) return E_ACCESSDENIED;
212 hres = IClassFactory_CreateInstance(pcf, pUnkOuter, refiid, ppv);
213 IClassFactory_Release(pcf);
214 end:
215 if(hres!=S_OK)
217 ERR("failed (0x%08x) to create CLSID:%s IID:%s\n",
218 hres, shdebugstr_guid(myclsid), shdebugstr_guid(refiid));
219 ERR("class not found in registry\n");
222 TRACE("-- instance: %p\n",*ppv);
223 return hres;
226 /*************************************************************************
227 * DllGetClassObject [SHELL32.@]
228 * SHDllGetClassObject [SHELL32.128]
230 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
232 HRESULT hres = E_OUTOFMEMORY;
233 IClassFactory * pcf = NULL;
234 int i;
236 TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid),shdebugstr_guid(iid));
238 if (!ppv) return E_INVALIDARG;
239 *ppv = NULL;
241 /* search our internal interface table */
242 for(i=0;InterfaceTable[i].riid;i++) {
243 if(IsEqualIID(InterfaceTable[i].riid, rclsid)) {
244 TRACE("index[%u]\n", i);
245 pcf = IDefClF_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL);
249 if (!pcf) {
250 FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid));
251 return CLASS_E_CLASSNOTAVAILABLE;
254 hres = IClassFactory_QueryInterface(pcf, iid, ppv);
255 IClassFactory_Release(pcf);
257 TRACE("-- pointer to class factory: %p\n",*ppv);
258 return hres;
261 /*************************************************************************
262 * SHCLSIDFromString [SHELL32.147]
264 * Under Windows 9x this was an ANSI version of CLSIDFromString. It also allowed
265 * to avoid dependency on ole32.dll (see SHLoadOLE for details).
267 * Under Windows NT/2000/XP this is equivalent to CLSIDFromString
269 * NOTES
270 * exported by ordinal
272 * SEE ALSO
273 * CLSIDFromString, SHLoadOLE
275 DWORD WINAPI SHCLSIDFromStringA (LPCSTR clsid, CLSID *id)
277 WCHAR buffer[40];
278 TRACE("(%p(%s) %p)\n", clsid, clsid, id);
279 if (!MultiByteToWideChar( CP_ACP, 0, clsid, -1, buffer, sizeof(buffer)/sizeof(WCHAR) ))
280 return CO_E_CLASSSTRING;
281 return CLSIDFromString( buffer, id );
283 DWORD WINAPI SHCLSIDFromStringW (LPCWSTR clsid, CLSID *id)
285 TRACE("(%p(%s) %p)\n", clsid, debugstr_w(clsid), id);
286 return CLSIDFromString((LPWSTR)clsid, id);
288 DWORD WINAPI SHCLSIDFromStringAW (LPVOID clsid, CLSID *id)
290 if (SHELL_OsIsUnicode())
291 return SHCLSIDFromStringW (clsid, id);
292 return SHCLSIDFromStringA (clsid, id);
295 /*************************************************************************
296 * SHGetMalloc [SHELL32.@]
298 * Equivalent to CoGetMalloc(MEMCTX_TASK, ...). Under Windows 9x this function
299 * could use the shell32 built-in "mini-COM" without the need to load ole32.dll -
300 * see SHLoadOLE for details.
302 * PARAMS
303 * lpmal [O] Destination for IMalloc interface.
305 * RETURNS
306 * Success: S_OK. lpmal contains the shells IMalloc interface.
307 * Failure. An HRESULT error code.
309 * SEE ALSO
310 * CoGetMalloc, SHLoadOLE
312 HRESULT WINAPI SHGetMalloc(LPMALLOC *lpmal)
314 TRACE("(%p)\n", lpmal);
315 return CoGetMalloc(MEMCTX_TASK, lpmal);
318 /*************************************************************************
319 * SHAlloc [SHELL32.196]
321 * Equivalent to CoTaskMemAlloc. Under Windows 9x this function could use
322 * the shell32 built-in "mini-COM" without the need to load ole32.dll -
323 * see SHLoadOLE for details.
325 * NOTES
326 * exported by ordinal
328 * SEE ALSO
329 * CoTaskMemAlloc, SHLoadOLE
331 LPVOID WINAPI SHAlloc(DWORD len)
333 LPVOID ret;
335 ret = CoTaskMemAlloc(len);
336 TRACE("%u bytes at %p\n",len, ret);
337 return ret;
340 /*************************************************************************
341 * SHFree [SHELL32.195]
343 * Equivalent to CoTaskMemFree. Under Windows 9x this function could use
344 * the shell32 built-in "mini-COM" without the need to load ole32.dll -
345 * see SHLoadOLE for details.
347 * NOTES
348 * exported by ordinal
350 * SEE ALSO
351 * CoTaskMemFree, SHLoadOLE
353 void WINAPI SHFree(LPVOID pv)
355 TRACE("%p\n",pv);
356 CoTaskMemFree(pv);
359 /*************************************************************************
360 * SHGetDesktopFolder [SHELL32.@]
362 HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
364 HRESULT hres = S_OK;
365 TRACE("\n");
367 if(!psf) return E_INVALIDARG;
368 *psf = NULL;
369 hres = ISF_Desktop_Constructor(NULL, &IID_IShellFolder,(LPVOID*)psf);
371 TRACE("-- %p->(%p)\n",psf, *psf);
372 return hres;
374 /**************************************************************************
375 * Default ClassFactory Implementation
377 * SHCreateDefClassObject
379 * NOTES
380 * Helper function for dlls without their own classfactory.
381 * A generic classfactory is returned.
382 * When the CreateInstance of the cf is called the callback is executed.
385 typedef struct
387 const IClassFactoryVtbl *lpVtbl;
388 LONG ref;
389 CLSID *rclsid;
390 LPFNCREATEINSTANCE lpfnCI;
391 const IID * riidInst;
392 LONG * pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */
393 } IDefClFImpl;
395 static const IClassFactoryVtbl dclfvt;
397 /**************************************************************************
398 * IDefClF_fnConstructor
401 static IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
403 IDefClFImpl* lpclf;
405 lpclf = HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl));
406 lpclf->ref = 1;
407 lpclf->lpVtbl = &dclfvt;
408 lpclf->lpfnCI = lpfnCI;
409 lpclf->pcRefDll = pcRefDll;
411 if (pcRefDll) InterlockedIncrement(pcRefDll);
412 lpclf->riidInst = riidInst;
414 TRACE("(%p)%s\n",lpclf, shdebugstr_guid(riidInst));
415 return (LPCLASSFACTORY)lpclf;
417 /**************************************************************************
418 * IDefClF_fnQueryInterface
420 static HRESULT WINAPI IDefClF_fnQueryInterface(
421 LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
423 IDefClFImpl *This = (IDefClFImpl *)iface;
425 TRACE("(%p)->(%s)\n",This,shdebugstr_guid(riid));
427 *ppvObj = NULL;
429 if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory)) {
430 *ppvObj = This;
431 InterlockedIncrement(&This->ref);
432 return S_OK;
435 TRACE("-- E_NOINTERFACE\n");
436 return E_NOINTERFACE;
438 /******************************************************************************
439 * IDefClF_fnAddRef
441 static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface)
443 IDefClFImpl *This = (IDefClFImpl *)iface;
444 ULONG refCount = InterlockedIncrement(&This->ref);
446 TRACE("(%p)->(count=%u)\n", This, refCount - 1);
448 return refCount;
450 /******************************************************************************
451 * IDefClF_fnRelease
453 static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface)
455 IDefClFImpl *This = (IDefClFImpl *)iface;
456 ULONG refCount = InterlockedDecrement(&This->ref);
458 TRACE("(%p)->(count=%u)\n", This, refCount + 1);
460 if (!refCount)
462 if (This->pcRefDll) InterlockedDecrement(This->pcRefDll);
464 TRACE("-- destroying IClassFactory(%p)\n",This);
465 HeapFree(GetProcessHeap(),0,This);
466 return 0;
468 return refCount;
470 /******************************************************************************
471 * IDefClF_fnCreateInstance
473 static HRESULT WINAPI IDefClF_fnCreateInstance(
474 LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
476 IDefClFImpl *This = (IDefClFImpl *)iface;
478 TRACE("%p->(%p,%s,%p)\n",This,pUnkOuter,shdebugstr_guid(riid),ppvObject);
480 *ppvObject = NULL;
482 if ( This->riidInst==NULL ||
483 IsEqualCLSID(riid, This->riidInst) ||
484 IsEqualCLSID(riid, &IID_IUnknown) )
486 return This->lpfnCI(pUnkOuter, riid, ppvObject);
489 ERR("unknown IID requested %s\n",shdebugstr_guid(riid));
490 return E_NOINTERFACE;
492 /******************************************************************************
493 * IDefClF_fnLockServer
495 static HRESULT WINAPI IDefClF_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
497 IDefClFImpl *This = (IDefClFImpl *)iface;
498 TRACE("%p->(0x%x), not implemented\n",This, fLock);
499 return E_NOTIMPL;
502 static const IClassFactoryVtbl dclfvt =
504 IDefClF_fnQueryInterface,
505 IDefClF_fnAddRef,
506 IDefClF_fnRelease,
507 IDefClF_fnCreateInstance,
508 IDefClF_fnLockServer
511 /******************************************************************************
512 * SHCreateDefClassObject [SHELL32.70]
514 HRESULT WINAPI SHCreateDefClassObject(
515 REFIID riid,
516 LPVOID* ppv,
517 LPFNCREATEINSTANCE lpfnCI, /* [in] create instance callback entry */
518 LPDWORD pcRefDll, /* [in/out] ref count of the dll */
519 REFIID riidInst) /* [in] optional interface to the instance */
521 IClassFactory * pcf;
523 TRACE("%s %p %p %p %s\n",
524 shdebugstr_guid(riid), ppv, lpfnCI, pcRefDll, shdebugstr_guid(riidInst));
526 if (! IsEqualCLSID(riid, &IID_IClassFactory) ) return E_NOINTERFACE;
527 if (! (pcf = IDefClF_fnConstructor(lpfnCI, (PLONG)pcRefDll, riidInst))) return E_OUTOFMEMORY;
528 *ppv = pcf;
529 return NOERROR;
532 /*************************************************************************
533 * DragAcceptFiles [SHELL32.@]
535 void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
537 LONG exstyle;
539 if( !IsWindow(hWnd) ) return;
540 exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE);
541 if (b)
542 exstyle |= WS_EX_ACCEPTFILES;
543 else
544 exstyle &= ~WS_EX_ACCEPTFILES;
545 SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle);
548 /*************************************************************************
549 * DragFinish [SHELL32.@]
551 void WINAPI DragFinish(HDROP h)
553 TRACE("\n");
554 GlobalFree((HGLOBAL)h);
557 /*************************************************************************
558 * DragQueryPoint [SHELL32.@]
560 BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p)
562 DROPFILES *lpDropFileStruct;
563 BOOL bRet;
565 TRACE("\n");
567 lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
569 *p = lpDropFileStruct->pt;
570 bRet = lpDropFileStruct->fNC;
572 GlobalUnlock(hDrop);
573 return bRet;
576 /*************************************************************************
577 * DragQueryFileA [SHELL32.@]
578 * DragQueryFile [SHELL32.@]
580 UINT WINAPI DragQueryFileA(
581 HDROP hDrop,
582 UINT lFile,
583 LPSTR lpszFile,
584 UINT lLength)
586 LPSTR lpDrop;
587 UINT i = 0;
588 DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
590 TRACE("(%p, %x, %p, %u)\n", hDrop,lFile,lpszFile,lLength);
592 if(!lpDropFileStruct) goto end;
594 lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->pFiles;
596 if(lpDropFileStruct->fWide) {
597 LPWSTR lpszFileW = NULL;
599 if(lpszFile) {
600 lpszFileW = HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR));
601 if(lpszFileW == NULL) {
602 goto end;
605 i = DragQueryFileW(hDrop, lFile, lpszFileW, lLength);
607 if(lpszFileW) {
608 WideCharToMultiByte(CP_ACP, 0, lpszFileW, -1, lpszFile, lLength, 0, NULL);
609 HeapFree(GetProcessHeap(), 0, lpszFileW);
611 goto end;
614 while (i++ < lFile)
616 while (*lpDrop++); /* skip filename */
617 if (!*lpDrop)
619 i = (lFile == 0xFFFFFFFF) ? i : 0;
620 goto end;
624 i = strlen(lpDrop);
625 i++;
626 if (!lpszFile ) goto end; /* needed buffer size */
627 i = (lLength > i) ? i : lLength;
628 lstrcpynA (lpszFile, lpDrop, i);
629 end:
630 GlobalUnlock(hDrop);
631 return i;
634 /*************************************************************************
635 * DragQueryFileW [SHELL32.@]
637 UINT WINAPI DragQueryFileW(
638 HDROP hDrop,
639 UINT lFile,
640 LPWSTR lpszwFile,
641 UINT lLength)
643 LPWSTR lpwDrop;
644 UINT i = 0;
645 DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
647 TRACE("(%p, %x, %p, %u)\n", hDrop,lFile,lpszwFile,lLength);
649 if(!lpDropFileStruct) goto end;
651 lpwDrop = (LPWSTR) ((LPSTR)lpDropFileStruct + lpDropFileStruct->pFiles);
653 if(lpDropFileStruct->fWide == FALSE) {
654 LPSTR lpszFileA = NULL;
656 if(lpszwFile) {
657 lpszFileA = HeapAlloc(GetProcessHeap(), 0, lLength);
658 if(lpszFileA == NULL) {
659 goto end;
662 i = DragQueryFileA(hDrop, lFile, lpszFileA, lLength);
664 if(lpszFileA) {
665 MultiByteToWideChar(CP_ACP, 0, lpszFileA, -1, lpszwFile, lLength);
666 HeapFree(GetProcessHeap(), 0, lpszFileA);
668 goto end;
671 i = 0;
672 while (i++ < lFile)
674 while (*lpwDrop++); /* skip filename */
675 if (!*lpwDrop)
677 i = (lFile == 0xFFFFFFFF) ? i : 0;
678 goto end;
682 i = strlenW(lpwDrop);
683 i++;
684 if ( !lpszwFile) goto end; /* needed buffer size */
686 i = (lLength > i) ? i : lLength;
687 lstrcpynW (lpszwFile, lpwDrop, i);
688 end:
689 GlobalUnlock(hDrop);
690 return i;