Made some more spec file entries optional or unnecessary.
[wine] / dlls / comcat / comcat_main.c
1 /*
2  *      exported dll functions for comcat.dll
3  *
4  * Copyright (C) 2002 John K. Hohm
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "comcat.h"
22 #include "regsvr.h"
23
24 #include "wine/debug.h"
25
26 WINE_DEFAULT_DEBUG_CHANNEL(ole);
27
28 DWORD dll_ref = 0;
29 HINSTANCE COMCAT_hInstance = 0;
30
31 /***********************************************************************
32  *              Global string constant definitions
33  */
34 const WCHAR clsid_keyname[6] = { 'C', 'L', 'S', 'I', 'D', 0 };
35
36 /***********************************************************************
37  *              Registration entries
38  */
39 static const WCHAR class_keyname[39] = {
40     '{', '0', '0', '0', '2', 'E', '0', '0', '5', '-', '0', '0',
41     '0', '0', '-', '0', '0', '0', '0', '-', 'C', '0', '0', '0',
42     '-', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '4',
43     '6', '}', 0 };
44 static const WCHAR class_name[26] = {
45     'S', 't', 'd', 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n', 't',
46     'C', 'a', 't', 'e', 'g', 'o', 'r', 'i', 'e', 's', 'M', 'g',
47     'r', 0 };
48 static const WCHAR ips32_keyname[15] = {
49     'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
50     '3', '2', 0 };
51 static const WCHAR tm_valname[15] = {
52     'T', 'h', 'r', 'e', 'a', 'd', 'i', 'n', 'g', 'M', 'o', 'd',
53     'e', 'l', 0 };
54 static const WCHAR tm_value[5] = { 'B', 'o', 't', 'h', 0 };
55 static struct regsvr_entry regsvr_entries[6] = {
56     { HKEY_CLASSES_ROOT, 0, clsid_keyname },
57     { 0,                 1, class_keyname },
58     { 1,                 1, NULL, class_name },
59     { 1,                 1, ips32_keyname },
60     { 3,                 1, NULL, /*dynamic, path to dll module*/ },
61     { 3,                 1, tm_valname, tm_value }
62 };
63
64 /***********************************************************************
65  *              DllEntryPoint
66  */
67 BOOL WINAPI COMCAT_DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
68 {
69     TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
70
71     switch(fdwReason) {
72     case DLL_PROCESS_ATTACH:
73         COMCAT_hInstance = hinstDLL;
74         break;
75
76     case DLL_PROCESS_DETACH:
77         COMCAT_hInstance = 0;
78         break;
79     }
80     return TRUE;
81 }
82
83 /***********************************************************************
84  *              DllGetClassObject (COMCAT.@)
85  */
86 HRESULT WINAPI COMCAT_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
87 {
88     *ppv = NULL;
89     if (IsEqualGUID(rclsid, &CLSID_StdComponentCategoriesMgr)) {
90         return IClassFactory_QueryInterface((LPCLASSFACTORY)&COMCAT_ClassFactory, iid, ppv);
91     }
92     FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
93     return CLASS_E_CLASSNOTAVAILABLE;
94 }
95
96 /***********************************************************************
97  *              DllCanUnloadNow (COMCAT.@)
98  */
99 HRESULT WINAPI COMCAT_DllCanUnloadNow()
100 {
101     return dll_ref != 0 ? S_FALSE : S_OK;
102 }
103
104 /***********************************************************************
105  *              DllRegisterServer (COMCAT.@)
106  */
107 HRESULT WINAPI COMCAT_DllRegisterServer()
108 {
109     WCHAR dll_module[MAX_PATH];
110
111     TRACE("\n");
112
113     if (!GetModuleFileNameW(COMCAT_hInstance, dll_module,
114                             sizeof dll_module / sizeof(WCHAR)))
115         return HRESULT_FROM_WIN32(GetLastError());
116
117     regsvr_entries[4].value = dll_module;
118     return regsvr_register(regsvr_entries, 6);
119 }
120
121 /***********************************************************************
122  *              DllUnregisterServer (COMCAT.@)
123  */
124 HRESULT WINAPI COMCAT_DllUnregisterServer()
125 {
126     WCHAR dll_module[MAX_PATH];
127
128     TRACE("\n");
129
130     if (!GetModuleFileNameW(COMCAT_hInstance, dll_module,
131                             sizeof dll_module / sizeof(WCHAR)))
132         return HRESULT_FROM_WIN32(GetLastError());
133
134     regsvr_entries[4].value = dll_module;
135     return regsvr_unregister(regsvr_entries, 6);
136 }