[PATCH 12/13] ole32: Move GetClassFile to moniker.c and move OleRun
to ole2.c.
Robert Shearman
rob at codeweavers.com
Mon Mar 26 12:25:21 CDT 2007
---
dlls/ole32/compobj.c | 102 ------------------------
dlls/ole32/moniker.c | 216
++++++++++++++++++++++++++++++++++----------------
dlls/ole32/ole2.c | 28 ++++++
3 files changed, 173 insertions(+), 173 deletions(-)
-------------- next part --------------
diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index 4ef0ff5..ec37043 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -2001,108 +2001,6 @@ HRESULT WINAPI CoResumeClassObjects(void
}
/***********************************************************************
- * GetClassFile (OLE32.@)
- *
- * Retrieves the class ID associated with the given filename.
- *
- * PARAMS
- * filePathName [I] Filename to retrieve the class ID for.
- * pclsid [O] Address that receives the class ID for the file.
- *
- * RETURNS
- * Success: S_OK.
- * Failure: Any HRESULT code.
- */
-HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid)
-{
- IStorage *pstg=0;
- HRESULT res;
- int nbElm, length, i;
- LONG sizeProgId;
- LPOLESTR *pathDec=0,absFile=0,progId=0;
- LPWSTR extension;
- static const WCHAR bkslashW[] = {'\\',0};
- static const WCHAR dotW[] = {'.',0};
-
- TRACE("%s, %p\n", debugstr_w(filePathName), pclsid);
-
- /* if the file contain a storage object the return the CLSID written by IStorage_SetClass method*/
- if((StgIsStorageFile(filePathName))==S_OK){
-
- res=StgOpenStorage(filePathName,NULL,STGM_READ | STGM_SHARE_DENY_WRITE,NULL,0,&pstg);
-
- if (SUCCEEDED(res))
- res=ReadClassStg(pstg,pclsid);
-
- IStorage_Release(pstg);
-
- return res;
- }
- /* if the file is not a storage object then attemps to match various bits in the file against a
- pattern in the registry. this case is not frequently used ! so I present only the psodocode for
- this case
-
- for(i=0;i<nFileTypes;i++)
-
- for(i=0;j<nPatternsForType;j++){
-
- PATTERN pat;
- HANDLE hFile;
-
- pat=ReadPatternFromRegistry(i,j);
- hFile=CreateFileW(filePathName,,,,,,hFile);
- SetFilePosition(hFile,pat.offset);
- ReadFile(hFile,buf,pat.size,&r,NULL);
- if (memcmp(buf&pat.mask,pat.pattern.pat.size)==0){
-
- *pclsid=ReadCLSIDFromRegistry(i);
- return S_OK;
- }
- }
- */
-
- /* if the above strategies fail then search for the extension key in the registry */
-
- /* get the last element (absolute file) in the path name */
- nbElm=FileMonikerImpl_DecomposePath(filePathName,&pathDec);
- absFile=pathDec[nbElm-1];
-
- /* failed if the path represente a directory and not an absolute file name*/
- if (!lstrcmpW(absFile, bkslashW))
- return MK_E_INVALIDEXTENSION;
-
- /* get the extension of the file */
- extension = NULL;
- length=lstrlenW(absFile);
- for(i = length-1; (i >= 0) && *(extension = &absFile[i]) != '.'; i--)
- /* nothing */;
-
- if (!extension || !lstrcmpW(extension, dotW))
- return MK_E_INVALIDEXTENSION;
-
- res=RegQueryValueW(HKEY_CLASSES_ROOT, extension, NULL, &sizeProgId);
-
- /* get the progId associated to the extension */
- progId = CoTaskMemAlloc(sizeProgId);
- res = RegQueryValueW(HKEY_CLASSES_ROOT, extension, progId, &sizeProgId);
-
- if (res==ERROR_SUCCESS)
- /* return the clsid associated to the progId */
- res= CLSIDFromProgID(progId,pclsid);
-
- for(i=0; pathDec[i]!=NULL;i++)
- CoTaskMemFree(pathDec[i]);
- CoTaskMemFree(pathDec);
-
- CoTaskMemFree(progId);
-
- if (res==ERROR_SUCCESS)
- return res;
-
- return MK_E_INVALIDEXTENSION;
-}
-
-/***********************************************************************
* CoCreateInstance [OLE32.@]
*
* Creates an instance of the specified class.
diff --git a/dlls/ole32/moniker.c b/dlls/ole32/moniker.c
index d34860d..99ab450 100644
--- a/dlls/ole32/moniker.c
+++ b/dlls/ole32/moniker.c
@@ -734,6 +734,66 @@ RunningObjectTableImpl_EnumRunning(IRunn
return hr;
}
+/* Virtual function table for the IRunningObjectTable class. */
+static const IRunningObjectTableVtbl VT_RunningObjectTableImpl =
+{
+ RunningObjectTableImpl_QueryInterface,
+ RunningObjectTableImpl_AddRef,
+ RunningObjectTableImpl_Release,
+ RunningObjectTableImpl_Register,
+ RunningObjectTableImpl_Revoke,
+ RunningObjectTableImpl_IsRunning,
+ RunningObjectTableImpl_GetObject,
+ RunningObjectTableImpl_NoteChangeTime,
+ RunningObjectTableImpl_GetTimeOfLastChange,
+ RunningObjectTableImpl_EnumRunning
+};
+
+/***********************************************************************
+ * RunningObjectTable_Initialize
+ */
+HRESULT WINAPI RunningObjectTableImpl_Initialize(void)
+{
+ TRACE("\n");
+
+ /* create the unique instance of the RunningObjectTableImpl structure */
+ runningObjectTableInstance = HeapAlloc(GetProcessHeap(), 0, sizeof(RunningObjectTableImpl));
+
+ if (!runningObjectTableInstance)
+ return E_OUTOFMEMORY;
+
+ /* initialize the virtual table function */
+ runningObjectTableInstance->lpVtbl = &VT_RunningObjectTableImpl;
+
+ /* the initial reference is set to "1" ! because if set to "0" it will be not practis when */
+ /* the ROT referred many times not in the same time (all the objects in the ROT will */
+ /* be removed every time the ROT is removed ) */
+ runningObjectTableInstance->ref = 1;
+
+ list_init(&runningObjectTableInstance->rot);
+ InitializeCriticalSection(&runningObjectTableInstance->lock);
+ DEBUG_SET_CRITSEC_NAME(&runningObjectTableInstance->lock, "RunningObjectTableImpl.lock");
+
+ return S_OK;
+}
+
+/***********************************************************************
+ * RunningObjectTable_UnInitialize
+ */
+HRESULT WINAPI RunningObjectTableImpl_UnInitialize(void)
+{
+ TRACE("\n");
+
+ if (runningObjectTableInstance==NULL)
+ return E_POINTER;
+
+ RunningObjectTableImpl_Release((IRunningObjectTable*)runningObjectTableInstance);
+
+ RunningObjectTableImpl_Destroy();
+
+ return S_OK;
+}
+
/***********************************************************************
* GetRunningObjectTable (OLE32.@)
*
@@ -767,105 +827,119 @@ GetRunningObjectTable(DWORD reserved, LP
}
/******************************************************************************
- * OleRun [OLE32.@]
+ * MkParseDisplayName [OLE32.@]
+ */
+HRESULT WINAPI MkParseDisplayName(LPBC pbc, LPCOLESTR szUserName,
+ LPDWORD pchEaten, LPMONIKER *ppmk)
+{
+ FIXME("(%p, %s, %p, %p): stub.\n", pbc, debugstr_w(szUserName), pchEaten, *ppmk);
+
+ if (!(IsValidInterface((LPUNKNOWN) pbc)))
+ return E_INVALIDARG;
+
+ return MK_E_SYNTAX;
+}
+
+/***********************************************************************
+ * GetClassFile (OLE32.@)
*
- * Set the OLE object to the running state.
+ * Retrieves the class ID associated with the given filename.
*
* PARAMS
- * pUnknown [I] OLE object to run.
+ * filePathName [I] Filename to retrieve the class ID for.
+ * pclsid [O] Address that receives the class ID for the file.
*
* RETURNS
* Success: S_OK.
* Failure: Any HRESULT code.
*/
-HRESULT WINAPI OleRun(LPUNKNOWN pUnknown)
+HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid)
{
- IRunnableObject *runable;
- HRESULT hres;
+ IStorage *pstg=0;
+ HRESULT res;
+ int nbElm, length, i;
+ LONG sizeProgId;
+ LPOLESTR *pathDec=0,absFile=0,progId=0;
+ LPWSTR extension;
+ static const WCHAR bkslashW[] = {'\\',0};
+ static const WCHAR dotW[] = {'.',0};
- TRACE("(%p)\n", pUnknown);
+ TRACE("%s, %p\n", debugstr_w(filePathName), pclsid);
- hres = IUnknown_QueryInterface(pUnknown, &IID_IRunnableObject, (void**)&runable);
- if (FAILED(hres))
- return S_OK; /* Appears to return no error. */
+ /* if the file contain a storage object the return the CLSID written by IStorage_SetClass method*/
+ if((StgIsStorageFile(filePathName))==S_OK){
- hres = IRunnableObject_Run(runable, NULL);
- IRunnableObject_Release(runable);
- return hres;
-}
+ res=StgOpenStorage(filePathName,NULL,STGM_READ | STGM_SHARE_DENY_WRITE,NULL,0,&pstg);
-/******************************************************************************
- * MkParseDisplayName [OLE32.@]
- */
-HRESULT WINAPI MkParseDisplayName(LPBC pbc, LPCOLESTR szUserName,
- LPDWORD pchEaten, LPMONIKER *ppmk)
-{
- FIXME("(%p, %s, %p, %p): stub.\n", pbc, debugstr_w(szUserName), pchEaten, *ppmk);
+ if (SUCCEEDED(res))
+ res=ReadClassStg(pstg,pclsid);
- if (!(IsValidInterface((LPUNKNOWN) pbc)))
- return E_INVALIDARG;
+ IStorage_Release(pstg);
- return MK_E_SYNTAX;
-}
+ return res;
+ }
+ /* if the file is not a storage object then attemps to match various bits in the file against a
+ pattern in the registry. this case is not frequently used ! so I present only the psodocode for
+ this case
-/* Virtual function table for the IRunningObjectTable class. */
-static const IRunningObjectTableVtbl VT_RunningObjectTableImpl =
-{
- RunningObjectTableImpl_QueryInterface,
- RunningObjectTableImpl_AddRef,
- RunningObjectTableImpl_Release,
- RunningObjectTableImpl_Register,
- RunningObjectTableImpl_Revoke,
- RunningObjectTableImpl_IsRunning,
- RunningObjectTableImpl_GetObject,
- RunningObjectTableImpl_NoteChangeTime,
- RunningObjectTableImpl_GetTimeOfLastChange,
- RunningObjectTableImpl_EnumRunning
-};
+ for(i=0;i<nFileTypes;i++)
-/***********************************************************************
- * RunningObjectTable_Initialize
- */
-HRESULT WINAPI RunningObjectTableImpl_Initialize(void)
-{
- TRACE("\n");
+ for(i=0;j<nPatternsForType;j++){
- /* create the unique instance of the RunningObjectTableImpl structure */
- runningObjectTableInstance = HeapAlloc(GetProcessHeap(), 0, sizeof(RunningObjectTableImpl));
+ PATTERN pat;
+ HANDLE hFile;
- if (!runningObjectTableInstance)
- return E_OUTOFMEMORY;
+ pat=ReadPatternFromRegistry(i,j);
+ hFile=CreateFileW(filePathName,,,,,,hFile);
+ SetFilePosition(hFile,pat.offset);
+ ReadFile(hFile,buf,pat.size,&r,NULL);
+ if (memcmp(buf&pat.mask,pat.pattern.pat.size)==0){
- /* initialize the virtual table function */
- runningObjectTableInstance->lpVtbl = &VT_RunningObjectTableImpl;
+ *pclsid=ReadCLSIDFromRegistry(i);
+ return S_OK;
+ }
+ }
+ */
- /* the initial reference is set to "1" ! because if set to "0" it will be not practis when */
- /* the ROT referred many times not in the same time (all the objects in the ROT will */
- /* be removed every time the ROT is removed ) */
- runningObjectTableInstance->ref = 1;
+ /* if the above strategies fail then search for the extension key in the registry */
- list_init(&runningObjectTableInstance->rot);
- InitializeCriticalSection(&runningObjectTableInstance->lock);
- DEBUG_SET_CRITSEC_NAME(&runningObjectTableInstance->lock, "RunningObjectTableImpl.lock");
+ /* get the last element (absolute file) in the path name */
+ nbElm=FileMonikerImpl_DecomposePath(filePathName,&pathDec);
+ absFile=pathDec[nbElm-1];
- return S_OK;
-}
+ /* failed if the path represente a directory and not an absolute file name*/
+ if (!lstrcmpW(absFile, bkslashW))
+ return MK_E_INVALIDEXTENSION;
-/***********************************************************************
- * RunningObjectTable_UnInitialize
- */
-HRESULT WINAPI RunningObjectTableImpl_UnInitialize(void)
-{
- TRACE("\n");
+ /* get the extension of the file */
+ extension = NULL;
+ length=lstrlenW(absFile);
+ for(i = length-1; (i >= 0) && *(extension = &absFile[i]) != '.'; i--)
+ /* nothing */;
- if (runningObjectTableInstance==NULL)
- return E_POINTER;
+ if (!extension || !lstrcmpW(extension, dotW))
+ return MK_E_INVALIDEXTENSION;
- RunningObjectTableImpl_Release((IRunningObjectTable*)runningObjectTableInstance);
+ res=RegQueryValueW(HKEY_CLASSES_ROOT, extension, NULL, &sizeProgId);
- RunningObjectTableImpl_Destroy();
+ /* get the progId associated to the extension */
+ progId = CoTaskMemAlloc(sizeProgId);
+ res = RegQueryValueW(HKEY_CLASSES_ROOT, extension, progId, &sizeProgId);
- return S_OK;
+ if (res==ERROR_SUCCESS)
+ /* return the clsid associated to the progId */
+ res= CLSIDFromProgID(progId,pclsid);
+
+ for(i=0; pathDec[i]!=NULL;i++)
+ CoTaskMemFree(pathDec[i]);
+ CoTaskMemFree(pathDec);
+
+ CoTaskMemFree(progId);
+
+ if (res==ERROR_SUCCESS)
+ return res;
+
+ return MK_E_INVALIDEXTENSION;
}
/***********************************************************************
diff --git a/dlls/ole32/ole2.c b/dlls/ole32/ole2.c
index 924c6cd..8b61ac6 100644
--- a/dlls/ole32/ole2.c
+++ b/dlls/ole32/ole2.c
@@ -934,6 +934,34 @@ HRESULT WINAPI OleSetContainedObject(
}
/******************************************************************************
+ * OleRun [OLE32.@]
+ *
+ * Set the OLE object to the running state.
+ *
+ * PARAMS
+ * pUnknown [I] OLE object to run.
+ *
+ * RETURNS
+ * Success: S_OK.
+ * Failure: Any HRESULT code.
+ */
+HRESULT WINAPI OleRun(LPUNKNOWN pUnknown)
+{
+ IRunnableObject *runable;
+ HRESULT hres;
+
+ TRACE("(%p)\n", pUnknown);
+
+ hres = IUnknown_QueryInterface(pUnknown, &IID_IRunnableObject, (void**)&runable);
+ if (FAILED(hres))
+ return S_OK; /* Appears to return no error. */
+
+ hres = IRunnableObject_Run(runable, NULL);
+ IRunnableObject_Release(runable);
+ return hres;
+}
+
+/******************************************************************************
* OleLoad [OLE32.@]
*/
HRESULT WINAPI OleLoad(
More information about the wine-patches
mailing list