52 #include <sbWindowsUtils.h>
93 switch (aReasonForCall)
95 case DLL_PROCESS_ATTACH :
100 DisableThreadLibraryCalls(aModule);
143 if (!InlineIsEqualGUID(aCLSID, CLSID_sbWindowsFormatter))
144 return CLASS_E_CLASSNOTAVAILABLE;
147 if (IsBadWritePtr(aClassObject,
sizeof(
void*)))
151 *aClassObject = NULL;
157 return E_OUTOFMEMORY;
159 sbAutoIUnknown autoFactory(factory);
163 if (!SUCCEEDED(result))
177 TCHAR appIDGUID[] = _T(CLSIDStr_sbWindowsFormatter);
181 TCHAR dllModulePath[MAX_PATH];
183 length = GetModuleFileName(
gDLLModule, dllModulePath, MAX_PATH);
184 if ((length <= 0) || (length == MAX_PATH))
185 return HRESULT_FROM_WIN32(GetLastError());
195 result = RegCreateKeyEx(HKEY_CLASSES_ROOT,
196 _T(
"CLSID\\") _T(CLSIDStr_sbWindowsFormatter),
199 REG_OPTION_NON_VOLATILE,
200 KEY_SET_VALUE | KEY_CREATE_SUB_KEY,
204 if (result != ERROR_SUCCESS)
205 return HRESULT_FROM_WIN32(result);
206 sbAutoRegKey autoCLSIDKey(clsidKey);
210 result = RegSetValueEx(clsidKey,
214 reinterpret_cast<const BYTE*>(classDescription),
215 sizeof(classDescription));
216 if (result != ERROR_SUCCESS)
217 return HRESULT_FROM_WIN32(result);
220 result = RegSetValueEx(clsidKey,
224 reinterpret_cast<const BYTE*>(appIDGUID),
226 if (result != ERROR_SUCCESS)
227 return HRESULT_FROM_WIN32(result);
231 TCHAR localizedString[MAX_PATH + 32];
232 StringCchPrintf(localizedString,
233 sizeof(localizedString) /
sizeof(TCHAR),
236 result = RegSetValueExW(clsidKey,
237 _T(
"LocalizedString"),
240 reinterpret_cast<const BYTE*>(localizedString),
241 (_tcsclen(localizedString) + 1) *
sizeof(TCHAR));
242 if (result != ERROR_SUCCESS)
243 return HRESULT_FROM_WIN32(result);
251 HKEY inProcServerKey;
252 result = RegCreateKeyEx(clsidKey,
253 _T(
"InProcServer32"),
256 REG_OPTION_NON_VOLATILE,
261 if (result != ERROR_SUCCESS)
262 return HRESULT_FROM_WIN32(result);
263 sbAutoRegKey autoInProcServerKey(inProcServerKey);
266 result = RegSetValueEx(inProcServerKey,
270 reinterpret_cast<const BYTE*>(dllModulePath),
271 sizeof(TCHAR) * (lstrlen(dllModulePath) + 1));
272 if (result != ERROR_SUCCESS)
273 return HRESULT_FROM_WIN32(result);
276 TCHAR threadingModel[] = _T(
"Apartment");
277 result = RegSetValueEx(inProcServerKey,
278 _T(
"ThreadingModel"),
281 reinterpret_cast<const BYTE*>(threadingModel),
282 sizeof(threadingModel));
283 if (result != ERROR_SUCCESS)
284 return HRESULT_FROM_WIN32(result);
293 result = RegCreateKeyEx(clsidKey,
297 REG_OPTION_NON_VOLATILE,
302 if (result != ERROR_SUCCESS)
303 return HRESULT_FROM_WIN32(result);
304 sbAutoRegKey autoElevationKey(elevationKey);
307 DWORD elevationEnabled = 1;
308 result = RegSetValueEx(elevationKey,
312 reinterpret_cast<const BYTE*>(&elevationEnabled),
313 sizeof(elevationEnabled));
314 if (result != ERROR_SUCCESS)
315 return HRESULT_FROM_WIN32(result);
324 result = RegCreateKeyEx(clsidKey,
328 REG_OPTION_NON_VOLATILE,
333 if (result != ERROR_SUCCESS)
334 return HRESULT_FROM_WIN32(result);
335 sbAutoRegKey autoTypeLibKey(typeLibKey);
338 TCHAR typeLibID[] = _T(LIBIDStr_sbWindowsFormatterLibrary);
339 result = RegSetValueEx(typeLibKey,
343 reinterpret_cast<const BYTE*>(typeLibID),
345 if (result != ERROR_SUCCESS)
346 return HRESULT_FROM_WIN32(result);
356 result = RegCreateKeyEx(HKEY_CLASSES_ROOT,
357 _T(
"AppID\\") _T(CLSIDStr_sbWindowsFormatter),
360 REG_OPTION_NON_VOLATILE,
361 KEY_SET_VALUE | KEY_CREATE_SUB_KEY,
365 if (result != ERROR_SUCCESS)
366 return HRESULT_FROM_WIN32(result);
367 sbAutoRegKey autoAppIDGUIDKey(appIDGUIDKey);
370 TCHAR appDescription[] = _T(
"Songbird Windows Formatter");
371 result = RegSetValueEx(appIDGUIDKey,
375 reinterpret_cast<const BYTE*>(appDescription),
376 sizeof(appDescription));
377 if (result != ERROR_SUCCESS)
378 return HRESULT_FROM_WIN32(result);
381 TCHAR dllSurrogate[] = _T(
"");
382 result = RegSetValueEx(appIDGUIDKey,
386 reinterpret_cast<const BYTE*>(dllSurrogate),
387 sizeof(dllSurrogate));
388 if (result != ERROR_SUCCESS)
389 return HRESULT_FROM_WIN32(result);
398 HKEY appIDExecutableKey;
399 result = RegCreateKeyEx(HKEY_CLASSES_ROOT,
400 _T(
"AppID\\sbWindowsFormatter.dll"),
403 REG_OPTION_NON_VOLATILE,
404 KEY_SET_VALUE | KEY_CREATE_SUB_KEY,
408 if (result != ERROR_SUCCESS)
409 return HRESULT_FROM_WIN32(result);
410 sbAutoRegKey autoAppIDExecutableKey(appIDExecutableKey);
413 result = RegSetValueEx(appIDExecutableKey,
417 reinterpret_cast<const BYTE*>(appIDGUID),
419 if (result != ERROR_SUCCESS)
420 return HRESULT_FROM_WIN32(result);
426 result = LoadTypeLib(dllModulePath, &typeLib);
427 if (result != ERROR_SUCCESS)
428 return HRESULT_FROM_WIN32(result);
429 sbAutoIUnknown autoTypeLib(typeLib);
430 result = RegisterTypeLib(typeLib, dllModulePath, NULL);
431 if (result != ERROR_SUCCESS)
432 return HRESULT_FROM_WIN32(result);
446 UnRegisterTypeLib(LIBID_sbWindowsFormatterLibrary,
453 RegDeleteKey(HKEY_CLASSES_ROOT,
455 _T(CLSIDStr_sbWindowsFormatter)
457 RegDeleteKey(HKEY_CLASSES_ROOT,
459 _T(CLSIDStr_sbWindowsFormatter)
461 RegDeleteKey(HKEY_CLASSES_ROOT,
463 _T(CLSIDStr_sbWindowsFormatter)
464 _T(
"\\InProcServer32"));
465 RegDeleteKey(HKEY_CLASSES_ROOT,
466 _T(
"CLSID\\") _T(CLSIDStr_sbWindowsFormatter));
469 RegDeleteKey(HKEY_CLASSES_ROOT,
470 _T(
"AppID\\") _T(CLSIDStr_sbWindowsFormatter));
473 RegDeleteKey(HKEY_CLASSES_ROOT, _T(
"AppID\\sbWindowsFormatter.dll"));
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription