[SHLWAPI] Highlight a difference and mark the module as synced with Wine Staging...
[reactos.git] / dll / win32 / shlwapi / ordinal.c
index ad5ffa3..4e331f4 100644 (file)
@@ -78,6 +78,12 @@ HANDLE WINAPI SHMapHandle(HANDLE hShared, DWORD dwSrcProcId, DWORD dwDstProcId,
   TRACE("(%p,%d,%d,%08x,%08x)\n", hShared, dwDstProcId, dwSrcProcId,
         dwAccess, dwOptions);
 
+  if (!hShared)
+  {
+    TRACE("Returning handle NULL\n");
+    return NULL;
+  }
+
   /* Get dest process handle */
   if (dwDstProcId == dwMyProcId)
     hDst = GetCurrentProcess();
@@ -239,6 +245,9 @@ BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
 
   TRACE("(%p %d)\n", hShared, dwProcId);
 
+  if (!hShared)
+    return TRUE;
+
   /* Get a copy of the handle for our process, closing the source handle */
   hClose = SHMapHandle(hShared, dwProcId, GetCurrentProcessId(),
                        FILE_MAP_ALL_ACCESS,DUPLICATE_CLOSE_SOURCE);
@@ -431,7 +440,7 @@ exit:
  *  Success: S_OK.   langbuf is set to the language string found.
  *  Failure: E_FAIL, If any arguments are invalid, error occurred, or Explorer
  *           does not contain the setting.
- *           HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), If the buffer is not big enough
+ *           E_NOT_SUFFICIENT_BUFFER, If the buffer is not big enough
  */
 HRESULT WINAPI GetAcceptLanguagesW( LPWSTR langbuf, LPDWORD buflen)
 {
@@ -484,7 +493,7 @@ HRESULT WINAPI GetAcceptLanguagesW( LPWSTR langbuf, LPDWORD buflen)
     }
 
     *buflen = 0;
-    return __HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
+    return E_NOT_SUFFICIENT_BUFFER;
 }
 
 /*************************************************************************
@@ -1364,7 +1373,7 @@ HRESULT WINAPI IUnknown_SetSite(
  *
  * PARAMS
  *  lpUnknown [I] Object supporting the IPersist interface
- *  lpClassId [O] Destination for Class Id
+ *  clsid     [O] Destination for Class Id
  *
  * RETURNS
  *  Success: S_OK. lpClassId contains the Class Id requested.
@@ -1372,23 +1381,30 @@ HRESULT WINAPI IUnknown_SetSite(
  *           E_NOINTERFACE If lpUnknown does not support IPersist,
  *           Or an HRESULT error code.
  */
-HRESULT WINAPI IUnknown_GetClassID(IUnknown *lpUnknown, CLSID* lpClassId)
+HRESULT WINAPI IUnknown_GetClassID(IUnknown *lpUnknown, CLSID *clsid)
 {
-  IPersist* lpPersist;
-  HRESULT hRet = E_FAIL;
+    IPersist *persist;
+    HRESULT hr;
 
-  TRACE("(%p,%s)\n", lpUnknown, debugstr_guid(lpClassId));
+    TRACE("(%p, %p)\n", lpUnknown, clsid);
 
-  if (lpUnknown)
-  {
-    hRet = IUnknown_QueryInterface(lpUnknown,&IID_IPersist,(void**)&lpPersist);
-    if (SUCCEEDED(hRet))
+    if (!lpUnknown)
     {
-      IPersist_GetClassID(lpPersist, lpClassId);
-      IPersist_Release(lpPersist);
+        memset(clsid, 0, sizeof(*clsid));
+        return E_FAIL;
     }
-  }
-  return hRet;
+
+    hr = IUnknown_QueryInterface(lpUnknown, &IID_IPersist, (void**)&persist);
+    if (hr != S_OK)
+    {
+        hr = IUnknown_QueryInterface(lpUnknown, &IID_IPersistFolder, (void**)&persist);
+        if (hr != S_OK)
+            return hr;
+    }
+
+    hr = IPersist_GetClassID(persist, clsid);
+    IPersist_Release(persist);
+    return hr;
 }
 
 /*************************************************************************
@@ -3485,7 +3501,11 @@ HRESULT WINAPI SHInvokeCommand(HWND hWnd, IShellFolder* lpFolder, LPCITEMIDLIST
           cmIci.cbSize = sizeof(cmIci);
           cmIci.fMask = CMIC_MASK_ASYNCOK;
           cmIci.hwnd = hWnd;
+#ifdef __REACTOS__ /* r75561 */
+          cmIci.lpVerb = MAKEINTRESOURCEA(dwCommandId - 1);
+#else
           cmIci.lpVerb = MAKEINTRESOURCEA(dwCommandId);
+#endif
           cmIci.nShow = SW_SHOWNORMAL;
 
           hRet = IContextMenu_InvokeCommand(iContext, &cmIci);
@@ -4015,7 +4035,7 @@ BOOL WINAPI IsOS(DWORD feature)
     case OS_SMALLBUSINESSSERVER:
         ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT)
     case OS_TABLETPC:
-        FIXME("(OS_TABLEPC) What should we return here?\n");
+        FIXME("(OS_TABLETPC) What should we return here?\n");
         return FALSE;
     case OS_SERVERADMINUI:
         FIXME("(OS_SERVERADMINUI) What should we return here?\n");
@@ -4812,7 +4832,7 @@ typedef struct SHELL_USER_PERMISSION { /* ...and this should be in shlwapi.h */
  * NOTES
  *  Call should free returned descriptor with LocalFree
  */
-PSECURITY_DESCRIPTOR WINAPI GetShellSecurityDescriptor(PSHELL_USER_PERMISSION *apUserPerm, int cUserPerm)
+PSECURITY_DESCRIPTOR WINAPI GetShellSecurityDescriptor(const PSHELL_USER_PERMISSION *apUserPerm, int cUserPerm)
 {
     PSID *sidlist;
     PSID  cur_user = NULL;
@@ -5032,11 +5052,8 @@ INT WINAPI SHFormatDateTimeW(const FILETIME UNALIGNED *fileTime, DWORD *flags,
         {
             if ((fmt_flags & FDTF_LONGDATE) && (ret < size + 2))
             {
-                if (ret < size + 2)
-                {
-                   lstrcatW(&buf[ret-1], sep1);
-                   ret += 2;
-                }
+                lstrcatW(&buf[ret-1], sep1);
+                ret += 2;
             }
             else
             {
@@ -5163,9 +5180,9 @@ HRESULT WINAPI IUnknown_QueryServiceForWebBrowserApp(IUnknown* lpUnknown,
  *  pValue: address to receive the property value as a 32-bit signed integer
  *
  * RETURNS
- *  0 for Success
+ *  HRESULT codes
  */
-BOOL WINAPI SHPropertyBag_ReadLONG(IPropertyBag *ppb, LPCWSTR pszPropName, LPLONG pValue)
+HRESULT WINAPI SHPropertyBag_ReadLONG(IPropertyBag *ppb, LPCWSTR pszPropName, LPLONG pValue)
 {
     VARIANT var;
     HRESULT hr;
@@ -5184,6 +5201,46 @@ BOOL WINAPI SHPropertyBag_ReadLONG(IPropertyBag *ppb, LPCWSTR pszPropName, LPLON
     return hr;
 }
 
+#ifdef __REACTOS__
+/**************************************************************************
+ *  SHPropertyBag_WriteLONG (SHLWAPI.497)
+ *
+ * This function asks a property bag to write a named property as a LONG.
+ *
+ * PARAMS
+ *  ppb: a IPropertyBag interface
+ *  pszPropName:  Unicode string that names the property
+ *  lValue: address to receive the property value as a 32-bit signed integer
+ *
+ * RETURNS
+ *  HRESULT codes
+ */
+HRESULT WINAPI SHPropertyBag_WriteLONG(IPropertyBag *ppb, LPCWSTR pszPropName, LONG lValue)
+{
+       UNIMPLEMENTED;
+       return E_NOTIMPL;
+}
+
+/**************************************************************************
+ *  SHPropertyBag_WriteStr (SHLWAPI.495)
+ *
+ * This function asks a property bag to write a string as the value of a named property.
+ *
+ * PARAMS
+ *  ppb: a IPropertyBag interface
+ *  pszPropName:  Unicode string that names the property
+ *  pValue: address to write the property value
+ *
+ * RETURNS
+ *  HRESULT codes
+ */
+HRESULT WINAPI SHPropertyBag_WriteStr(IPropertyBag *ppb, LPCWSTR pszPropName, LPCWSTR pszValue)
+{
+       UNIMPLEMENTED;
+       return E_NOTIMPL;
+}
+#endif
+
 /* return flags for SHGetObjectCompatFlags, names derived from registry value names */
 #define OBJCOMPAT_OTNEEDSSFCACHE           0x00000001
 #define OBJCOMPAT_NO_WEBVIEW               0x00000002