[SHLWAPI] Sync with Wine Staging 3.3. CORE-14434
[reactos.git] / dll / win32 / shlwapi / shlwapi_main.c
index e595d5f..f466bb4 100644 (file)
 
 WINE_DEFAULT_DEBUG_CHANNEL(shell);
 
-HINSTANCE shlwapi_hInstance = 0;
-DWORD SHLWAPI_ThreadRef_index = TLS_OUT_OF_INDEXES;
+DECLSPEC_HIDDEN HINSTANCE shlwapi_hInstance = 0;
+DECLSPEC_HIDDEN DWORD SHLWAPI_ThreadRef_index = TLS_OUT_OF_INDEXES;
 
 /*************************************************************************
  * SHLWAPI {SHLWAPI}
  *
- * The Shell Light-Weight Api dll provides a large number of utility functions
+ * The Shell Light-Weight API dll provides a large number of utility functions
  * which are commonly required by Win32 programs. Originally distributed with
  * Internet Explorer as a free download, it became a core part of Windows when
  * Internet Explorer was 'integrated' into the O/S with the release of Win98.
@@ -51,7 +51,7 @@ DWORD SHLWAPI_ThreadRef_index = TLS_OUT_OF_INDEXES;
  * SHLWAPI DllMain
  *
  * NOTES
- *  calling oleinitialize here breaks sone apps.
+ *  calling oleinitialize here breaks some apps.
  */
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
 {
@@ -64,6 +64,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
            SHLWAPI_ThreadRef_index = TlsAlloc();
            break;
          case DLL_PROCESS_DETACH:
+            if (fImpLoad) break;
            if (SHLWAPI_ThreadRef_index != TLS_OUT_OF_INDEXES) TlsFree(SHLWAPI_ThreadRef_index);
            break;
        }
@@ -93,6 +94,9 @@ HRESULT WINAPI DllGetVersion (DLLVERSIONINFO *pdvi)
 
   TRACE("(%p)\n",pdvi);
 
+  if (!pdvi)
+    return E_INVALIDARG;
+
   switch (pdvi2->info1.cbSize)
   {
   case sizeof(DLLVERSIONINFO2):
@@ -106,7 +110,7 @@ HRESULT WINAPI DllGetVersion (DLLVERSIONINFO *pdvi)
     pdvi2->info1.dwPlatformID = DLLVER_PLATFORM_WINDOWS;
     return S_OK;
  }
- if (pdvi)
  WARN("pdvi->cbSize = %d, unhandled\n", pdvi2->info1.cbSize);
+
+ WARN("pdvi->cbSize = %d, unhandled\n", pdvi2->info1.cbSize);
  return E_INVALIDARG;
 }