For all DLLs with defined DllMain and which do not require
[wine/multimedia.git] / dlls / shlwapi / shlwapi_main.c
blob8dea8296510d5f2f3573bdb84c0f3c002e3cc39a
1 /*
2 * SHLWAPI initialisation
4 * Copyright 1998 Marcus Meissner
5 * Copyright 1998 Juergen Schmied (jsch)
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.
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.
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
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"
29 WINE_DEFAULT_DEBUG_CHANNEL(shell);
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;
40 DWORD SHLWAPI_ThreadRef_index = -1;
42 /*************************************************************************
43 * SHLWAPI {SHLWAPI}
45 * The Shell Light-Weight Api dll provides a large number of utility functions
46 * which are commonly required by Win32 programs. Originally distributed with
47 * Internet Explorer as a free download, it became a core part of Windows when
48 * Internet Explorer was 'integrated' into the O/S with the release of Win98.
50 * All functions exported by ordinal are undocumented by MS. The vast majority
51 * of these are wrappers for Unicode functions that may not exist on early 16
52 * bit platforms. The remainder perform various small tasks and presumably were
53 * added to facilitate code reuse amongst the MS developers.
56 /*************************************************************************
57 * SHLWAPI DllMain
59 * NOTES
60 * calling oleinitialize here breaks sone apps.
62 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
64 TRACE("%p 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
65 switch (fdwReason)
67 case DLL_PROCESS_ATTACH:
68 DisableThreadLibraryCalls(hinstDLL);
69 shlwapi_hInstance = hinstDLL;
70 SHLWAPI_ThreadRef_index = TlsAlloc();
71 break;
72 case DLL_PROCESS_DETACH:
73 if (SHLWAPI_hshell32) FreeLibrary(SHLWAPI_hshell32);
74 if (SHLWAPI_hwinmm) FreeLibrary(SHLWAPI_hwinmm);
75 if (SHLWAPI_hcomdlg32) FreeLibrary(SHLWAPI_hcomdlg32);
76 if (SHLWAPI_hcomctl32) FreeLibrary(SHLWAPI_hcomctl32);
77 if (SHLWAPI_hmpr) FreeLibrary(SHLWAPI_hmpr);
78 if (SHLWAPI_hmlang) FreeLibrary(SHLWAPI_hmlang);
79 if (SHLWAPI_hversion) FreeLibrary(SHLWAPI_hversion);
80 if (SHLWAPI_ThreadRef_index >= 0) TlsFree(SHLWAPI_ThreadRef_index);
81 break;
83 return TRUE;
86 /***********************************************************************
87 * DllGetVersion [SHLWAPI.@]
89 * Retrieve "shlwapi.dll" version information.
91 * PARAMS
92 * pdvi [O] pointer to version information structure.
94 * RETURNS
95 * Success: S_OK. pdvi is updated with the version information
96 * Failure: E_INVALIDARG, if pdvi->cbSize is not set correctly.
98 * NOTES
99 * You may pass either a DLLVERSIONINFO of DLLVERSIONINFO2 structure
100 * as pdvi, provided that the size is set correctly.
101 * Returns version as shlwapi.dll from IE5.01.
103 HRESULT WINAPI SHLWAPI_DllGetVersion (DLLVERSIONINFO *pdvi)
105 DLLVERSIONINFO2 *pdvi2 = (DLLVERSIONINFO2*)pdvi;
107 TRACE("(%p)\n",pdvi);
109 switch (pdvi2->info1.cbSize)
111 case sizeof(DLLVERSIONINFO2):
112 pdvi2->dwFlags = 0;
113 pdvi2->ullVersion = MAKEDLLVERULL(5, 0, 2314, 0);
114 /* Fall through */
115 case sizeof(DLLVERSIONINFO):
116 pdvi2->info1.dwMajorVersion = 5;
117 pdvi2->info1.dwMinorVersion = 0;
118 pdvi2->info1.dwBuildNumber = 2314;
119 pdvi2->info1.dwPlatformID = 1000;
120 return S_OK;
122 if (pdvi)
123 WARN("pdvi->cbSize = %ld, unhandled\n", pdvi2->info1.cbSize);
124 return E_INVALIDARG;