[WINHTTP] Sync with Wine Staging 3.9. CORE-14656
[reactos.git] / dll / win32 / winhttp / main.c
index 263814e..a63f28c 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
-
 #define COBJMACROS
-#include <config.h>
+#include "config.h"
 #include <stdarg.h>
 
-#include <windef.h>
-#include <winbase.h>
-#include <objbase.h>
-#include <rpcproxy.h>
-#include <httprequest.h>
-#include <winhttp.h>
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+#include "rpcproxy.h"
+#include "httprequest.h"
+#include "winhttp.h"
 
-#include <wine/debug.h>
+#include "wine/debug.h"
 #include "winhttp_private.h"
 
-static HINSTANCE instance;
+HINSTANCE winhttp_instance;
 
 WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
 
@@ -46,17 +42,19 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
     switch(fdwReason)
     {
     case DLL_PROCESS_ATTACH:
-        instance = hInstDLL;
+        winhttp_instance = hInstDLL;
         DisableThreadLibraryCalls(hInstDLL);
         break;
     case DLL_PROCESS_DETACH:
+        if (lpv) break;
         netconn_unload();
+        release_typelib();
         break;
     }
     return TRUE;
 }
 
-typedef HRESULT (*fnCreateInstance)( IUnknown *outer, void **obj );
+typedef HRESULT (*fnCreateInstance)( void **obj );
 
 struct winhttp_cf
 {
@@ -113,14 +111,11 @@ static HRESULT WINAPI requestcf_CreateInstance(
     if (outer)
         return CLASS_E_NOAGGREGATION;
 
-    hr = cf->pfnCreateInstance( outer, (void **)&unknown );
+    hr = cf->pfnCreateInstance( (void **)&unknown );
     if (FAILED(hr))
         return hr;
 
     hr = IUnknown_QueryInterface( unknown, riid, obj );
-    if (FAILED(hr))
-        return hr;
-
     IUnknown_Release( unknown );
     return hr;
 }
@@ -174,7 +169,7 @@ HRESULT WINAPI DllCanUnloadNow(void)
  */
 HRESULT WINAPI DllRegisterServer(void)
 {
-    return __wine_register_resources( instance );
+    return __wine_register_resources( winhttp_instance );
 }
 
 /***********************************************************************
@@ -182,5 +177,5 @@ HRESULT WINAPI DllRegisterServer(void)
  */
 HRESULT WINAPI DllUnregisterServer(void)
 {
-    return __wine_unregister_resources( instance );
+    return __wine_unregister_resources( winhttp_instance );
 }