Free comctl32 on unload.
[wine] / dlls / shlwapi / shlwapi_main.c
1 /*
2  * SHLWAPI initialisation
3  *
4  *  Copyright 1998 Marcus Meissner
5  *  Copyright 1998 Juergen Schmied (jsch)
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include "winbase.h"
23 #include "winerror.h"
24 #include "wine/debug.h"
25 #define NO_SHLWAPI_REG
26 #define NO_SHLWAPI_STREAM
27 #include "shlwapi.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(shell);
30
31 HINSTANCE shlwapi_hInstance = 0;
32 HMODULE SHLWAPI_hshell32 = 0;
33 HMODULE SHLWAPI_hwinmm = 0;
34 HMODULE SHLWAPI_hcomdlg32 = 0;
35 HMODULE SHLWAPI_hcomctl32 = 0;
36 HMODULE SHLWAPI_hmpr = 0;
37 HMODULE SHLWAPI_hmlang = 0;
38 HMODULE SHLWAPI_hversion = 0;
39
40 DWORD SHLWAPI_ThreadRef_index = -1;
41
42 /*************************************************************************
43  * SHLWAPI LibMain
44  *
45  * NOTES
46  *  calling oleinitialize here breaks sone apps.
47  */
48 BOOL WINAPI SHLWAPI_LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
49 {
50         TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
51         switch (fdwReason)
52         {
53           case DLL_PROCESS_ATTACH:
54             shlwapi_hInstance = hinstDLL;
55             SHLWAPI_ThreadRef_index = TlsAlloc();
56             break;
57           case DLL_PROCESS_DETACH:
58             if (SHLWAPI_hshell32)  FreeLibrary(SHLWAPI_hshell32);
59             if (SHLWAPI_hwinmm)    FreeLibrary(SHLWAPI_hwinmm);
60             if (SHLWAPI_hcomdlg32) FreeLibrary(SHLWAPI_hcomdlg32);
61             if (SHLWAPI_hcomctl32) FreeLibrary(SHLWAPI_hcomctl32);
62             if (SHLWAPI_hmpr)      FreeLibrary(SHLWAPI_hmpr);
63             if (SHLWAPI_hmlang)    FreeLibrary(SHLWAPI_hmlang);
64             if (SHLWAPI_hversion)  FreeLibrary(SHLWAPI_hversion);
65             if (SHLWAPI_ThreadRef_index >= 0) TlsFree(SHLWAPI_ThreadRef_index);
66             break;
67         }
68         return TRUE;
69 }
70
71 /***********************************************************************
72  * DllGetVersion [SHLWAPI.@]
73  *
74  * Retrieves version information of the 'SHLWAPI.DLL'
75  *
76  * PARAMS
77  *     pdvi [O] pointer to version information structure.
78  *
79  * RETURNS
80  *     Success: S_OK
81  *     Failure: E_INVALIDARG
82  *
83  * NOTES
84  *     Returns version of a SHLWAPI.dll from IE5.01.
85  */
86
87 HRESULT WINAPI SHLWAPI_DllGetVersion (DLLVERSIONINFO *pdvi)
88 {
89         if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
90         {
91           WARN("wrong DLLVERSIONINFO size from app\n");
92           return E_INVALIDARG;
93         }
94
95         pdvi->dwMajorVersion = 5;
96         pdvi->dwMinorVersion = 0;
97         pdvi->dwBuildNumber = 2314;
98         pdvi->dwPlatformID = 1000;
99
100         TRACE("%lu.%lu.%lu.%lu\n",
101            pdvi->dwMajorVersion, pdvi->dwMinorVersion,
102            pdvi->dwBuildNumber, pdvi->dwPlatformID);
103
104         return S_OK;
105 }