[KSPROXY]
[reactos.git] / reactos / dll / cpl / odbccp32 / odbccp32.c
1 /* $Id$
2 *
3 * PROJECT: ReactOS ODBC Control Panel Applet
4 * FILE: lib/cpl/main/main.c
5 * PURPOSE: applet initialization
6 * PROGRAMMER: Johannes Anderwald
7 */
8
9 #include "odbccp32.h"
10
11 HINSTANCE hApplet = NULL;
12 APPLET_PROC ODBCProc = NULL;
13 HMODULE hLibrary = NULL;
14
15
16 LONG
17 CALLBACK
18 CPlApplet(HWND hwndCpl,
19 UINT uMsg,
20 LPARAM lParam1,
21 LPARAM lParam2)
22 {
23 if (ODBCProc == NULL)
24 {
25 TCHAR szBuffer[MAX_PATH];
26
27 if (ExpandEnvironmentStrings(_T("%systemroot%\\system32\\odbccp32.dll"),
28 szBuffer,
29 sizeof(szBuffer) / sizeof(TCHAR)) > 0)
30 {
31 hLibrary = LoadLibrary(szBuffer);
32 if (hLibrary)
33 {
34 ODBCProc = (APPLET_PROC)GetProcAddress(hLibrary, "ODBCCPlApplet");
35 }
36 }
37 }
38
39 if (ODBCProc)
40 {
41 return ODBCProc(hwndCpl, uMsg, lParam1, lParam2);
42 }
43 else
44 {
45 if(hLibrary)
46 {
47 FreeLibrary(hLibrary);
48 }
49
50 TerminateProcess(GetCurrentProcess(), -1);
51 return (LONG)-1;
52 }
53 }
54
55
56 BOOL
57 WINAPI
58 DllMain(HINSTANCE hinstDLL,
59 DWORD dwReason,
60 LPVOID lpReserved)
61 {
62 INITCOMMONCONTROLSEX InitControls;
63 UNREFERENCED_PARAMETER(lpReserved);
64
65 switch(dwReason)
66 {
67 case DLL_PROCESS_ATTACH:
68 case DLL_THREAD_ATTACH:
69
70 InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
71 InitControls.dwICC = ICC_LISTVIEW_CLASSES | ICC_UPDOWN_CLASS | ICC_BAR_CLASSES;
72 InitCommonControlsEx(&InitControls);
73
74 hApplet = hinstDLL;
75 break;
76 }
77
78 return TRUE;
79 }
80