source: trunk/src/shell32/shellole.c@ 10367

Last change on this file since 10367 was 10172, checked in by sandervl, 22 years ago

KOM: DragQueryFileW; allocate more for unicode conversion (DBCS)

File size: 17.8 KB
Line 
1/*
2 * handling of SHELL32.DLL OLE-Objects
3 *
4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Juergen Schmied <juergen.schmied@metronet.de>
6 *
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.
11 *
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.
16 *
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
20 */
21
22#include "config.h"
23
24#include <stdlib.h>
25#include <string.h>
26
27#include "shellapi.h"
28#include "shlobj.h"
29#include "shlguid.h"
30#include "winreg.h"
31#include "winerror.h"
32
33#include "undocshell.h"
34#include "wine/unicode.h"
35#include "shell32_main.h"
36
37#include "wine/debug.h"
38
39WINE_DEFAULT_DEBUG_CHANNEL(shell);
40
41DWORD WINAPI SHCLSIDFromStringA (LPCSTR clsid, CLSID *id);
42extern IShellFolder * IShellFolder_Constructor(
43 IShellFolder * psf,
44 LPITEMIDLIST pidl);
45extern HRESULT IFSFolder_Constructor(
46 IUnknown * pUnkOuter,
47 REFIID riid,
48 LPVOID * ppv);
49
50/*************************************************************************
51 * SHCoCreateInstance [SHELL32.102]
52 *
53 * NOTES
54 * exported by ordinal
55 */
56LRESULT WINAPI SHCoCreateInstance(
57 LPCSTR aclsid,
58 REFCLSID clsid,
59 LPUNKNOWN unknownouter,
60 REFIID refiid,
61 LPVOID *ppv)
62{
63 DWORD hres;
64 IID iid;
65 CLSID * myclsid = (CLSID*)clsid;
66
67 if (!clsid)
68 {
69 if (!aclsid) return REGDB_E_CLASSNOTREG;
70 SHCLSIDFromStringA(aclsid, &iid);
71 myclsid = &iid;
72 }
73
74 TRACE("(%p,\n\tCLSID:\t%s, unk:%p\n\tIID:\t%s,%p)\n",
75 aclsid,debugstr_guid(myclsid),unknownouter,debugstr_guid(refiid),ppv);
76
77 if IsEqualCLSID(myclsid, &CLSID_ShellFSFolder)
78 {
79 hres = IFSFolder_Constructor(unknownouter, refiid, ppv);
80 }
81 else
82 {
83 CoInitialize(NULL);
84 hres = CoCreateInstance(myclsid, unknownouter, CLSCTX_INPROC_SERVER, refiid, ppv);
85 }
86
87 if(hres!=S_OK)
88 {
89 ERR("failed (0x%08lx) to create \n\tCLSID:\t%s\n\tIID:\t%s\n",
90 hres, debugstr_guid(myclsid), debugstr_guid(refiid));
91 ERR("class not found in registry\n");
92 }
93
94 TRACE("-- instance: %p\n",*ppv);
95 return hres;
96}
97
98/*************************************************************************
99 * DllGetClassObject [SHELL32.128]
100 */
101HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
102{ HRESULT hres = E_OUTOFMEMORY;
103 LPCLASSFACTORY lpclf;
104
105 TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
106
107 *ppv = NULL;
108
109 if(IsEqualCLSID(rclsid, &CLSID_ShellDesktop)||
110 IsEqualCLSID(rclsid, &CLSID_ShellLink))
111 {
112 lpclf = IClassFactory_Constructor( rclsid );
113
114 if(lpclf)
115 {
116 hres = IClassFactory_QueryInterface(lpclf,iid, ppv);
117 IClassFactory_Release(lpclf);
118 }
119 }
120 else
121 {
122 WARN("-- CLSID not found\n");
123 hres = CLASS_E_CLASSNOTAVAILABLE;
124 }
125 TRACE("-- pointer to class factory: %p\n",*ppv);
126 return hres;
127}
128
129/*************************************************************************
130 * SHCLSIDFromString [SHELL32.147]
131 *
132 * NOTES
133 * exported by ordinal
134 */
135DWORD WINAPI SHCLSIDFromStringA (LPCSTR clsid, CLSID *id)
136{
137 WCHAR buffer[40];
138 TRACE("(%p(%s) %p)\n", clsid, clsid, id);
139 if (!MultiByteToWideChar( CP_ACP, 0, clsid, -1, buffer, sizeof(buffer)/sizeof(WCHAR) ))
140 return CO_E_CLASSSTRING;
141 return CLSIDFromString( buffer, id );
142}
143DWORD WINAPI SHCLSIDFromStringW (LPWSTR clsid, CLSID *id)
144{
145 TRACE("(%p(%s) %p)\n", clsid, debugstr_w(clsid), id);
146 return CLSIDFromString(clsid, id);
147}
148DWORD WINAPI SHCLSIDFromStringAW (LPVOID clsid, CLSID *id)
149{
150 if (SHELL_OsIsUnicode())
151 return SHCLSIDFromStringW (clsid, id);
152 return SHCLSIDFromStringA (clsid, id);
153}
154
155/*************************************************************************
156 * SHGetMalloc [SHELL32.@]
157 * returns the interface to shell malloc.
158 *
159 * [SDK header win95/shlobj.h:
160 * equivalent to: #define SHGetMalloc(ppmem) CoGetMalloc(MEMCTX_TASK, ppmem)
161 * ]
162 * What we are currently doing is not very wrong, since we always use the same
163 * heap (ProcessHeap).
164 */
165DWORD WINAPI SHGetMalloc(LPMALLOC *lpmal)
166{
167 TRACE("(%p)\n", lpmal);
168 return CoGetMalloc(MEMCTX_TASK, lpmal);
169}
170
171/*************************************************************************
172 * SHGetDesktopFolder [SHELL32.@]
173 */
174LPSHELLFOLDER pdesktopfolder=NULL;
175
176DWORD WINAPI SHGetDesktopFolder(IShellFolder **psf)
177{
178 HRESULT hres = S_OK;
179 LPCLASSFACTORY lpclf;
180 TRACE("%p->(%p)\n",psf,*psf);
181
182 *psf=NULL;
183
184 if (!pdesktopfolder)
185 {
186 lpclf = IClassFactory_Constructor(&CLSID_ShellDesktop);
187 if(lpclf)
188 {
189 hres = IClassFactory_CreateInstance(lpclf,NULL,(REFIID)&IID_IShellFolder, (void*)&pdesktopfolder);
190 IClassFactory_Release(lpclf);
191 }
192 }
193
194 if (pdesktopfolder)
195 {
196 /* even if we create the folder, add a ref so the application canŽt destroy the folder*/
197 IShellFolder_AddRef(pdesktopfolder);
198 *psf = pdesktopfolder;
199 }
200
201 TRACE("-- %p->(%p)\n",psf, *psf);
202 return hres;
203}
204
205/**************************************************************************
206* IClassFactory Implementation
207*/
208
209typedef struct
210{
211 /* IUnknown fields */
212 ICOM_VFIELD(IClassFactory);
213 DWORD ref;
214 CLSID *rclsid;
215} IClassFactoryImpl;
216
217static ICOM_VTABLE(IClassFactory) clfvt;
218
219/**************************************************************************
220 * IClassFactory_Constructor
221 */
222
223LPCLASSFACTORY IClassFactory_Constructor(REFCLSID rclsid)
224{
225 IClassFactoryImpl* lpclf;
226
227 lpclf= (IClassFactoryImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactoryImpl));
228 lpclf->ref = 1;
229 ICOM_VTBL(lpclf) = &clfvt;
230 lpclf->rclsid = (CLSID*)rclsid;
231
232 TRACE("(%p)->()\n",lpclf);
233 InterlockedIncrement(&shell32_ObjCount);
234 return (LPCLASSFACTORY)lpclf;
235}
236/**************************************************************************
237 * IClassFactory_QueryInterface
238 */
239static HRESULT WINAPI IClassFactory_fnQueryInterface(
240 LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
241{
242 ICOM_THIS(IClassFactoryImpl,iface);
243 TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
244
245 *ppvObj = NULL;
246
247 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
248 { *ppvObj = This;
249 }
250 else if(IsEqualIID(riid, &IID_IClassFactory)) /*IClassFactory*/
251 { *ppvObj = (IClassFactory*)This;
252 }
253
254 if(*ppvObj)
255 { IUnknown_AddRef((LPUNKNOWN)*ppvObj);
256 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
257 return S_OK;
258 }
259 TRACE("-- Interface: %s E_NOINTERFACE\n", debugstr_guid(riid));
260 return E_NOINTERFACE;
261}
262/******************************************************************************
263 * IClassFactory_AddRef
264 */
265static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
266{
267 ICOM_THIS(IClassFactoryImpl,iface);
268 TRACE("(%p)->(count=%lu)\n",This,This->ref);
269
270 InterlockedIncrement(&shell32_ObjCount);
271 return InterlockedIncrement(&This->ref);
272}
273/******************************************************************************
274 * IClassFactory_Release
275 */
276static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface)
277{
278 ICOM_THIS(IClassFactoryImpl,iface);
279 TRACE("(%p)->(count=%lu)\n",This,This->ref);
280
281 InterlockedDecrement(&shell32_ObjCount);
282 if (!InterlockedDecrement(&This->ref))
283 {
284 TRACE("-- destroying IClassFactory(%p)\n",This);
285 HeapFree(GetProcessHeap(),0,This);
286 return 0;
287 }
288 return This->ref;
289}
290/******************************************************************************
291 * IClassFactory_CreateInstance
292 */
293static HRESULT WINAPI IClassFactory_fnCreateInstance(
294 LPCLASSFACTORY iface, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
295{
296 ICOM_THIS(IClassFactoryImpl,iface);
297 IUnknown *pObj = NULL;
298 HRESULT hres;
299
300 TRACE("%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnknown,debugstr_guid(riid),ppObject);
301
302 *ppObject = NULL;
303
304 if(pUnknown)
305 {
306 return(CLASS_E_NOAGGREGATION);
307 }
308
309 if (IsEqualCLSID(This->rclsid, &CLSID_ShellDesktop))
310 {
311 pObj = (IUnknown *)ISF_Desktop_Constructor();
312 }
313 else if (IsEqualCLSID(This->rclsid, &CLSID_ShellLink))
314 {
315 pObj = (IUnknown *)IShellLink_Constructor(FALSE);
316 }
317 else
318 {
319 ERR("unknown IID requested\n\tIID:\t%s\n",debugstr_guid(riid));
320 return(E_NOINTERFACE);
321 }
322
323 if (!pObj)
324 {
325 return(E_OUTOFMEMORY);
326 }
327
328 hres = IUnknown_QueryInterface(pObj,riid, ppObject);
329 IUnknown_Release(pObj);
330
331 TRACE("-- Object created: (%p)->%p\n",This,*ppObject);
332
333 return hres;
334}
335/******************************************************************************
336 * IClassFactory_LockServer
337 */
338static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
339{
340 ICOM_THIS(IClassFactoryImpl,iface);
341 TRACE("%p->(0x%x), not implemented\n",This, fLock);
342 return E_NOTIMPL;
343}
344
345static ICOM_VTABLE(IClassFactory) clfvt =
346{
347 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
348 IClassFactory_fnQueryInterface,
349 IClassFactory_fnAddRef,
350 IClassFactory_fnRelease,
351 IClassFactory_fnCreateInstance,
352 IClassFactory_fnLockServer
353};
354
355/**************************************************************************
356 * Default ClassFactory Implementation
357 *
358 * SHCreateDefClassObject
359 *
360 * NOTES
361 * helper function for dll's without a own classfactory
362 * a generic classfactory is returned
363 * when the CreateInstance of the cf is called the callback is executed
364 */
365#ifdef __WIN32OS2__
366typedef HRESULT (* CALLBACK LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject);
367#else
368typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject);
369#endif
370
371typedef struct
372{
373 ICOM_VFIELD(IClassFactory);
374 DWORD ref;
375 CLSID *rclsid;
376 LPFNCREATEINSTANCE lpfnCI;
377 const IID * riidInst;
378 ULONG * pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */
379} IDefClFImpl;
380
381static ICOM_VTABLE(IClassFactory) dclfvt;
382
383/**************************************************************************
384 * IDefClF_fnConstructor
385 */
386
387IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
388{
389 IDefClFImpl* lpclf;
390
391 lpclf = (IDefClFImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl));
392 lpclf->ref = 1;
393 ICOM_VTBL(lpclf) = &dclfvt;
394 lpclf->lpfnCI = lpfnCI;
395 lpclf->pcRefDll = pcRefDll;
396
397 if (pcRefDll) InterlockedIncrement(pcRefDll);
398 lpclf->riidInst = riidInst;
399
400 TRACE("(%p)\n\tIID:\t%s\n",lpclf, debugstr_guid(riidInst));
401 InterlockedIncrement(&shell32_ObjCount);
402 return (LPCLASSFACTORY)lpclf;
403}
404/**************************************************************************
405 * IDefClF_fnQueryInterface
406 */
407static HRESULT WINAPI IDefClF_fnQueryInterface(
408 LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
409{
410 ICOM_THIS(IDefClFImpl,iface);
411
412 TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
413
414 *ppvObj = NULL;
415
416 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
417 { *ppvObj = This;
418 }
419 else if(IsEqualIID(riid, &IID_IClassFactory)) /*IClassFactory*/
420 { *ppvObj = (IClassFactory*)This;
421 }
422
423 if(*ppvObj)
424 { IUnknown_AddRef((LPUNKNOWN)*ppvObj);
425 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
426 return S_OK;
427 }
428 TRACE("-- Interface: %s E_NOINTERFACE\n", debugstr_guid(riid));
429 return E_NOINTERFACE;
430}
431/******************************************************************************
432 * IDefClF_fnAddRef
433 */
434static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface)
435{
436 ICOM_THIS(IDefClFImpl,iface);
437 TRACE("(%p)->(count=%lu)\n",This,This->ref);
438
439 InterlockedIncrement(&shell32_ObjCount);
440 return InterlockedIncrement(&This->ref);
441}
442/******************************************************************************
443 * IDefClF_fnRelease
444 */
445static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface)
446{
447 ICOM_THIS(IDefClFImpl,iface);
448 TRACE("(%p)->(count=%lu)\n",This,This->ref);
449
450 InterlockedDecrement(&shell32_ObjCount);
451
452 if (!InterlockedDecrement(&This->ref))
453 {
454 if (This->pcRefDll) InterlockedDecrement(This->pcRefDll);
455
456 TRACE("-- destroying IClassFactory(%p)\n",This);
457 HeapFree(GetProcessHeap(),0,This);
458 return 0;
459 }
460 return This->ref;
461}
462/******************************************************************************
463 * IDefClF_fnCreateInstance
464 */
465static HRESULT WINAPI IDefClF_fnCreateInstance(
466 LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
467{
468 ICOM_THIS(IDefClFImpl,iface);
469
470 TRACE("%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnkOuter,debugstr_guid(riid),ppvObject);
471
472 *ppvObject = NULL;
473
474 if(pUnkOuter)
475 return(CLASS_E_NOAGGREGATION);
476
477 if ( This->riidInst==NULL ||
478 IsEqualCLSID(riid, This->riidInst) ||
479 IsEqualCLSID(riid, &IID_IUnknown) )
480 {
481 return This->lpfnCI(pUnkOuter, riid, ppvObject);
482 }
483
484 ERR("unknown IID requested\n\tIID:\t%s\n",debugstr_guid(riid));
485 return E_NOINTERFACE;
486}
487/******************************************************************************
488 * IDefClF_fnLockServer
489 */
490static HRESULT WINAPI IDefClF_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
491{
492 ICOM_THIS(IDefClFImpl,iface);
493 TRACE("%p->(0x%x), not implemented\n",This, fLock);
494 return E_NOTIMPL;
495}
496
497static ICOM_VTABLE(IClassFactory) dclfvt =
498{
499 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
500 IDefClF_fnQueryInterface,
501 IDefClF_fnAddRef,
502 IDefClF_fnRelease,
503 IDefClF_fnCreateInstance,
504 IDefClF_fnLockServer
505};
506
507/******************************************************************************
508 * SHCreateDefClassObject [SHELL32.70]
509 */
510HRESULT WINAPI SHCreateDefClassObject(
511 REFIID riid,
512 LPVOID* ppv,
513 LPFNCREATEINSTANCE lpfnCI, /* [in] create instance callback entry */
514 LPDWORD pcRefDll, /* [in/out] ref count of the dll */
515 REFIID riidInst) /* [in] optional interface to the instance */
516{
517 TRACE("\n\tIID:\t%s %p %p %p \n\tIIDIns:\t%s\n",
518 debugstr_guid(riid), ppv, lpfnCI, pcRefDll, debugstr_guid(riidInst));
519
520 if ( IsEqualCLSID(riid, &IID_IClassFactory) )
521 {
522 IClassFactory * pcf = IDefClF_fnConstructor(lpfnCI, pcRefDll, riidInst);
523 if (pcf)
524 {
525 *ppv = pcf;
526 return NOERROR;
527 }
528 return E_OUTOFMEMORY;
529 }
530 return E_NOINTERFACE;
531}
532
533/*************************************************************************
534 * DragAcceptFiles [SHELL32.54]
535 */
536void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
537{
538 LONG exstyle;
539
540 if( !IsWindow(hWnd) ) return;
541 exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE);
542 if (b)
543 exstyle |= WS_EX_ACCEPTFILES;
544 else
545 exstyle &= ~WS_EX_ACCEPTFILES;
546 SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle);
547}
548
549/*************************************************************************
550 * DragFinish [SHELL32.80]
551 */
552void WINAPI DragFinish(HDROP h)
553{
554 TRACE("\n");
555 GlobalFree((HGLOBAL)h);
556}
557
558/*************************************************************************
559 * DragQueryPoint [SHELL32.135]
560 */
561BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p)
562{
563 DROPFILES *lpDropFileStruct;
564 BOOL bRet;
565
566 TRACE("\n");
567
568 lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
569
570 *p = lpDropFileStruct->pt;
571 bRet = lpDropFileStruct->fNC;
572
573 GlobalUnlock(hDrop);
574 return bRet;
575}
576
577/*************************************************************************
578 * DragQueryFile [SHELL32.81]
579 * DragQueryFileA [SHELL32.82]
580 */
581UINT WINAPI DragQueryFileA(
582 HDROP hDrop,
583 UINT lFile,
584 LPSTR lpszFile,
585 UINT lLength)
586{
587 LPSTR lpDrop;
588 UINT i = 0;
589 DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
590
591 TRACE("(%08x, %x, %p, %u)\n", hDrop,lFile,lpszFile,lLength);
592
593 if(!lpDropFileStruct) goto end;
594
595 lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->pFiles;
596
597 if(lpDropFileStruct->fWide == TRUE) {
598 LPWSTR lpszFileW = NULL;
599
600 if(lpszFile) {
601 lpszFileW = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR));
602 if(lpszFileW == NULL) {
603 goto end;
604 }
605 }
606 i = DragQueryFileW(hDrop, lFile, lpszFileW, lLength);
607
608 if(lpszFileW) {
609 WideCharToMultiByte(CP_ACP, 0, lpszFileW, -1, lpszFile, lLength, 0, NULL);
610 HeapFree(GetProcessHeap(), 0, lpszFileW);
611 }
612 goto end;
613 }
614
615 while (i++ < lFile)
616 {
617 while (*lpDrop++); /* skip filename */
618 if (!*lpDrop)
619 {
620 i = (lFile == 0xFFFFFFFF) ? i : 0;
621 goto end;
622 }
623 }
624
625 i = strlen(lpDrop);
626 i++;
627 if (!lpszFile ) goto end; /* needed buffer size */
628 i = (lLength > i) ? i : lLength;
629 lstrcpynA (lpszFile, lpDrop, i);
630end:
631 GlobalUnlock(hDrop);
632 return i;
633}
634
635/*************************************************************************
636 * DragQueryFileW [SHELL32.133]
637 */
638UINT WINAPI DragQueryFileW(
639 HDROP hDrop,
640 UINT lFile,
641 LPWSTR lpszwFile,
642 UINT lLength)
643{
644 LPWSTR lpwDrop;
645 UINT i = 0;
646 DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
647
648 TRACE("(%08x, %x, %p, %u)\n", hDrop,lFile,lpszwFile,lLength);
649
650 if(!lpDropFileStruct) goto end;
651
652 lpwDrop = (LPWSTR) ((LPSTR)lpDropFileStruct + lpDropFileStruct->pFiles);
653
654 if(lpDropFileStruct->fWide == FALSE) {
655 LPSTR lpszFileA = NULL;
656
657 if(lpszwFile) {
658#ifdef __WIN32OS2__
659 lpszFileA = (LPSTR) HeapAlloc(GetProcessHeap(), 0, lLength * sizeof( WCHAR ));
660#else
661 lpszFileA = (LPSTR) HeapAlloc(GetProcessHeap(), 0, lLength);
662#endif
663 if(lpszFileA == NULL) {
664 goto end;
665 }
666 }
667#ifdef __WIN32OS2__
668 i = DragQueryFileA(hDrop, lFile, lpszFileA, lLength * sizeof( WCHAR ));
669#else
670 i = DragQueryFileA(hDrop, lFile, lpszFileA, lLength);
671#endif
672
673 if(lpszFileA) {
674 MultiByteToWideChar(CP_ACP, 0, lpszFileA, -1, lpszwFile, lLength);
675 HeapFree(GetProcessHeap(), 0, lpszFileA);
676 }
677 goto end;
678 }
679
680 i = 0;
681 while (i++ < lFile)
682 {
683 while (*lpwDrop++); /* skip filename */
684 if (!*lpwDrop)
685 {
686 i = (lFile == 0xFFFFFFFF) ? i : 0;
687 goto end;
688 }
689 }
690
691 i = strlenW(lpwDrop);
692 i++;
693 if ( !lpszwFile) goto end; /* needed buffer size */
694
695 i = (lLength > i) ? i : lLength;
696 lstrcpynW (lpszwFile, lpwDrop, i);
697end:
698 GlobalUnlock(hDrop);
699 return i;
700}
Note: See TracBrowser for help on using the repository browser.