Ignore:
Timestamp:
Sep 5, 2001, 3:54:53 PM (24 years ago)
Author:
bird
Message:

Added $Id:$ keyword.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shell32/shellole.c

    r5618 r6650  
     1/* $Id: shellole.c,v 1.3 2001-09-05 13:46:57 bird Exp $ */
    12/*
    2  *      handling of SHELL32.DLL OLE-Objects
     3 *  handling of SHELL32.DLL OLE-Objects
    34 *
    4  *      Copyright 1997  Marcus Meissner
    5  *      Copyright 1998  Juergen Schmied  <juergen.schmied@metronet.de>
     5 *  Copyright 1997  Marcus Meissner
     6 *  Copyright 1998  Juergen Schmied  <juergen.schmied@metronet.de>
    67 *
    78 */
     
    2425DWORD WINAPI SHCLSIDFromStringA (LPSTR clsid, CLSID *id);
    2526extern IShellFolder * IShellFolder_Constructor(
    26         IShellFolder * psf,
    27         LPITEMIDLIST pidl);
     27    IShellFolder * psf,
     28    LPITEMIDLIST pidl);
    2829extern HRESULT IFSFolder_Constructor(
    29         IUnknown * pUnkOuter,
    30         REFIID riid,
    31         LPVOID * ppv);
     30    IUnknown * pUnkOuter,
     31    REFIID riid,
     32    LPVOID * ppv);
    3233
    3334/*************************************************************************
    3435 * SHCoCreateInstance [SHELL32.102]
    35  * 
     36 *
    3637 * NOTES
    3738 *     exported by ordinal
    3839 */
    3940LRESULT WINAPI SHCoCreateInstance(
    40         LPSTR aclsid,
    41         REFCLSID clsid,
    42         IUnknown * unknownouter,
    43         REFIID refiid,
    44         LPVOID *ppv)
    45 {
    46         DWORD   hres;
    47         IID     iid;
    48         CLSID * myclsid = (CLSID*)clsid;
    49        
    50         if (!clsid)
    51         {
    52           if (!aclsid) return REGDB_E_CLASSNOTREG;
    53           SHCLSIDFromStringA(aclsid, &iid);
    54           myclsid = &iid;
    55         }
    56 
    57         TRACE("(%p,\n\tCLSID:\t%s, unk:%p\n\tIID:\t%s,%p)\n",
    58                 aclsid,debugstr_guid(myclsid),unknownouter,debugstr_guid(refiid),ppv);
    59 
    60         if IsEqualCLSID(myclsid, &CLSID_ShellFSFolder)
    61         {
    62           hres = IFSFolder_Constructor(unknownouter, refiid, ppv);
    63         }
    64         else
    65         {
    66           hres = CoCreateInstance(myclsid, unknownouter, CLSCTX_INPROC_SERVER, refiid, ppv);
    67         }
    68        
    69         if(hres!=S_OK)
    70         {
    71           ERR("failed (0x%08lx) to create \n\tCLSID:\t%s\n\tIID:\t%s\n",
     41    LPSTR aclsid,
     42    REFCLSID clsid,
     43    IUnknown * unknownouter,
     44    REFIID refiid,
     45    LPVOID *ppv)
     46{
     47    DWORD   hres;
     48    IID iid;
     49    CLSID * myclsid = (CLSID*)clsid;
     50
     51    if (!clsid)
     52    {
     53      if (!aclsid) return REGDB_E_CLASSNOTREG;
     54      SHCLSIDFromStringA(aclsid, &iid);
     55      myclsid = &iid;
     56    }
     57
     58    TRACE("(%p,\n\tCLSID:\t%s, unk:%p\n\tIID:\t%s,%p)\n",
     59        aclsid,debugstr_guid(myclsid),unknownouter,debugstr_guid(refiid),ppv);
     60
     61    if IsEqualCLSID(myclsid, &CLSID_ShellFSFolder)
     62    {
     63      hres = IFSFolder_Constructor(unknownouter, refiid, ppv);
     64    }
     65    else
     66    {
     67      hres = CoCreateInstance(myclsid, unknownouter, CLSCTX_INPROC_SERVER, refiid, ppv);
     68    }
     69
     70    if(hres!=S_OK)
     71    {
     72      ERR("failed (0x%08lx) to create \n\tCLSID:\t%s\n\tIID:\t%s\n",
    7273              hres, debugstr_guid(myclsid), debugstr_guid(refiid));
    73           ERR("class not found in registry\n");
    74         }
    75 
    76         TRACE("-- instance: %p\n",*ppv);
    77         return hres;
     74      ERR("class not found in registry\n");
     75    }
     76
     77    TRACE("-- instance: %p\n",*ppv);
     78    return hres;
    7879}
    7980
     
    8283 */
    8384HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
    84 {       HRESULT hres = E_OUTOFMEMORY;
    85         LPCLASSFACTORY lpclf;
    86 
    87         TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
    88        
    89         *ppv = NULL;
    90 
    91         if(IsEqualCLSID(rclsid, &CLSID_ShellDesktop)||
    92            IsEqualCLSID(rclsid, &CLSID_ShellLink))
    93         {
    94           lpclf = IClassFactory_Constructor( rclsid );
    95 
    96           if(lpclf)
    97           {
    98             hres = IClassFactory_QueryInterface(lpclf,iid, ppv);
    99             IClassFactory_Release(lpclf);
    100           }
    101         }
    102         else
    103         {
    104           WARN("-- CLSID not found\n");
    105           hres = CLASS_E_CLASSNOTAVAILABLE;
    106         }
    107         TRACE("-- pointer to class factory: %p\n",*ppv);
    108         return hres;
    109 }
    110 
    111 /*************************************************************************
    112  * SHCLSIDFromString                            [SHELL32.147]
     85{   HRESULT hres = E_OUTOFMEMORY;
     86    LPCLASSFACTORY lpclf;
     87
     88    TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
     89
     90    *ppv = NULL;
     91
     92    if(IsEqualCLSID(rclsid, &CLSID_ShellDesktop)||
     93       IsEqualCLSID(rclsid, &CLSID_ShellLink))
     94    {
     95      lpclf = IClassFactory_Constructor( rclsid );
     96
     97      if(lpclf)
     98      {
     99        hres = IClassFactory_QueryInterface(lpclf,iid, ppv);
     100        IClassFactory_Release(lpclf);
     101      }
     102    }
     103    else
     104    {
     105      WARN("-- CLSID not found\n");
     106      hres = CLASS_E_CLASSNOTAVAILABLE;
     107    }
     108    TRACE("-- pointer to class factory: %p\n",*ppv);
     109    return hres;
     110}
     111
     112/*************************************************************************
     113 * SHCLSIDFromString                [SHELL32.147]
    113114 *
    114115 * NOTES
     
    125126DWORD WINAPI SHCLSIDFromStringW (LPWSTR clsid, CLSID *id)
    126127{
    127         TRACE("(%p(%s) %p)\n", clsid, debugstr_w(clsid), id);
    128         return CLSIDFromString(clsid, id);
     128    TRACE("(%p(%s) %p)\n", clsid, debugstr_w(clsid), id);
     129    return CLSIDFromString(clsid, id);
    129130}
    130131DWORD WINAPI SHCLSIDFromStringAW (LPVOID clsid, CLSID *id)
    131132{
    132         if (SHELL_OsIsUnicode())
    133           return SHCLSIDFromStringW (clsid, id);
    134         return SHCLSIDFromStringA (clsid, id);
    135 }
    136 
    137 /*************************************************************************
    138  *                       SHGetMalloc                    [SHELL32.220]
     133    if (SHELL_OsIsUnicode())
     134      return SHCLSIDFromStringW (clsid, id);
     135    return SHCLSIDFromStringA (clsid, id);
     136}
     137
     138/*************************************************************************
     139 *           SHGetMalloc            [SHELL32.220]
    139140 * returns the interface to shell malloc.
    140141 *
     
    145146 * heap (ProcessHeap).
    146147 */
    147 DWORD WINAPI SHGetMalloc(LPMALLOC *lpmal) 
    148 {
    149         TRACE("(%p)\n", lpmal);
    150         return CoGetMalloc(MEMCTX_TASK, lpmal);
    151 }
    152 
    153 /*************************************************************************
    154  * SHGetDesktopFolder                   [SHELL32.216]
     148DWORD WINAPI SHGetMalloc(LPMALLOC *lpmal)
     149{
     150    TRACE("(%p)\n", lpmal);
     151    return CoGetMalloc(MEMCTX_TASK, lpmal);
     152}
     153
     154/*************************************************************************
     155 * SHGetDesktopFolder           [SHELL32.216]
    155156 */
    156157LPSHELLFOLDER pdesktopfolder=NULL;
     
    158159DWORD WINAPI SHGetDesktopFolder(IShellFolder **psf)
    159160{
    160         HRESULT hres = S_OK;
    161         LPCLASSFACTORY lpclf;
    162         TRACE("%p->(%p)\n",psf,*psf);
    163 
    164         *psf=NULL;
    165 
    166         if (!pdesktopfolder)
    167         {
    168           lpclf = IClassFactory_Constructor(&CLSID_ShellDesktop);
    169           if(lpclf)
    170           {
    171             hres = IClassFactory_CreateInstance(lpclf,NULL,(REFIID)&IID_IShellFolder, (void*)&pdesktopfolder);
    172             IClassFactory_Release(lpclf);
    173           } 
    174         }
    175        
    176         if (pdesktopfolder)
    177         {
    178           /* even if we create the folder, add a ref so the application canŽt destroy the folder*/
    179           IShellFolder_AddRef(pdesktopfolder);
    180           *psf = pdesktopfolder;
    181         }
    182 
    183         TRACE("-- %p->(%p)\n",psf, *psf);
    184         return hres;
     161    HRESULT hres = S_OK;
     162    LPCLASSFACTORY lpclf;
     163    TRACE("%p->(%p)\n",psf,*psf);
     164
     165    *psf=NULL;
     166
     167    if (!pdesktopfolder)
     168    {
     169      lpclf = IClassFactory_Constructor(&CLSID_ShellDesktop);
     170      if(lpclf)
     171      {
     172        hres = IClassFactory_CreateInstance(lpclf,NULL,(REFIID)&IID_IShellFolder, (void*)&pdesktopfolder);
     173        IClassFactory_Release(lpclf);
     174      }
     175    }
     176
     177    if (pdesktopfolder)
     178    {
     179      /* even if we create the folder, add a ref so the application canŽt destroy the folder*/
     180      IShellFolder_AddRef(pdesktopfolder);
     181      *psf = pdesktopfolder;
     182    }
     183
     184    TRACE("-- %p->(%p)\n",psf, *psf);
     185    return hres;
    185186}
    186187
     
    194195    ICOM_VFIELD(IClassFactory);
    195196    DWORD                       ref;
    196     CLSID                       *rclsid;
     197    CLSID           *rclsid;
    197198} IClassFactoryImpl;
    198199
     
    205206LPCLASSFACTORY IClassFactory_Constructor(REFCLSID rclsid)
    206207{
    207         IClassFactoryImpl* lpclf;
    208 
    209         lpclf= (IClassFactoryImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactoryImpl));
    210         lpclf->ref = 1;
    211         ICOM_VTBL(lpclf) = &clfvt;
    212         lpclf->rclsid = (CLSID*)rclsid;
    213 
    214         TRACE("(%p)->()\n",lpclf);
    215         InterlockedIncrement(&shell32_ObjCount);
    216         return (LPCLASSFACTORY)lpclf;
     208    IClassFactoryImpl* lpclf;
     209
     210    lpclf= (IClassFactoryImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactoryImpl));
     211    lpclf->ref = 1;
     212    ICOM_VTBL(lpclf) = &clfvt;
     213    lpclf->rclsid = (CLSID*)rclsid;
     214
     215    TRACE("(%p)->()\n",lpclf);
     216    InterlockedIncrement(&shell32_ObjCount);
     217    return (LPCLASSFACTORY)lpclf;
    217218}
    218219/**************************************************************************
     
    222223  LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
    223224{
    224         ICOM_THIS(IClassFactoryImpl,iface);
    225         TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
    226 
    227         *ppvObj = NULL;
    228 
    229         if(IsEqualIID(riid, &IID_IUnknown))          /*IUnknown*/
    230         { *ppvObj = This;
    231         }
    232         else if(IsEqualIID(riid, &IID_IClassFactory))  /*IClassFactory*/
    233         { *ppvObj = (IClassFactory*)This;
    234         }   
    235 
    236         if(*ppvObj)
    237         { IUnknown_AddRef((LPUNKNOWN)*ppvObj);         
    238           TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
    239           return S_OK;
    240         }
    241         TRACE("-- Interface: %s E_NOINTERFACE\n", debugstr_guid(riid));
    242         return E_NOINTERFACE;
    243 } 
     225    ICOM_THIS(IClassFactoryImpl,iface);
     226    TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
     227
     228    *ppvObj = NULL;
     229
     230    if(IsEqualIID(riid, &IID_IUnknown))          /*IUnknown*/
     231    { *ppvObj = This;
     232    }
     233    else if(IsEqualIID(riid, &IID_IClassFactory))  /*IClassFactory*/
     234    { *ppvObj = (IClassFactory*)This;
     235    }
     236
     237    if(*ppvObj)
     238    { IUnknown_AddRef((LPUNKNOWN)*ppvObj);
     239      TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
     240      return S_OK;
     241    }
     242    TRACE("-- Interface: %s E_NOINTERFACE\n", debugstr_guid(riid));
     243    return E_NOINTERFACE;
     244}
    244245/******************************************************************************
    245246 * IClassFactory_AddRef
     
    247248static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
    248249{
    249         ICOM_THIS(IClassFactoryImpl,iface);
    250         TRACE("(%p)->(count=%lu)\n",This,This->ref);
    251 
    252         InterlockedIncrement(&shell32_ObjCount);
    253         return InterlockedIncrement(&This->ref);
     250    ICOM_THIS(IClassFactoryImpl,iface);
     251    TRACE("(%p)->(count=%lu)\n",This,This->ref);
     252
     253    InterlockedIncrement(&shell32_ObjCount);
     254    return InterlockedIncrement(&This->ref);
    254255}
    255256/******************************************************************************
     
    258259static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface)
    259260{
    260         ICOM_THIS(IClassFactoryImpl,iface);
    261         TRACE("(%p)->(count=%lu)\n",This,This->ref);
    262 
    263         InterlockedDecrement(&shell32_ObjCount);
    264         if (!InterlockedDecrement(&This->ref))
    265         {
    266           TRACE("-- destroying IClassFactory(%p)\n",This);
    267           HeapFree(GetProcessHeap(),0,This);
    268           return 0;
    269         }
    270         return This->ref;
     261    ICOM_THIS(IClassFactoryImpl,iface);
     262    TRACE("(%p)->(count=%lu)\n",This,This->ref);
     263
     264    InterlockedDecrement(&shell32_ObjCount);
     265    if (!InterlockedDecrement(&This->ref))
     266    {
     267      TRACE("-- destroying IClassFactory(%p)\n",This);
     268      HeapFree(GetProcessHeap(),0,This);
     269      return 0;
     270    }
     271    return This->ref;
    271272}
    272273/******************************************************************************
     
    276277  LPCLASSFACTORY iface, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
    277278{
    278         ICOM_THIS(IClassFactoryImpl,iface);
    279         IUnknown *pObj = NULL;
    280         HRESULT hres;
    281 
    282         TRACE("%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnknown,debugstr_guid(riid),ppObject);
    283 
    284         *ppObject = NULL;
    285                
    286         if(pUnknown)
    287         {
    288           return(CLASS_E_NOAGGREGATION);
    289         }
    290 
    291         if (IsEqualCLSID(This->rclsid, &CLSID_ShellDesktop))
    292         {
    293           pObj = (IUnknown *)ISF_Desktop_Constructor();
    294         }
    295         else if (IsEqualCLSID(This->rclsid, &CLSID_ShellLink))
    296         {
    297           pObj = (IUnknown *)IShellLink_Constructor(FALSE);
    298         }
    299         else
    300         {
    301           ERR("unknown IID requested\n\tIID:\t%s\n",debugstr_guid(riid));
    302           return(E_NOINTERFACE);
    303         }
    304        
    305         if (!pObj)
    306         {
    307           return(E_OUTOFMEMORY);
    308         }
    309          
    310         hres = IUnknown_QueryInterface(pObj,riid, ppObject);
    311         IUnknown_Release(pObj);
    312 
    313         TRACE("-- Object created: (%p)->%p\n",This,*ppObject);
    314 
    315         return hres;
     279    ICOM_THIS(IClassFactoryImpl,iface);
     280    IUnknown *pObj = NULL;
     281    HRESULT hres;
     282
     283    TRACE("%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnknown,debugstr_guid(riid),ppObject);
     284
     285    *ppObject = NULL;
     286
     287    if(pUnknown)
     288    {
     289      return(CLASS_E_NOAGGREGATION);
     290    }
     291
     292    if (IsEqualCLSID(This->rclsid, &CLSID_ShellDesktop))
     293    {
     294      pObj = (IUnknown *)ISF_Desktop_Constructor();
     295    }
     296    else if (IsEqualCLSID(This->rclsid, &CLSID_ShellLink))
     297    {
     298      pObj = (IUnknown *)IShellLink_Constructor(FALSE);
     299    }
     300    else
     301    {
     302      ERR("unknown IID requested\n\tIID:\t%s\n",debugstr_guid(riid));
     303      return(E_NOINTERFACE);
     304    }
     305
     306    if (!pObj)
     307    {
     308      return(E_OUTOFMEMORY);
     309    }
     310
     311    hres = IUnknown_QueryInterface(pObj,riid, ppObject);
     312    IUnknown_Release(pObj);
     313
     314    TRACE("-- Object created: (%p)->%p\n",This,*ppObject);
     315
     316    return hres;
    316317}
    317318/******************************************************************************
     
    320321static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
    321322{
    322         ICOM_THIS(IClassFactoryImpl,iface);
    323         TRACE("%p->(0x%x), not implemented\n",This, fLock);
    324         return E_NOTIMPL;
    325 }
    326 
    327 static ICOM_VTABLE(IClassFactory) clfvt = 
     323    ICOM_THIS(IClassFactoryImpl,iface);
     324    TRACE("%p->(0x%x), not implemented\n",This, fLock);
     325    return E_NOTIMPL;
     326}
     327
     328static ICOM_VTABLE(IClassFactory) clfvt =
    328329{
    329330    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     
    355356    ICOM_VFIELD(IClassFactory);
    356357    DWORD                       ref;
    357     CLSID                       *rclsid;
    358     LPFNCREATEINSTANCE          lpfnCI;
    359     const IID *                 riidInst;
    360     ULONG *                     pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */
     358    CLSID           *rclsid;
     359    LPFNCREATEINSTANCE      lpfnCI;
     360    const IID *         riidInst;
     361    ULONG *         pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */
    361362} IDefClFImpl;
    362363
     
    369370IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
    370371{
    371         IDefClFImpl* lpclf;
    372 
    373         lpclf = (IDefClFImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl));
    374         lpclf->ref = 1;
    375         ICOM_VTBL(lpclf) = &dclfvt;
    376         lpclf->lpfnCI = lpfnCI;
    377         lpclf->pcRefDll = pcRefDll;
    378 
    379         if (pcRefDll) InterlockedIncrement(pcRefDll);
    380         lpclf->riidInst = riidInst;
    381 
    382         TRACE("(%p)\n\tIID:\t%s\n",lpclf, debugstr_guid(riidInst));
    383         InterlockedIncrement(&shell32_ObjCount);
    384         return (LPCLASSFACTORY)lpclf;
     372    IDefClFImpl* lpclf;
     373
     374    lpclf = (IDefClFImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl));
     375    lpclf->ref = 1;
     376    ICOM_VTBL(lpclf) = &dclfvt;
     377    lpclf->lpfnCI = lpfnCI;
     378    lpclf->pcRefDll = pcRefDll;
     379
     380    if (pcRefDll) InterlockedIncrement(pcRefDll);
     381    lpclf->riidInst = riidInst;
     382
     383    TRACE("(%p)\n\tIID:\t%s\n",lpclf, debugstr_guid(riidInst));
     384    InterlockedIncrement(&shell32_ObjCount);
     385    return (LPCLASSFACTORY)lpclf;
    385386}
    386387/**************************************************************************
     
    390391  LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
    391392{
    392         ICOM_THIS(IDefClFImpl,iface);
    393 
    394         TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
    395 
    396         *ppvObj = NULL;
    397 
    398         if(IsEqualIID(riid, &IID_IUnknown))          /*IUnknown*/
    399         { *ppvObj = This;
    400         }
    401         else if(IsEqualIID(riid, &IID_IClassFactory))  /*IClassFactory*/
    402         { *ppvObj = (IClassFactory*)This;
    403         }   
    404 
    405         if(*ppvObj)
    406         { IUnknown_AddRef((LPUNKNOWN)*ppvObj);         
    407           TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
    408           return S_OK;
    409         }
    410         TRACE("-- Interface: %s E_NOINTERFACE\n", debugstr_guid(riid));
    411         return E_NOINTERFACE;
    412 } 
     393    ICOM_THIS(IDefClFImpl,iface);
     394
     395    TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
     396
     397    *ppvObj = NULL;
     398
     399    if(IsEqualIID(riid, &IID_IUnknown))          /*IUnknown*/
     400    { *ppvObj = This;
     401    }
     402    else if(IsEqualIID(riid, &IID_IClassFactory))  /*IClassFactory*/
     403    { *ppvObj = (IClassFactory*)This;
     404    }
     405
     406    if(*ppvObj)
     407    { IUnknown_AddRef((LPUNKNOWN)*ppvObj);
     408      TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
     409      return S_OK;
     410    }
     411    TRACE("-- Interface: %s E_NOINTERFACE\n", debugstr_guid(riid));
     412    return E_NOINTERFACE;
     413}
    413414/******************************************************************************
    414415 * IDefClF_fnAddRef
     
    416417static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface)
    417418{
    418         ICOM_THIS(IDefClFImpl,iface);
    419         TRACE("(%p)->(count=%lu)\n",This,This->ref);
    420 
    421         InterlockedIncrement(&shell32_ObjCount);
    422         return InterlockedIncrement(&This->ref);
     419    ICOM_THIS(IDefClFImpl,iface);
     420    TRACE("(%p)->(count=%lu)\n",This,This->ref);
     421
     422    InterlockedIncrement(&shell32_ObjCount);
     423    return InterlockedIncrement(&This->ref);
    423424}
    424425/******************************************************************************
     
    427428static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface)
    428429{
    429         ICOM_THIS(IDefClFImpl,iface);
    430         TRACE("(%p)->(count=%lu)\n",This,This->ref);
    431 
    432         InterlockedDecrement(&shell32_ObjCount);
    433 
    434         if (!InterlockedDecrement(&This->ref))
    435         {
    436           if (This->pcRefDll) InterlockedDecrement(This->pcRefDll);
    437 
    438           TRACE("-- destroying IClassFactory(%p)\n",This);
    439           HeapFree(GetProcessHeap(),0,This);
    440           return 0;
    441         }
    442         return This->ref;
     430    ICOM_THIS(IDefClFImpl,iface);
     431    TRACE("(%p)->(count=%lu)\n",This,This->ref);
     432
     433    InterlockedDecrement(&shell32_ObjCount);
     434
     435    if (!InterlockedDecrement(&This->ref))
     436    {
     437      if (This->pcRefDll) InterlockedDecrement(This->pcRefDll);
     438
     439      TRACE("-- destroying IClassFactory(%p)\n",This);
     440      HeapFree(GetProcessHeap(),0,This);
     441      return 0;
     442    }
     443    return This->ref;
    443444}
    444445/******************************************************************************
     
    448449  LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
    449450{
    450         ICOM_THIS(IDefClFImpl,iface);
    451 
    452         TRACE("%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnkOuter,debugstr_guid(riid),ppvObject);
    453 
    454         *ppvObject = NULL;
    455                
    456         if(pUnkOuter)
    457           return(CLASS_E_NOAGGREGATION);
    458 
    459         if ( This->riidInst==NULL ||
    460              IsEqualCLSID(riid, This->riidInst) ||
    461              IsEqualCLSID(riid, &IID_IUnknown) )
    462         {
    463           return This->lpfnCI(pUnkOuter, riid, ppvObject);
    464         }
    465 
    466         ERR("unknown IID requested\n\tIID:\t%s\n",debugstr_guid(riid));
    467         return E_NOINTERFACE;
     451    ICOM_THIS(IDefClFImpl,iface);
     452
     453    TRACE("%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnkOuter,debugstr_guid(riid),ppvObject);
     454
     455    *ppvObject = NULL;
     456
     457    if(pUnkOuter)
     458      return(CLASS_E_NOAGGREGATION);
     459
     460    if ( This->riidInst==NULL ||
     461         IsEqualCLSID(riid, This->riidInst) ||
     462         IsEqualCLSID(riid, &IID_IUnknown) )
     463    {
     464      return This->lpfnCI(pUnkOuter, riid, ppvObject);
     465    }
     466
     467    ERR("unknown IID requested\n\tIID:\t%s\n",debugstr_guid(riid));
     468    return E_NOINTERFACE;
    468469}
    469470/******************************************************************************
     
    472473static HRESULT WINAPI IDefClF_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
    473474{
    474         ICOM_THIS(IDefClFImpl,iface);
    475         TRACE("%p->(0x%x), not implemented\n",This, fLock);
    476         return E_NOTIMPL;
    477 }
    478 
    479 static ICOM_VTABLE(IClassFactory) dclfvt = 
     475    ICOM_THIS(IDefClFImpl,iface);
     476    TRACE("%p->(0x%x), not implemented\n",This, fLock);
     477    return E_NOTIMPL;
     478}
     479
     480static ICOM_VTABLE(IClassFactory) dclfvt =
    480481{
    481482    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     
    488489
    489490/******************************************************************************
    490  * SHCreateDefClassObject                       [SHELL32.70]
     491 * SHCreateDefClassObject           [SHELL32.70]
    491492 */
    492493HRESULT WINAPI SHCreateDefClassObject(
    493         REFIID  riid,                           
    494         LPVOID* ppv,   
    495         LPFNCREATEINSTANCE lpfnCI,      /* [in] create instance callback entry */
    496         PLONG   pcRefDll,               /* [in/out] ref count of the dll */
    497         REFIID  riidInst)               /* [in] optional interface to the instance */
    498 {
    499         TRACE("\n\tIID:\t%s %p %p %p \n\tIIDIns:\t%s\n",
     494    REFIID  riid,
     495    LPVOID* ppv,
     496    LPFNCREATEINSTANCE lpfnCI,  /* [in] create instance callback entry */
     497    PLONG   pcRefDll,       /* [in/out] ref count of the dll */
     498    REFIID  riidInst)       /* [in] optional interface to the instance */
     499{
     500    TRACE("\n\tIID:\t%s %p %p %p \n\tIIDIns:\t%s\n",
    500501              debugstr_guid(riid), ppv, lpfnCI, pcRefDll, debugstr_guid(riidInst));
    501502
    502         if ( IsEqualCLSID(riid, &IID_IClassFactory) )
    503         {
    504           IClassFactory * pcf = IDefClF_fnConstructor(lpfnCI, pcRefDll, riidInst);
    505           if (pcf)
    506           {
    507             *ppv = pcf;
    508             return NOERROR;
    509           }
    510           return E_OUTOFMEMORY;
    511         }
    512         return E_NOINTERFACE;
    513 }
    514 
    515 /*************************************************************************
    516  *  DragAcceptFiles             [SHELL32.54]
     503    if ( IsEqualCLSID(riid, &IID_IClassFactory) )
     504    {
     505      IClassFactory * pcf = IDefClF_fnConstructor(lpfnCI, pcRefDll, riidInst);
     506      if (pcf)
     507      {
     508        *ppv = pcf;
     509        return NOERROR;
     510      }
     511      return E_OUTOFMEMORY;
     512    }
     513    return E_NOINTERFACE;
     514}
     515
     516/*************************************************************************
     517 *  DragAcceptFiles     [SHELL32.54]
    517518 */
    518519void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
    519520{
    520         LONG exstyle;
    521  
    522         if( !IsWindow(hWnd) ) return;
    523         exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE);
    524         if (b)
    525           exstyle |= WS_EX_ACCEPTFILES;
    526         else
    527           exstyle &= ~WS_EX_ACCEPTFILES;
    528         SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle);
    529 }
    530 
    531 /*************************************************************************
    532  * DragFinish           [SHELL32.80]
     521    LONG exstyle;
     522
     523    if( !IsWindow(hWnd) ) return;
     524    exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE);
     525    if (b)
     526      exstyle |= WS_EX_ACCEPTFILES;
     527    else
     528      exstyle &= ~WS_EX_ACCEPTFILES;
     529    SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle);
     530}
     531
     532/*************************************************************************
     533 * DragFinish       [SHELL32.80]
    533534 */
    534535void WINAPI DragFinish(HDROP h)
    535536{
    536         TRACE("\n");
    537         GlobalFree((HGLOBAL)h);
    538 }
    539 
    540 /*************************************************************************
    541  * DragQueryPoint               [SHELL32.135]
     537    TRACE("\n");
     538    GlobalFree((HGLOBAL)h);
     539}
     540
     541/*************************************************************************
     542 * DragQueryPoint       [SHELL32.135]
    542543 */
    543544BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p)
    544545{
    545546        DROPFILES *lpDropFileStruct;
    546         BOOL bRet;
    547 
    548         TRACE("\n");
    549 
    550         lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
     547    BOOL bRet;
     548
     549    TRACE("\n");
     550
     551    lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
    551552
    552553        *p = lpDropFileStruct->pt;
    553         bRet = lpDropFileStruct->fNC;
    554  
    555         GlobalUnlock(hDrop);
    556         return bRet;
    557 }
    558 
    559 /*************************************************************************
    560  *  DragQueryFileA              [SHELL32.81] [shell32.82]
     554    bRet = lpDropFileStruct->fNC;
     555
     556    GlobalUnlock(hDrop);
     557    return bRet;
     558}
     559
     560/*************************************************************************
     561 *  DragQueryFileA      [SHELL32.81] [shell32.82]
    561562 */
    562563UINT WINAPI DragQueryFileA(
    563         HDROP hDrop,
    564         UINT lFile,
    565         LPSTR lpszFile,
    566         UINT lLength)
    567 {
    568         LPSTR lpDrop;
    569         UINT i = 0;
    570         DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
    571    
    572         TRACE("(%08x, %x, %p, %u)\n",   hDrop,lFile,lpszFile,lLength);
    573    
    574         if(!lpDropFileStruct) goto end;
    575 
    576         lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->pFiles;
    577 
    578         while (i++ < lFile)
    579         {
    580           while (*lpDrop++); /* skip filename */
    581           if (!*lpDrop)
    582           {
    583             i = (lFile == 0xFFFFFFFF) ? i : 0;
    584             goto end;
    585           }
    586         }
    587    
    588         i = strlen(lpDrop);
    589         i++;
    590         if (!lpszFile ) goto end;   /* needed buffer size */
    591         i = (lLength > i) ? i : lLength;
    592         lstrcpynA (lpszFile,  lpDrop,  i);
     564    HDROP hDrop,
     565    UINT lFile,
     566    LPSTR lpszFile,
     567    UINT lLength)
     568{
     569    LPSTR lpDrop;
     570    UINT i = 0;
     571    DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
     572
     573    TRACE("(%08x, %x, %p, %u)\n",   hDrop,lFile,lpszFile,lLength);
     574
     575    if(!lpDropFileStruct) goto end;
     576
     577    lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->pFiles;
     578
     579    while (i++ < lFile)
     580    {
     581      while (*lpDrop++); /* skip filename */
     582      if (!*lpDrop)
     583      {
     584        i = (lFile == 0xFFFFFFFF) ? i : 0;
     585        goto end;
     586      }
     587    }
     588
     589    i = strlen(lpDrop);
     590    i++;
     591    if (!lpszFile ) goto end;   /* needed buffer size */
     592    i = (lLength > i) ? i : lLength;
     593    lstrcpynA (lpszFile,  lpDrop,  i);
    593594end:
    594         GlobalUnlock(hDrop);
    595         return i;
    596 }
    597 
    598 /*************************************************************************
    599  *  DragQueryFileW              [shell32.133]
     595    GlobalUnlock(hDrop);
     596    return i;
     597}
     598
     599/*************************************************************************
     600 *  DragQueryFileW      [shell32.133]
    600601 */
    601602UINT WINAPI DragQueryFileW(
    602         HDROP hDrop,
    603         UINT lFile,
    604         LPWSTR lpszwFile,
    605         UINT lLength)
    606 {
    607         LPWSTR lpwDrop;
    608         UINT i = 0;
    609         DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
    610    
    611         TRACE("(%08x, %x, %p, %u)\n", hDrop,lFile,lpszwFile,lLength);
    612    
    613         if(!lpDropFileStruct) goto end;
    614 
    615         lpwDrop = (LPWSTR) lpDropFileStruct + lpDropFileStruct->pFiles;
    616 
    617         i = 0;
    618         while (i++ < lFile)
    619         {
    620           while (*lpwDrop++); /* skip filename */
    621           if (!*lpwDrop)
    622           {
    623             i = (lFile == 0xFFFFFFFF) ? i : 0;
    624             goto end;
    625           }
    626         }
    627    
    628         i = strlenW(lpwDrop);
    629         i++;
    630         if ( !lpszwFile) goto end;   /* needed buffer size */
    631 
    632         i = (lLength > i) ? i : lLength;
    633         lstrcpynW (lpszwFile, lpwDrop, i);
     603    HDROP hDrop,
     604    UINT lFile,
     605    LPWSTR lpszwFile,
     606    UINT lLength)
     607{
     608    LPWSTR lpwDrop;
     609    UINT i = 0;
     610    DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
     611
     612    TRACE("(%08x, %x, %p, %u)\n", hDrop,lFile,lpszwFile,lLength);
     613
     614    if(!lpDropFileStruct) goto end;
     615
     616    lpwDrop = (LPWSTR) lpDropFileStruct + lpDropFileStruct->pFiles;
     617
     618    i = 0;
     619    while (i++ < lFile)
     620    {
     621      while (*lpwDrop++); /* skip filename */
     622      if (!*lpwDrop)
     623      {
     624        i = (lFile == 0xFFFFFFFF) ? i : 0;
     625        goto end;
     626      }
     627    }
     628
     629    i = strlenW(lpwDrop);
     630    i++;
     631    if ( !lpszwFile) goto end;   /* needed buffer size */
     632
     633    i = (lLength > i) ? i : lLength;
     634    lstrcpynW (lpszwFile, lpwDrop, i);
    634635end:
    635         GlobalUnlock(hDrop);
    636         return i;
    637 }
     636    GlobalUnlock(hDrop);
     637    return i;
     638}
Note: See TracChangeset for help on using the changeset viewer.