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
[] = {
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
},
70 {&CLSID_ControlPanel
, &IControlPanel_Constructor
},
74 /*************************************************************************
75 * __CoCreateInstance [internal]
78 * wraper for late bound call to OLE32.DLL
81 HRESULT (WINAPI
*pCoCreateInstance
)(REFCLSID rclsid
, LPUNKNOWN pUnkOuter
, DWORD dwClsContext
, REFIID iid
, LPVOID
*ppv
) = NULL
;
83 void * __GetExternalFunc(HMODULE
* phModule
, LPCWSTR szModuleName
, LPCSTR szProcName
)
85 if (!*phModule
) *phModule
= GetModuleHandleW(szModuleName
);
86 if (!*phModule
) *phModule
= LoadLibraryW(szModuleName
);
87 if (*phModule
) return GetProcAddress(*phModule
, szProcName
);
91 HRESULT
__CoCreateInstance(REFCLSID rclsid
, LPUNKNOWN pUnkOuter
, DWORD dwClsContext
, REFIID iid
, LPVOID
*ppv
)
93 if(!pCoCreateInstance
) pCoCreateInstance
= __GetExternalFunc(&hShellOle32
, sOLE32
, "CoCreateInstance");
94 if(!pCoCreateInstance
) return E_FAIL
;
95 return pCoCreateInstance(rclsid
, pUnkOuter
, dwClsContext
, iid
, ppv
);
98 /*************************************************************************
99 * SHCoCreateInstance [SHELL32.102]
102 * exported by ordinal
105 /* FIXME: this should be SHLWAPI.24 since we can't yet import by ordinal */
107 DWORD WINAPI
__SHGUIDToStringW (REFGUID guid
, LPWSTR str
)
109 WCHAR sFormat
[52] = {'{','%','0','8','l','x','-','%','0','4',
110 'x','-','%','0','4','x','-','%','0','2',
111 'x','%','0','2','x','-','%','0','2','x',
112 '%','0','2','x','%','0','2','x','%','0',
113 '2','x','%','0','2','x','%','0','2','x',
116 return wsprintfW ( str
, sFormat
,
117 guid
->Data1
, guid
->Data2
, guid
->Data3
,
118 guid
->Data4
[0], guid
->Data4
[1], guid
->Data4
[2], guid
->Data4
[3],
119 guid
->Data4
[4], guid
->Data4
[5], guid
->Data4
[6], guid
->Data4
[7] );
123 /************************************************************************/
125 LRESULT WINAPI
SHCoCreateInstance(
134 CLSID
* myclsid
= (CLSID
*)clsid
;
135 WCHAR sKeyName
[MAX_PATH
];
136 const WCHAR sCLSID
[7] = {'C','L','S','I','D','\\','\0'};
138 const WCHAR sInProcServer32
[16] ={'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2','\0'};
139 const WCHAR sLoadWithoutCOM
[15] ={'L','o','a','d','W','i','t','h','o','u','t','C','O','M','\0'};
140 WCHAR sDllPath
[MAX_PATH
];
143 BOOLEAN bLoadFromShell32
= FALSE
;
144 BOOLEAN bLoadWithoutCOM
= FALSE
;
145 IClassFactory
* pcf
= NULL
;
147 if(!ppv
) return E_POINTER
;
150 /* if the clsid is a string, convert it */
153 if (!aclsid
) return REGDB_E_CLASSNOTREG
;
154 SHCLSIDFromStringW(aclsid
, &iid
);
158 TRACE("(%p,%s,unk:%p,%s,%p)\n",
159 aclsid
,shdebugstr_guid(myclsid
),pUnkOuter
,shdebugstr_guid(refiid
),ppv
);
161 /* we look up the dll path in the registry */
162 __SHGUIDToStringW(myclsid
, sClassID
);
163 lstrcpyW(sKeyName
, sCLSID
);
164 lstrcatW(sKeyName
, sClassID
);
165 lstrcatW(sKeyName
, sInProcServer32
);
167 if (ERROR_SUCCESS
== RegOpenKeyExW(HKEY_CLASSES_ROOT
, sKeyName
, 0, KEY_READ
, &hKey
)) {
168 dwSize
= sizeof(sDllPath
);
169 SHQueryValueExW(hKey
, NULL
, 0,0, sDllPath
, &dwSize
);
171 /* if a special registry key is set, we load a shell extension without help of OLE32 */
172 bLoadWithoutCOM
= (ERROR_SUCCESS
== SHQueryValueExW(hKey
, sLoadWithoutCOM
, 0, 0, 0, 0));
174 /* if the com object is inside shell32, omit use of ole32 */
175 bLoadFromShell32
= (0==lstrcmpiW( PathFindFileNameW(sDllPath
), sShell32
));
179 /* since we can't find it in the registry we try internally */
180 bLoadFromShell32
= TRUE
;
183 TRACE("WithoutCom=%u FromShell=%u\n", bLoadWithoutCOM
, bLoadFromShell32
);
185 /* now we create a instance */
186 if (bLoadFromShell32
) {
187 if (! SUCCEEDED(SHELL32_DllGetClassObject(myclsid
, &IID_IClassFactory
,(LPVOID
*)&pcf
))) {
188 ERR("LoadFromShell failed for CLSID=%s\n", shdebugstr_guid(myclsid
));
190 } else if (bLoadWithoutCOM
) {
192 /* load a external dll without ole32 */
194 typedef HRESULT (CALLBACK
*DllGetClassObjectFunc
)(REFCLSID clsid
, REFIID iid
, LPVOID
*ppv
);
195 DllGetClassObjectFunc DllGetClassObject
;
197 if ((hLibrary
= LoadLibraryExW(sDllPath
, 0, LOAD_WITH_ALTERED_SEARCH_PATH
)) == 0) {
198 ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath
));
199 hres
= E_ACCESSDENIED
;
201 } else if (!(DllGetClassObject
= (DllGetClassObjectFunc
)GetProcAddress(hLibrary
, "DllGetClassObject"))) {
202 ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath
));
203 FreeLibrary( hLibrary
);
204 hres
= E_ACCESSDENIED
;
206 } else if (! SUCCEEDED(hres
= DllGetClassObject(myclsid
, &IID_IClassFactory
, (LPVOID
*)&pcf
))) {
207 TRACE("GetClassObject failed 0x%08lx\n", hres
);
213 /* load a external dll in the usual way */
214 hres
= __CoCreateInstance(myclsid
, pUnkOuter
, CLSCTX_INPROC_SERVER
, refiid
, ppv
);
218 /* here we should have a ClassFactory */
219 if (!pcf
) return E_ACCESSDENIED
;
221 hres
= IClassFactory_CreateInstance(pcf
, pUnkOuter
, refiid
, ppv
);
222 IClassFactory_Release(pcf
);
226 ERR("failed (0x%08lx) to create CLSID:%s IID:%s\n",
227 hres
, shdebugstr_guid(myclsid
), shdebugstr_guid(refiid
));
228 ERR("class not found in registry\n");
231 TRACE("-- instance: %p\n",*ppv
);
235 /*************************************************************************
236 * DllGetClassObject [SHELL32.128]
238 HRESULT WINAPI
SHELL32_DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
240 HRESULT hres
= E_OUTOFMEMORY
;
241 IClassFactory
* pcf
= NULL
;
244 TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid
),shdebugstr_guid(iid
));
246 if (!ppv
) return E_INVALIDARG
;
249 /* search our internal interface table */
250 for(i
=0;InterfaceTable
[i
].riid
;i
++) {
251 if(IsEqualIID(InterfaceTable
[i
].riid
, rclsid
)) {
252 TRACE("index[%u]\n", i
);
253 pcf
= IDefClF_fnConstructor(InterfaceTable
[i
].lpfnCI
, NULL
, NULL
);
258 FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid
));
259 return CLASS_E_CLASSNOTAVAILABLE
;
262 hres
= IClassFactory_QueryInterface(pcf
, iid
, ppv
);
263 IClassFactory_Release(pcf
);
265 TRACE("-- pointer to class factory: %p\n",*ppv
);
269 /*************************************************************************
270 * SHCLSIDFromString [SHELL32.147]
273 * exported by ordinal
275 DWORD WINAPI
SHCLSIDFromStringA (LPCSTR clsid
, CLSID
*id
)
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 * Shell Memory Allocator
299 /* set the vtable later */
300 extern ICOM_VTABLE(IMalloc
) VT_Shell_IMalloc32
;
302 /* this is the static object instance */
304 ICOM_VFIELD(IMalloc
);
308 _ShellMalloc Shell_Malloc
= { &VT_Shell_IMalloc32
,1};
310 /* this is the global allocator of shell32 */
311 IMalloc
* ShellTaskAllocator
= NULL
;
313 /******************************************************************************
314 * IShellMalloc_QueryInterface [VTABLE]
316 static HRESULT WINAPI
IShellMalloc_fnQueryInterface(LPMALLOC iface
, REFIID refiid
, LPVOID
*obj
)
318 TRACE("(%s,%p)\n",shdebugstr_guid(refiid
),obj
);
319 if (IsEqualIID(refiid
, &IID_IUnknown
) || IsEqualIID(refiid
, &IID_IMalloc
)) {
320 *obj
= (LPMALLOC
) &Shell_Malloc
;
323 return E_NOINTERFACE
;
326 /******************************************************************************
327 * IShellMalloc_AddRefRelease [VTABLE]
329 static ULONG WINAPI
IShellMalloc_fnAddRefRelease(LPMALLOC iface
)
334 /******************************************************************************
335 * IShellMalloc_Alloc [VTABLE]
337 static LPVOID WINAPI
IShellMalloc_fnAlloc(LPMALLOC iface
, DWORD cb
)
341 addr
= (LPVOID
) LocalAlloc(GMEM_ZEROINIT
, cb
);
342 TRACE("(%p,%ld);\n",addr
,cb
);
346 /******************************************************************************
347 * IShellMalloc_Realloc [VTABLE]
349 static LPVOID WINAPI
IShellMalloc_fnRealloc(LPMALLOC iface
, LPVOID pv
, DWORD cb
)
355 addr
= (LPVOID
) LocalReAlloc((HANDLE
) pv
, cb
, GMEM_ZEROINIT
| GMEM_MOVEABLE
);
357 LocalFree((HANDLE
) pv
);
362 addr
= (LPVOID
) LocalAlloc(GMEM_ZEROINIT
, cb
);
368 TRACE("(%p->%p,%ld)\n",pv
,addr
,cb
);
372 /******************************************************************************
373 * IShellMalloc_Free [VTABLE]
375 static VOID WINAPI
IShellMalloc_fnFree(LPMALLOC iface
, LPVOID pv
)
378 LocalFree((HANDLE
) pv
);
381 /******************************************************************************
382 * IShellMalloc_GetSize [VTABLE]
384 static DWORD WINAPI
IShellMalloc_fnGetSize(LPMALLOC iface
, LPVOID pv
)
386 DWORD cb
= (DWORD
) LocalSize((HANDLE
)pv
);
387 TRACE("(%p,%ld)\n", pv
, cb
);
391 /******************************************************************************
392 * IShellMalloc_DidAlloc [VTABLE]
394 static INT WINAPI
IShellMalloc_fnDidAlloc(LPMALLOC iface
, LPVOID pv
)
400 /******************************************************************************
401 * IShellMalloc_HeapMinimize [VTABLE]
403 static VOID WINAPI
IShellMalloc_fnHeapMinimize(LPMALLOC iface
)
408 static ICOM_VTABLE(IMalloc
) VT_Shell_IMalloc32
=
410 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
411 IShellMalloc_fnQueryInterface
,
412 IShellMalloc_fnAddRefRelease
,
413 IShellMalloc_fnAddRefRelease
,
414 IShellMalloc_fnAlloc
,
415 IShellMalloc_fnRealloc
,
417 IShellMalloc_fnGetSize
,
418 IShellMalloc_fnDidAlloc
,
419 IShellMalloc_fnHeapMinimize
422 /*************************************************************************
423 * SHGetMalloc [SHELL32.@]
425 * Return the shell IMalloc interface.
428 * lpmal [O] Destination for IMalloc interface.
431 * Success: S_OK. lpmal contains the shells IMalloc interface.
432 * Failure. An HRESULT error code.
435 * This function will use CoGetMalloc() if OLE32.DLL is already loaded.
436 * If not it uses an internal implementation as a fallback.
438 HRESULT WINAPI
SHGetMalloc(LPMALLOC
*lpmal
)
440 HRESULT (WINAPI
*pCoGetMalloc
)(DWORD
,LPMALLOC
*);
443 TRACE("(%p)\n", lpmal
);
445 if (!ShellTaskAllocator
)
447 hOle32
= GetModuleHandleA("OLE32.DLL");
449 pCoGetMalloc
= (void*) GetProcAddress(hOle32
, "CoGetMalloc");
450 if (pCoGetMalloc
) pCoGetMalloc(MEMCTX_TASK
, &ShellTaskAllocator
);
451 TRACE("got ole32 IMalloc\n");
453 if(!ShellTaskAllocator
) {
454 ShellTaskAllocator
= (IMalloc
* ) &Shell_Malloc
;
455 TRACE("use fallback allocator\n");
458 *lpmal
= ShellTaskAllocator
;
462 /*************************************************************************
463 * SHAlloc [SHELL32.196]
466 * exported by ordinal
468 LPVOID WINAPI
SHAlloc(DWORD len
)
473 if (!ShellTaskAllocator
) SHGetMalloc(&ppv
);
475 ret
= (LPVOID
) IMalloc_Alloc(ShellTaskAllocator
, len
);
476 TRACE("%lu bytes at %p\n",len
, ret
);
480 /*************************************************************************
481 * SHFree [SHELL32.195]
484 * exported by ordinal
486 void WINAPI
SHFree(LPVOID pv
)
491 if (!ShellTaskAllocator
) SHGetMalloc(&ppv
);
492 IMalloc_Free(ShellTaskAllocator
, pv
);
495 /*************************************************************************
496 * SHGetDesktopFolder [SHELL32.@]
498 DWORD WINAPI
SHGetDesktopFolder(IShellFolder
**psf
)
503 if(!psf
) return E_INVALIDARG
;
505 hres
= ISF_Desktop_Constructor(NULL
, &IID_IShellFolder
,(LPVOID
*)psf
);
507 TRACE("-- %p->(%p)\n",psf
, *psf
);
510 /**************************************************************************
511 * Default ClassFactory Implementation
513 * SHCreateDefClassObject
516 * helper function for dll's without a own classfactory
517 * a generic classfactory is returned
518 * when the CreateInstance of the cf is called the callback is executed
523 ICOM_VFIELD(IClassFactory
);
526 LPFNCREATEINSTANCE lpfnCI
;
527 const IID
* riidInst
;
528 ULONG
* pcRefDll
; /* pointer to refcounter in external dll (ugrrr...) */
531 static ICOM_VTABLE(IClassFactory
) dclfvt
;
533 /**************************************************************************
534 * IDefClF_fnConstructor
537 IClassFactory
* IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, REFIID riidInst
)
541 lpclf
= (IDefClFImpl
*)HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl
));
543 lpclf
->lpVtbl
= &dclfvt
;
544 lpclf
->lpfnCI
= lpfnCI
;
545 lpclf
->pcRefDll
= pcRefDll
;
547 if (pcRefDll
) InterlockedIncrement(pcRefDll
);
548 lpclf
->riidInst
= riidInst
;
550 TRACE("(%p)%s\n",lpclf
, shdebugstr_guid(riidInst
));
551 return (LPCLASSFACTORY
)lpclf
;
553 /**************************************************************************
554 * IDefClF_fnQueryInterface
556 static HRESULT WINAPI
IDefClF_fnQueryInterface(
557 LPCLASSFACTORY iface
, REFIID riid
, LPVOID
*ppvObj
)
559 ICOM_THIS(IDefClFImpl
,iface
);
561 TRACE("(%p)->(%s)\n",This
,shdebugstr_guid(riid
));
565 if(IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
)) {
567 InterlockedIncrement(&This
->ref
);
571 TRACE("-- E_NOINTERFACE\n");
572 return E_NOINTERFACE
;
574 /******************************************************************************
577 static ULONG WINAPI
IDefClF_fnAddRef(LPCLASSFACTORY iface
)
579 ICOM_THIS(IDefClFImpl
,iface
);
580 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
582 return InterlockedIncrement(&This
->ref
);
584 /******************************************************************************
587 static ULONG WINAPI
IDefClF_fnRelease(LPCLASSFACTORY iface
)
589 ICOM_THIS(IDefClFImpl
,iface
);
590 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
592 if (!InterlockedDecrement(&This
->ref
))
594 if (This
->pcRefDll
) InterlockedDecrement(This
->pcRefDll
);
596 TRACE("-- destroying IClassFactory(%p)\n",This
);
597 HeapFree(GetProcessHeap(),0,This
);
602 /******************************************************************************
603 * IDefClF_fnCreateInstance
605 static HRESULT WINAPI
IDefClF_fnCreateInstance(
606 LPCLASSFACTORY iface
, LPUNKNOWN pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
)
608 ICOM_THIS(IDefClFImpl
,iface
);
610 TRACE("%p->(%p,%s,%p)\n",This
,pUnkOuter
,shdebugstr_guid(riid
),ppvObject
);
614 if ( This
->riidInst
==NULL
||
615 IsEqualCLSID(riid
, This
->riidInst
) ||
616 IsEqualCLSID(riid
, &IID_IUnknown
) )
618 return This
->lpfnCI(pUnkOuter
, riid
, ppvObject
);
621 ERR("unknown IID requested %s\n",shdebugstr_guid(riid
));
622 return E_NOINTERFACE
;
624 /******************************************************************************
625 * IDefClF_fnLockServer
627 static HRESULT WINAPI
IDefClF_fnLockServer(LPCLASSFACTORY iface
, BOOL fLock
)
629 ICOM_THIS(IDefClFImpl
,iface
);
630 TRACE("%p->(0x%x), not implemented\n",This
, fLock
);
634 static ICOM_VTABLE(IClassFactory
) dclfvt
=
636 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
637 IDefClF_fnQueryInterface
,
640 IDefClF_fnCreateInstance
,
644 /******************************************************************************
645 * SHCreateDefClassObject [SHELL32.70]
647 HRESULT WINAPI
SHCreateDefClassObject(
650 LPFNCREATEINSTANCE lpfnCI
, /* [in] create instance callback entry */
651 LPDWORD pcRefDll
, /* [in/out] ref count of the dll */
652 REFIID riidInst
) /* [in] optional interface to the instance */
656 TRACE("%s %p %p %p %s\n",
657 shdebugstr_guid(riid
), ppv
, lpfnCI
, pcRefDll
, shdebugstr_guid(riidInst
));
659 if (! IsEqualCLSID(riid
, &IID_IClassFactory
) ) return E_NOINTERFACE
;
660 if (! (pcf
= IDefClF_fnConstructor(lpfnCI
, pcRefDll
, riidInst
))) return E_OUTOFMEMORY
;
665 /*************************************************************************
666 * DragAcceptFiles [SHELL32.54]
668 void WINAPI
DragAcceptFiles(HWND hWnd
, BOOL b
)
672 if( !IsWindow(hWnd
) ) return;
673 exstyle
= GetWindowLongA(hWnd
,GWL_EXSTYLE
);
675 exstyle
|= WS_EX_ACCEPTFILES
;
677 exstyle
&= ~WS_EX_ACCEPTFILES
;
678 SetWindowLongA(hWnd
,GWL_EXSTYLE
,exstyle
);
681 /*************************************************************************
682 * DragFinish [SHELL32.80]
684 void WINAPI
DragFinish(HDROP h
)
687 GlobalFree((HGLOBAL
)h
);
690 /*************************************************************************
691 * DragQueryPoint [SHELL32.135]
693 BOOL WINAPI
DragQueryPoint(HDROP hDrop
, POINT
*p
)
695 DROPFILES
*lpDropFileStruct
;
700 lpDropFileStruct
= (DROPFILES
*) GlobalLock(hDrop
);
702 *p
= lpDropFileStruct
->pt
;
703 bRet
= lpDropFileStruct
->fNC
;
709 /*************************************************************************
710 * DragQueryFile [SHELL32.81]
711 * DragQueryFileA [SHELL32.82]
713 UINT WINAPI
DragQueryFileA(
721 DROPFILES
*lpDropFileStruct
= (DROPFILES
*) GlobalLock(hDrop
);
723 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszFile
,lLength
);
725 if(!lpDropFileStruct
) goto end
;
727 lpDrop
= (LPSTR
) lpDropFileStruct
+ lpDropFileStruct
->pFiles
;
729 if(lpDropFileStruct
->fWide
== TRUE
) {
730 LPWSTR lpszFileW
= NULL
;
733 lpszFileW
= (LPWSTR
) HeapAlloc(GetProcessHeap(), 0, lLength
*sizeof(WCHAR
));
734 if(lpszFileW
== NULL
) {
738 i
= DragQueryFileW(hDrop
, lFile
, lpszFileW
, lLength
);
741 WideCharToMultiByte(CP_ACP
, 0, lpszFileW
, -1, lpszFile
, lLength
, 0, NULL
);
742 HeapFree(GetProcessHeap(), 0, lpszFileW
);
749 while (*lpDrop
++); /* skip filename */
752 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
759 if (!lpszFile
) goto end
; /* needed buffer size */
760 i
= (lLength
> i
) ? i
: lLength
;
761 lstrcpynA (lpszFile
, lpDrop
, i
);
767 /*************************************************************************
768 * DragQueryFileW [SHELL32.133]
770 UINT WINAPI
DragQueryFileW(
778 DROPFILES
*lpDropFileStruct
= (DROPFILES
*) GlobalLock(hDrop
);
780 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszwFile
,lLength
);
782 if(!lpDropFileStruct
) goto end
;
784 lpwDrop
= (LPWSTR
) ((LPSTR
)lpDropFileStruct
+ lpDropFileStruct
->pFiles
);
786 if(lpDropFileStruct
->fWide
== FALSE
) {
787 LPSTR lpszFileA
= NULL
;
790 lpszFileA
= (LPSTR
) HeapAlloc(GetProcessHeap(), 0, lLength
);
791 if(lpszFileA
== NULL
) {
795 i
= DragQueryFileA(hDrop
, lFile
, lpszFileA
, lLength
);
798 MultiByteToWideChar(CP_ACP
, 0, lpszFileA
, -1, lpszwFile
, lLength
);
799 HeapFree(GetProcessHeap(), 0, lpszFileA
);
807 while (*lpwDrop
++); /* skip filename */
810 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
815 i
= strlenW(lpwDrop
);
817 if ( !lpszwFile
) goto end
; /* needed buffer size */
819 i
= (lLength
> i
) ? i
: lLength
;
820 lstrcpynW (lpszwFile
, lpwDrop
, i
);