d3d10/effect: Use case-insensitive comparison in GetMemberTypeBySemantic().
[wine.git] / dlls / msi / classes.c
blob52a91b306f192307a0e96825373ba745b6f7ab62
1 /*
2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2005 Aric Stewart for CodeWeavers
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 /* Actions handled in this module:
23 * RegisterClassInfo
24 * RegisterProgIdInfo
25 * RegisterExtensionInfo
26 * RegisterMIMEInfo
27 * UnregisterClassInfo
28 * UnregisterProgIdInfo
29 * UnregisterExtensionInfo
30 * UnregisterMIMEInfo
33 #include <stdarg.h>
35 #include "windef.h"
36 #include "winbase.h"
37 #include "winerror.h"
38 #include "winreg.h"
39 #include "wine/debug.h"
40 #include "msipriv.h"
41 #include "winuser.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(msi);
45 static MSIAPPID *load_appid( MSIPACKAGE* package, MSIRECORD *row )
47 LPCWSTR buffer;
48 MSIAPPID *appid;
50 /* fill in the data */
52 appid = msi_alloc_zero( sizeof(MSIAPPID) );
53 if (!appid)
54 return NULL;
56 appid->AppID = msi_dup_record_field( row, 1 );
57 TRACE("loading appid %s\n", debugstr_w( appid->AppID ));
59 buffer = MSI_RecordGetString(row,2);
60 deformat_string( package, buffer, &appid->RemoteServerName );
62 appid->LocalServer = msi_dup_record_field(row,3);
63 appid->ServiceParameters = msi_dup_record_field(row,4);
64 appid->DllSurrogate = msi_dup_record_field(row,5);
66 appid->ActivateAtStorage = !MSI_RecordIsNull(row,6);
67 appid->RunAsInteractiveUser = !MSI_RecordIsNull(row,7);
69 list_add_tail( &package->appids, &appid->entry );
71 return appid;
74 static MSIAPPID *load_given_appid( MSIPACKAGE *package, LPCWSTR name )
76 MSIRECORD *row;
77 MSIAPPID *appid;
79 if (!name)
80 return NULL;
82 /* check for appids already loaded */
83 LIST_FOR_EACH_ENTRY( appid, &package->appids, MSIAPPID, entry )
85 if (!wcsicmp( appid->AppID, name ))
87 TRACE("found appid %s %p\n", debugstr_w(name), appid);
88 return appid;
92 row = MSI_QueryGetRecord(package->db, L"SELECT * FROM `AppId` WHERE `AppId` = '%s'", name);
93 if (!row)
94 return NULL;
96 appid = load_appid(package, row);
97 msiobj_release(&row->hdr);
98 return appid;
101 static MSIPROGID *load_given_progid(MSIPACKAGE *package, LPCWSTR progid);
102 static MSICLASS *load_given_class( MSIPACKAGE *package, LPCWSTR classid );
104 static MSIPROGID *load_progid( MSIPACKAGE* package, MSIRECORD *row )
106 MSIPROGID *progid;
107 LPCWSTR buffer;
109 /* fill in the data */
111 progid = msi_alloc_zero( sizeof(MSIPROGID) );
112 if (!progid)
113 return NULL;
115 list_add_tail( &package->progids, &progid->entry );
117 progid->ProgID = msi_dup_record_field(row,1);
118 TRACE("loading progid %s\n",debugstr_w(progid->ProgID));
120 buffer = MSI_RecordGetString(row,2);
121 progid->Parent = load_given_progid(package,buffer);
122 if (progid->Parent == NULL && buffer)
123 FIXME("Unknown parent ProgID %s\n",debugstr_w(buffer));
125 buffer = MSI_RecordGetString(row,3);
126 progid->Class = load_given_class(package,buffer);
127 if (progid->Class == NULL && buffer)
128 FIXME("Unknown class %s\n",debugstr_w(buffer));
130 progid->Description = msi_dup_record_field(row,4);
132 if (!MSI_RecordIsNull(row,6))
134 INT icon_index = MSI_RecordGetInteger(row,6);
135 LPCWSTR FileName = MSI_RecordGetString(row,5);
136 LPWSTR FilePath;
138 FilePath = msi_build_icon_path(package, FileName);
140 progid->IconPath = msi_alloc( (lstrlenW(FilePath) + 10) * sizeof(WCHAR) );
141 swprintf( progid->IconPath, lstrlenW(FilePath) + 10, L"%s,%d", FilePath, icon_index );
142 msi_free(FilePath);
144 else
146 buffer = MSI_RecordGetString(row,5);
147 if (buffer)
148 progid->IconPath = msi_build_icon_path(package, buffer);
151 progid->CurVer = NULL;
152 progid->VersionInd = NULL;
154 /* if we have a parent then we may be that parents CurVer */
155 if (progid->Parent && progid->Parent != progid)
157 MSIPROGID *parent = progid->Parent;
159 while (parent->Parent && parent->Parent != parent)
160 parent = parent->Parent;
162 /* FIXME: need to determine if we are really the CurVer */
164 progid->CurVer = parent;
165 parent->VersionInd = progid;
168 return progid;
171 static MSIPROGID *load_given_progid(MSIPACKAGE *package, LPCWSTR name)
173 MSIPROGID *progid;
174 MSIRECORD *row;
176 if (!name)
177 return NULL;
179 /* check for progids already loaded */
180 LIST_FOR_EACH_ENTRY( progid, &package->progids, MSIPROGID, entry )
182 if (!wcsicmp( progid->ProgID, name ))
184 TRACE("found progid %s (%p)\n",debugstr_w(name), progid );
185 return progid;
189 row = MSI_QueryGetRecord( package->db, L"SELECT * FROM `ProgId` WHERE `ProgId` = '%s'", name );
190 if (!row)
191 return NULL;
193 progid = load_progid(package, row);
194 msiobj_release(&row->hdr);
195 return progid;
198 static MSICLASS *load_class( MSIPACKAGE* package, MSIRECORD *row )
200 MSICLASS *cls;
201 DWORD i;
202 LPCWSTR buffer;
204 /* fill in the data */
206 cls = msi_alloc_zero( sizeof(MSICLASS) );
207 if (!cls)
208 return NULL;
210 list_add_tail( &package->classes, &cls->entry );
212 cls->clsid = msi_dup_record_field( row, 1 );
213 TRACE("loading class %s\n",debugstr_w(cls->clsid));
214 cls->Context = msi_dup_record_field( row, 2 );
215 buffer = MSI_RecordGetString(row,3);
216 cls->Component = msi_get_loaded_component( package, buffer );
218 cls->ProgIDText = msi_dup_record_field(row,4);
219 cls->ProgID = load_given_progid(package, cls->ProgIDText);
221 cls->Description = msi_dup_record_field(row,5);
223 buffer = MSI_RecordGetString(row,6);
224 if (buffer)
225 cls->AppID = load_given_appid(package, buffer);
227 cls->FileTypeMask = msi_dup_record_field(row,7);
229 if (!MSI_RecordIsNull(row,9))
232 INT icon_index = MSI_RecordGetInteger(row,9);
233 LPCWSTR FileName = MSI_RecordGetString(row,8);
234 LPWSTR FilePath;
236 FilePath = msi_build_icon_path(package, FileName);
238 cls->IconPath = msi_alloc( (lstrlenW(FilePath) + 5) * sizeof(WCHAR) );
239 swprintf( cls->IconPath, lstrlenW(FilePath) + 5, L"%s,%d", FilePath, icon_index );
240 msi_free(FilePath);
242 else
244 buffer = MSI_RecordGetString(row,8);
245 if (buffer)
246 cls->IconPath = msi_build_icon_path(package, buffer);
249 if (!MSI_RecordIsNull(row,10))
251 i = MSI_RecordGetInteger(row,10);
252 if (i != MSI_NULL_INTEGER && i > 0 && i < 4)
254 switch(i)
256 case 1:
257 cls->DefInprocHandler = strdupW(L"ole2.dll");
258 break;
259 case 2:
260 cls->DefInprocHandler32 = strdupW(L"ole32.dll");
261 break;
262 case 3:
263 cls->DefInprocHandler = strdupW(L"ole2.dll");
264 cls->DefInprocHandler32 = strdupW(L"ole32.dll");
265 break;
268 else
270 cls->DefInprocHandler32 = msi_dup_record_field( row, 10 );
271 msi_reduce_to_long_filename( cls->DefInprocHandler32 );
274 buffer = MSI_RecordGetString(row,11);
275 deformat_string(package,buffer,&cls->Argument);
277 buffer = MSI_RecordGetString(row,12);
278 cls->Feature = msi_get_loaded_feature(package, buffer);
280 cls->Attributes = MSI_RecordGetInteger(row,13);
281 cls->action = INSTALLSTATE_UNKNOWN;
282 return cls;
286 * the Class table has 3 primary keys. Generally it is only
287 * referenced through the first CLSID key. However when loading
288 * all of the classes we need to make sure we do not ignore rows
289 * with other Context and ComponentIndexs
291 static MSICLASS *load_given_class(MSIPACKAGE *package, LPCWSTR classid)
293 MSICLASS *cls;
294 MSIRECORD *row;
296 if (!classid)
297 return NULL;
299 /* check for classes already loaded */
300 LIST_FOR_EACH_ENTRY( cls, &package->classes, MSICLASS, entry )
302 if (!wcsicmp( cls->clsid, classid ))
304 TRACE("found class %s (%p)\n",debugstr_w(classid), cls);
305 return cls;
309 row = MSI_QueryGetRecord( package->db, L"SELECT * FROM `Class` WHERE `CLSID` = '%s'", classid );
310 if (!row)
311 return NULL;
313 cls = load_class(package, row);
314 msiobj_release(&row->hdr);
315 return cls;
318 static MSIEXTENSION *load_given_extension( MSIPACKAGE *package, LPCWSTR extension );
320 static MSIMIME *load_mime( MSIPACKAGE* package, MSIRECORD *row )
322 LPCWSTR extension;
323 MSIMIME *mt;
325 /* fill in the data */
327 mt = msi_alloc_zero( sizeof(MSIMIME) );
328 if (!mt)
329 return mt;
331 mt->ContentType = msi_dup_record_field( row, 1 );
332 TRACE("loading mime %s\n", debugstr_w(mt->ContentType));
334 extension = MSI_RecordGetString( row, 2 );
335 mt->Extension = load_given_extension( package, extension );
336 mt->suffix = strdupW( extension );
338 mt->clsid = msi_dup_record_field( row, 3 );
339 mt->Class = load_given_class( package, mt->clsid );
341 list_add_tail( &package->mimes, &mt->entry );
343 return mt;
346 static MSIMIME *load_given_mime( MSIPACKAGE *package, LPCWSTR mime )
348 MSIRECORD *row;
349 MSIMIME *mt;
351 if (!mime)
352 return NULL;
354 /* check for mime already loaded */
355 LIST_FOR_EACH_ENTRY( mt, &package->mimes, MSIMIME, entry )
357 if (!wcsicmp( mt->ContentType, mime ))
359 TRACE("found mime %s (%p)\n",debugstr_w(mime), mt);
360 return mt;
364 row = MSI_QueryGetRecord( package->db, L"SELECT * FROM `MIME` WHERE `ContentType` = '%s'", mime );
365 if (!row)
366 return NULL;
368 mt = load_mime(package, row);
369 msiobj_release(&row->hdr);
370 return mt;
373 static MSIEXTENSION *load_extension( MSIPACKAGE* package, MSIRECORD *row )
375 MSIEXTENSION *ext;
376 LPCWSTR buffer;
378 /* fill in the data */
380 ext = msi_alloc_zero( sizeof(MSIEXTENSION) );
381 if (!ext)
382 return NULL;
384 list_init( &ext->verbs );
386 list_add_tail( &package->extensions, &ext->entry );
388 ext->Extension = msi_dup_record_field( row, 1 );
389 TRACE("loading extension %s\n", debugstr_w(ext->Extension));
391 buffer = MSI_RecordGetString( row, 2 );
392 ext->Component = msi_get_loaded_component( package, buffer );
394 ext->ProgIDText = msi_dup_record_field( row, 3 );
395 ext->ProgID = load_given_progid( package, ext->ProgIDText );
397 buffer = MSI_RecordGetString( row, 4 );
398 ext->Mime = load_given_mime( package, buffer );
400 buffer = MSI_RecordGetString(row,5);
401 ext->Feature = msi_get_loaded_feature( package, buffer );
402 ext->action = INSTALLSTATE_UNKNOWN;
403 return ext;
407 * While the extension table has 2 primary keys, this function is only looking
408 * at the Extension key which is what is referenced as a foreign key
410 static MSIEXTENSION *load_given_extension( MSIPACKAGE *package, LPCWSTR name )
412 MSIEXTENSION *ext;
413 MSIRECORD *row;
415 if (!name)
416 return NULL;
418 if (name[0] == '.')
419 name++;
421 /* check for extensions already loaded */
422 LIST_FOR_EACH_ENTRY( ext, &package->extensions, MSIEXTENSION, entry )
424 if (!wcsicmp( ext->Extension, name ))
426 TRACE("extension %s already loaded %p\n", debugstr_w(name), ext);
427 return ext;
431 row = MSI_QueryGetRecord( package->db, L"SELECT * FROM `Extension` WHERE `Extension` = '%s'", name );
432 if (!row)
433 return NULL;
435 ext = load_extension(package, row);
436 msiobj_release(&row->hdr);
437 return ext;
440 static UINT iterate_load_verb(MSIRECORD *row, LPVOID param)
442 MSIPACKAGE* package = param;
443 MSIVERB *verb;
444 LPCWSTR buffer;
445 MSIEXTENSION *extension;
447 buffer = MSI_RecordGetString(row,1);
448 extension = load_given_extension( package, buffer );
449 if (!extension)
451 ERR("Verb unable to find loaded extension %s\n", debugstr_w(buffer));
452 return ERROR_SUCCESS;
455 /* fill in the data */
457 verb = msi_alloc_zero( sizeof(MSIVERB) );
458 if (!verb)
459 return ERROR_OUTOFMEMORY;
461 verb->Verb = msi_dup_record_field(row,2);
462 TRACE("loading verb %s\n",debugstr_w(verb->Verb));
463 verb->Sequence = MSI_RecordGetInteger(row,3);
465 buffer = MSI_RecordGetString(row,4);
466 deformat_string(package,buffer,&verb->Command);
468 buffer = MSI_RecordGetString(row,5);
469 deformat_string(package,buffer,&verb->Argument);
471 /* associate the verb with the correct extension */
472 list_add_tail( &extension->verbs, &verb->entry );
474 return ERROR_SUCCESS;
477 static UINT iterate_all_classes(MSIRECORD *rec, LPVOID param)
479 MSICOMPONENT *comp;
480 LPCWSTR clsid;
481 LPCWSTR context;
482 LPCWSTR buffer;
483 MSIPACKAGE* package = param;
484 MSICLASS *cls;
485 BOOL match = FALSE;
487 clsid = MSI_RecordGetString(rec,1);
488 context = MSI_RecordGetString(rec,2);
489 buffer = MSI_RecordGetString(rec,3);
490 comp = msi_get_loaded_component(package, buffer);
492 LIST_FOR_EACH_ENTRY( cls, &package->classes, MSICLASS, entry )
494 if (wcsicmp( clsid, cls->clsid ))
495 continue;
496 if (wcscmp( context, cls->Context ))
497 continue;
498 if (comp == cls->Component)
500 match = TRUE;
501 break;
505 if (!match)
506 load_class(package, rec);
508 return ERROR_SUCCESS;
511 static UINT load_all_classes( MSIPACKAGE *package )
513 MSIQUERY *view;
514 UINT rc;
516 rc = MSI_DatabaseOpenViewW( package->db, L"SELECT * FROM `Class`", &view );
517 if (rc != ERROR_SUCCESS)
518 return ERROR_SUCCESS;
520 rc = MSI_IterateRecords(view, NULL, iterate_all_classes, package);
521 msiobj_release(&view->hdr);
522 return rc;
525 static UINT iterate_all_extensions(MSIRECORD *rec, LPVOID param)
527 MSICOMPONENT *comp;
528 LPCWSTR buffer;
529 LPCWSTR extension;
530 MSIPACKAGE* package = param;
531 BOOL match = FALSE;
532 MSIEXTENSION *ext;
534 extension = MSI_RecordGetString(rec,1);
535 buffer = MSI_RecordGetString(rec,2);
536 comp = msi_get_loaded_component(package, buffer);
538 LIST_FOR_EACH_ENTRY( ext, &package->extensions, MSIEXTENSION, entry )
540 if (wcsicmp(extension, ext->Extension))
541 continue;
542 if (comp == ext->Component)
544 match = TRUE;
545 break;
549 if (!match)
550 load_extension(package, rec);
552 return ERROR_SUCCESS;
555 static UINT load_all_extensions( MSIPACKAGE *package )
557 MSIQUERY *view;
558 UINT rc;
560 rc = MSI_DatabaseOpenViewW( package->db, L"SELECT * FROM `Extension`", &view );
561 if (rc != ERROR_SUCCESS)
562 return ERROR_SUCCESS;
564 rc = MSI_IterateRecords(view, NULL, iterate_all_extensions, package);
565 msiobj_release(&view->hdr);
566 return rc;
569 static UINT iterate_all_progids(MSIRECORD *rec, LPVOID param)
571 LPCWSTR buffer;
572 MSIPACKAGE* package = param;
574 buffer = MSI_RecordGetString(rec,1);
575 load_given_progid(package,buffer);
576 return ERROR_SUCCESS;
579 static UINT load_all_progids( MSIPACKAGE *package )
581 MSIQUERY *view;
582 UINT rc;
584 rc = MSI_DatabaseOpenViewW( package->db, L"SELECT `ProgId` FROM `ProgId`", &view );
585 if (rc != ERROR_SUCCESS)
586 return ERROR_SUCCESS;
588 rc = MSI_IterateRecords(view, NULL, iterate_all_progids, package);
589 msiobj_release(&view->hdr);
590 return rc;
593 static UINT load_all_verbs( MSIPACKAGE *package )
595 MSIQUERY *view;
596 UINT rc;
598 rc = MSI_DatabaseOpenViewW( package->db, L"SELECT * FROM `Verb`", &view );
599 if (rc != ERROR_SUCCESS)
600 return ERROR_SUCCESS;
602 rc = MSI_IterateRecords(view, NULL, iterate_load_verb, package);
603 msiobj_release(&view->hdr);
604 return rc;
607 static UINT iterate_all_mimes(MSIRECORD *rec, LPVOID param)
609 LPCWSTR buffer;
610 MSIPACKAGE* package = param;
612 buffer = MSI_RecordGetString(rec,1);
613 load_given_mime(package,buffer);
614 return ERROR_SUCCESS;
617 static UINT load_all_mimes( MSIPACKAGE *package )
619 MSIQUERY *view;
620 UINT rc;
622 rc = MSI_DatabaseOpenViewW( package->db, L"SELECT `ContentType` FROM `MIME`", &view );
623 if (rc != ERROR_SUCCESS)
624 return ERROR_SUCCESS;
626 rc = MSI_IterateRecords(view, NULL, iterate_all_mimes, package);
627 msiobj_release(&view->hdr);
628 return rc;
631 static UINT load_classes_and_such( MSIPACKAGE *package )
633 UINT r;
635 TRACE("Loading all the class info and related tables\n");
637 /* check if already loaded */
638 if (!list_empty( &package->classes ) ||
639 !list_empty( &package->mimes ) ||
640 !list_empty( &package->extensions ) ||
641 !list_empty( &package->progids )) return ERROR_SUCCESS;
643 r = load_all_classes( package );
644 if (r != ERROR_SUCCESS) return r;
646 r = load_all_extensions( package );
647 if (r != ERROR_SUCCESS) return r;
649 r = load_all_progids( package );
650 if (r != ERROR_SUCCESS) return r;
652 /* these loads must come after the other loads */
653 r = load_all_verbs( package );
654 if (r != ERROR_SUCCESS) return r;
656 return load_all_mimes( package );
659 static UINT register_appid(const MSIAPPID *appid, LPCWSTR app )
661 HKEY hkey2, hkey3;
663 RegCreateKeyW( HKEY_CLASSES_ROOT, L"AppID", &hkey2 );
664 RegCreateKeyW( hkey2, appid->AppID, &hkey3 );
665 RegCloseKey(hkey2);
666 msi_reg_set_val_str( hkey3, NULL, app );
668 if (appid->RemoteServerName)
669 msi_reg_set_val_str( hkey3, L"RemoteServerName", appid->RemoteServerName );
671 if (appid->LocalServer)
672 msi_reg_set_val_str( hkey3, L"LocalService", appid->LocalServer );
674 if (appid->ServiceParameters)
675 msi_reg_set_val_str( hkey3, L"ServiceParameters", appid->ServiceParameters );
677 if (appid->DllSurrogate)
678 msi_reg_set_val_str( hkey3, L"DllSurrogate", appid->DllSurrogate );
680 if (appid->ActivateAtStorage)
681 msi_reg_set_val_str( hkey3, L"ActivateAtStorage", L"Y" );
683 if (appid->RunAsInteractiveUser)
684 msi_reg_set_val_str( hkey3, L"RunAs", L"Interactive User" );
686 RegCloseKey(hkey3);
687 return ERROR_SUCCESS;
690 UINT ACTION_RegisterClassInfo(MSIPACKAGE *package)
692 REGSAM access = KEY_ALL_ACCESS;
693 MSIRECORD *uirow;
694 HKEY hkey, hkey2, hkey3;
695 MSICLASS *cls;
696 UINT r;
698 if (package->script == SCRIPT_NONE)
699 return msi_schedule_action( package, SCRIPT_INSTALL, L"RegisterClassInfo" );
701 r = load_classes_and_such( package );
702 if (r != ERROR_SUCCESS)
703 return r;
705 if (package->platform == PLATFORM_INTEL)
706 access |= KEY_WOW64_32KEY;
707 else
708 access |= KEY_WOW64_64KEY;
710 if (RegCreateKeyExW( HKEY_CLASSES_ROOT, L"CLSID", 0, NULL, 0, access, NULL, &hkey, NULL ))
711 return ERROR_FUNCTION_FAILED;
713 LIST_FOR_EACH_ENTRY( cls, &package->classes, MSICLASS, entry )
715 MSICOMPONENT *comp;
716 MSIFILE *file;
717 DWORD size;
718 LPWSTR argument;
719 MSIFEATURE *feature;
721 comp = cls->Component;
722 if ( !comp )
723 continue;
725 if (!comp->Enabled)
727 TRACE("component is disabled\n");
728 continue;
731 feature = cls->Feature;
732 if (!feature)
733 continue;
735 feature->Action = msi_get_feature_action( package, feature );
736 if (feature->Action != INSTALLSTATE_LOCAL &&
737 feature->Action != INSTALLSTATE_ADVERTISED )
739 TRACE("feature %s not scheduled for installation, skipping registration of class %s\n",
740 debugstr_w(feature->Feature), debugstr_w(cls->clsid));
741 continue;
744 if (!comp->KeyPath || !(file = msi_get_loaded_file( package, comp->KeyPath )))
746 TRACE("COM server not provided, skipping class %s\n", debugstr_w(cls->clsid));
747 continue;
749 TRACE("Registering class %s (%p)\n", debugstr_w(cls->clsid), cls);
751 cls->action = INSTALLSTATE_LOCAL;
753 RegCreateKeyW( hkey, cls->clsid, &hkey2 );
755 if (cls->Description)
756 msi_reg_set_val_str( hkey2, NULL, cls->Description );
758 RegCreateKeyW( hkey2, cls->Context, &hkey3 );
761 * FIXME: Implement install on demand (advertised components).
763 * ole32.dll should call msi.MsiProvideComponentFromDescriptor()
764 * when it needs an InProcServer that doesn't exist.
765 * The component advertise string should be in the "InProcServer" value.
767 size = lstrlenW( file->TargetPath )+1;
768 if (cls->Argument)
769 size += lstrlenW(cls->Argument)+1;
771 argument = msi_alloc( size * sizeof(WCHAR) );
772 lstrcpyW( argument, file->TargetPath );
774 if (cls->Argument)
776 lstrcatW( argument, L" " );
777 lstrcatW( argument, cls->Argument );
780 msi_reg_set_val_str( hkey3, NULL, argument );
781 msi_free(argument);
783 RegCloseKey(hkey3);
785 if (cls->ProgID || cls->ProgIDText)
787 LPCWSTR progid;
789 if (cls->ProgID)
790 progid = cls->ProgID->ProgID;
791 else
792 progid = cls->ProgIDText;
794 msi_reg_set_subkey_val( hkey2, L"ProgID", NULL, progid );
796 if (cls->ProgID && cls->ProgID->VersionInd)
798 msi_reg_set_subkey_val( hkey2, L"VersionIndependentProgID", NULL,
799 cls->ProgID->VersionInd->ProgID );
803 if (cls->AppID)
805 MSIAPPID *appid = cls->AppID;
806 msi_reg_set_val_str( hkey2, L"AppID", appid->AppID );
807 register_appid( appid, cls->Description );
810 if (cls->IconPath)
811 msi_reg_set_subkey_val( hkey2, L"DefaultIcon", NULL, cls->IconPath );
813 if (cls->DefInprocHandler)
814 msi_reg_set_subkey_val( hkey2, L"InprocHandler", NULL, cls->DefInprocHandler );
816 if (cls->DefInprocHandler32)
817 msi_reg_set_subkey_val( hkey2, L"InprocHandler32", NULL, cls->DefInprocHandler32 );
818 RegCloseKey(hkey2);
820 /* if there is a FileTypeMask, register the FileType */
821 if (cls->FileTypeMask)
823 LPWSTR ptr, ptr2;
824 LPWSTR keyname;
825 INT index = 0;
826 ptr = cls->FileTypeMask;
827 while (ptr && *ptr)
829 ptr2 = wcschr(ptr,';');
830 if (ptr2)
831 *ptr2 = 0;
832 keyname = msi_alloc( (lstrlenW(L"FileType\\%s\\%d") + lstrlenW(cls->clsid) + 4) * sizeof(WCHAR));
833 swprintf( keyname, lstrlenW(L"FileType\\%s\\%d") + lstrlenW(cls->clsid) + 4,
834 L"FileType\\%s\\%d", cls->clsid, index );
836 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, keyname, NULL, ptr );
837 msi_free(keyname);
839 if (ptr2)
840 ptr = ptr2+1;
841 else
842 ptr = NULL;
844 index ++;
848 uirow = MSI_CreateRecord(1);
849 MSI_RecordSetStringW( uirow, 1, cls->clsid );
850 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
851 msiobj_release(&uirow->hdr);
853 RegCloseKey(hkey);
854 return ERROR_SUCCESS;
857 UINT ACTION_UnregisterClassInfo( MSIPACKAGE *package )
859 REGSAM access = KEY_ALL_ACCESS;
860 MSIRECORD *uirow;
861 MSICLASS *cls;
862 HKEY hkey, hkey2;
863 UINT r;
865 if (package->script == SCRIPT_NONE)
866 return msi_schedule_action( package, SCRIPT_INSTALL, L"UnregisterClassInfo" );
868 r = load_classes_and_such( package );
869 if (r != ERROR_SUCCESS)
870 return r;
872 if (package->platform == PLATFORM_INTEL)
873 access |= KEY_WOW64_32KEY;
874 else
875 access |= KEY_WOW64_64KEY;
877 if (RegCreateKeyExW( HKEY_CLASSES_ROOT, L"CLSID", 0, NULL, 0, access, NULL, &hkey, NULL ))
878 return ERROR_FUNCTION_FAILED;
880 LIST_FOR_EACH_ENTRY( cls, &package->classes, MSICLASS, entry )
882 MSIFEATURE *feature;
883 MSICOMPONENT *comp;
884 LPWSTR filetype;
885 LONG res;
887 comp = cls->Component;
888 if (!comp)
889 continue;
891 if (!comp->Enabled)
893 TRACE("component is disabled\n");
894 continue;
897 feature = cls->Feature;
898 if (!feature)
899 continue;
901 feature->Action = msi_get_feature_action( package, feature );
902 if (feature->Action != INSTALLSTATE_ABSENT)
904 TRACE("feature %s not scheduled for removal, skipping unregistration of class %s\n",
905 debugstr_w(feature->Feature), debugstr_w(cls->clsid));
906 continue;
908 TRACE("Unregistering class %s (%p)\n", debugstr_w(cls->clsid), cls);
910 cls->action = INSTALLSTATE_ABSENT;
912 res = RegDeleteTreeW( hkey, cls->clsid );
913 if (res != ERROR_SUCCESS)
914 WARN("Failed to delete class key %d\n", res);
916 if (cls->AppID)
918 res = RegOpenKeyW( HKEY_CLASSES_ROOT, L"AppID", &hkey2 );
919 if (res == ERROR_SUCCESS)
921 res = RegDeleteKeyW( hkey2, cls->AppID->AppID );
922 if (res != ERROR_SUCCESS)
923 WARN("Failed to delete appid key %d\n", res);
924 RegCloseKey( hkey2 );
927 if (cls->FileTypeMask)
929 filetype = msi_alloc( (lstrlenW( L"FileType\\" ) + lstrlenW( cls->clsid ) + 1) * sizeof(WCHAR) );
930 if (filetype)
932 lstrcpyW( filetype, L"FileType\\" );
933 lstrcatW( filetype, cls->clsid );
934 res = RegDeleteTreeW( HKEY_CLASSES_ROOT, filetype );
935 msi_free( filetype );
937 if (res != ERROR_SUCCESS)
938 WARN("Failed to delete file type %d\n", res);
942 uirow = MSI_CreateRecord( 1 );
943 MSI_RecordSetStringW( uirow, 1, cls->clsid );
944 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
945 msiobj_release( &uirow->hdr );
947 RegCloseKey( hkey );
948 return ERROR_SUCCESS;
951 static LPCWSTR get_clsid_of_progid( const MSIPROGID *progid )
953 while (progid)
955 if (progid->Class)
956 return progid->Class->clsid;
957 if (progid->Parent == progid)
958 break;
959 progid = progid->Parent;
961 return NULL;
964 static UINT register_progid( const MSIPROGID* progid )
966 HKEY hkey = 0;
967 UINT rc;
969 rc = RegCreateKeyW( HKEY_CLASSES_ROOT, progid->ProgID, &hkey );
970 if (rc == ERROR_SUCCESS)
972 LPCWSTR clsid = get_clsid_of_progid( progid );
974 if (clsid)
975 msi_reg_set_subkey_val( hkey, L"CLSID", NULL, clsid );
976 else
977 TRACE("%s has no class\n", debugstr_w( progid->ProgID ) );
979 if (progid->Description)
980 msi_reg_set_val_str( hkey, NULL, progid->Description );
982 if (progid->IconPath)
983 msi_reg_set_subkey_val( hkey, L"DefaultIcon", NULL, progid->IconPath );
985 /* write out the current version */
986 if (progid->CurVer)
987 msi_reg_set_subkey_val( hkey, L"CurVer", NULL, progid->CurVer->ProgID );
989 RegCloseKey(hkey);
991 else
992 ERR("failed to create key %s\n", debugstr_w( progid->ProgID ) );
994 return rc;
997 static const MSICLASS *get_progid_class( const MSIPROGID *progid )
999 while (progid)
1001 if (progid->Parent) progid = progid->Parent;
1002 if (progid->Class) return progid->Class;
1003 if (!progid->Parent || progid->Parent == progid) break;
1005 return NULL;
1008 static BOOL has_class_installed( const MSIPROGID *progid )
1010 const MSICLASS *class = get_progid_class( progid );
1011 if (!class || !class->ProgID) return FALSE;
1012 return (class->action == INSTALLSTATE_LOCAL);
1015 static BOOL has_one_extension_installed( const MSIPACKAGE *package, const MSIPROGID *progid )
1017 const MSIEXTENSION *extension;
1018 LIST_FOR_EACH_ENTRY( extension, &package->extensions, MSIEXTENSION, entry )
1020 if (extension->ProgID == progid && !list_empty( &extension->verbs ) &&
1021 extension->action == INSTALLSTATE_LOCAL) return TRUE;
1023 return FALSE;
1026 UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package)
1028 MSIPROGID *progid;
1029 MSIRECORD *uirow;
1030 UINT r;
1032 if (package->script == SCRIPT_NONE)
1033 return msi_schedule_action( package, SCRIPT_INSTALL, L"RegisterProgIdInfo" );
1035 r = load_classes_and_such( package );
1036 if (r != ERROR_SUCCESS)
1037 return r;
1039 LIST_FOR_EACH_ENTRY( progid, &package->progids, MSIPROGID, entry )
1041 if (!has_class_installed( progid ) && !has_one_extension_installed( package, progid ))
1043 TRACE("progid %s not scheduled to be installed\n", debugstr_w(progid->ProgID));
1044 continue;
1046 TRACE("Registering progid %s\n", debugstr_w(progid->ProgID));
1048 register_progid( progid );
1050 uirow = MSI_CreateRecord( 1 );
1051 MSI_RecordSetStringW( uirow, 1, progid->ProgID );
1052 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
1053 msiobj_release( &uirow->hdr );
1055 return ERROR_SUCCESS;
1058 static BOOL has_class_removed( const MSIPROGID *progid )
1060 const MSICLASS *class = get_progid_class( progid );
1061 if (!class || !class->ProgID) return FALSE;
1062 return (class->action == INSTALLSTATE_ABSENT);
1065 static BOOL has_extensions( const MSIPACKAGE *package, const MSIPROGID *progid )
1067 const MSIEXTENSION *extension;
1068 LIST_FOR_EACH_ENTRY( extension, &package->extensions, MSIEXTENSION, entry )
1070 if (extension->ProgID == progid && !list_empty( &extension->verbs )) return TRUE;
1072 return FALSE;
1075 static BOOL has_all_extensions_removed( const MSIPACKAGE *package, const MSIPROGID *progid )
1077 BOOL ret = FALSE;
1078 const MSIEXTENSION *extension;
1079 LIST_FOR_EACH_ENTRY( extension, &package->extensions, MSIEXTENSION, entry )
1081 if (extension->ProgID == progid && !list_empty( &extension->verbs ) &&
1082 extension->action == INSTALLSTATE_ABSENT) ret = TRUE;
1083 else ret = FALSE;
1085 return ret;
1088 UINT ACTION_UnregisterProgIdInfo( MSIPACKAGE *package )
1090 MSIPROGID *progid;
1091 MSIRECORD *uirow;
1092 LONG res;
1093 UINT r;
1095 if (package->script == SCRIPT_NONE)
1096 return msi_schedule_action( package, SCRIPT_INSTALL, L"UnregisterProgIdInfo" );
1098 r = load_classes_and_such( package );
1099 if (r != ERROR_SUCCESS)
1100 return r;
1102 LIST_FOR_EACH_ENTRY( progid, &package->progids, MSIPROGID, entry )
1104 if (!has_class_removed( progid ) ||
1105 (has_extensions( package, progid ) && !has_all_extensions_removed( package, progid )))
1107 TRACE("progid %s not scheduled to be removed\n", debugstr_w(progid->ProgID));
1108 continue;
1110 TRACE("Unregistering progid %s\n", debugstr_w(progid->ProgID));
1112 res = RegDeleteTreeW( HKEY_CLASSES_ROOT, progid->ProgID );
1113 if (res != ERROR_SUCCESS)
1114 TRACE("Failed to delete progid key %d\n", res);
1116 uirow = MSI_CreateRecord( 1 );
1117 MSI_RecordSetStringW( uirow, 1, progid->ProgID );
1118 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
1119 msiobj_release( &uirow->hdr );
1121 return ERROR_SUCCESS;
1124 static UINT register_verb(MSIPACKAGE *package, LPCWSTR progid,
1125 MSICOMPONENT* component, const MSIEXTENSION* extension,
1126 MSIVERB* verb, INT* Sequence )
1128 LPWSTR keyname;
1129 HKEY key;
1130 LPWSTR command;
1131 DWORD size;
1132 LPWSTR advertise;
1134 keyname = msi_build_directory_name(4, progid, L"shell", verb->Verb, L"command");
1136 TRACE("Making Key %s\n",debugstr_w(keyname));
1137 RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key);
1138 size = lstrlenW(component->FullKeypath);
1139 if (verb->Argument)
1140 size += lstrlenW(verb->Argument);
1141 size += 4;
1143 command = msi_alloc(size * sizeof (WCHAR));
1144 if (verb->Argument)
1145 swprintf(command, size, L"\"%s\" %s", component->FullKeypath, verb->Argument);
1146 else
1147 swprintf(command, size, L"\"%s\"", component->FullKeypath);
1149 msi_reg_set_val_str( key, NULL, command );
1150 msi_free(command);
1152 advertise = msi_create_component_advertise_string(package, component,
1153 extension->Feature->Feature);
1154 size = lstrlenW(advertise);
1156 if (verb->Argument)
1157 size += lstrlenW(verb->Argument);
1158 size += 4;
1160 command = msi_alloc_zero(size * sizeof (WCHAR));
1162 lstrcpyW(command,advertise);
1163 if (verb->Argument)
1165 lstrcatW(command, L" ");
1166 lstrcatW(command, verb->Argument);
1169 msi_reg_set_val_multi_str( key, L"command", command );
1171 RegCloseKey(key);
1172 msi_free(keyname);
1173 msi_free(advertise);
1174 msi_free(command);
1176 if (verb->Command)
1178 keyname = msi_build_directory_name( 3, progid, L"shell", verb->Verb );
1179 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, keyname, NULL, verb->Command );
1180 msi_free(keyname);
1183 if (verb->Sequence != MSI_NULL_INTEGER)
1185 if (*Sequence == MSI_NULL_INTEGER || verb->Sequence < *Sequence)
1187 *Sequence = verb->Sequence;
1188 keyname = msi_build_directory_name( 2, progid, L"shell" );
1189 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, keyname, NULL, verb->Verb );
1190 msi_free(keyname);
1193 return ERROR_SUCCESS;
1196 UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package)
1198 HKEY hkey = NULL;
1199 MSIEXTENSION *ext;
1200 MSIRECORD *uirow;
1201 BOOL install_on_demand = TRUE;
1202 LONG res;
1203 UINT r;
1205 if (package->script == SCRIPT_NONE)
1206 return msi_schedule_action( package, SCRIPT_INSTALL, L"RegisterExtensionInfo" );
1208 r = load_classes_and_such( package );
1209 if (r != ERROR_SUCCESS)
1210 return r;
1212 /* We need to set install_on_demand based on if the shell handles advertised
1213 * shortcuts and the like. Because Mike McCormack is working on this i am
1214 * going to default to TRUE
1217 LIST_FOR_EACH_ENTRY( ext, &package->extensions, MSIEXTENSION, entry )
1219 LPWSTR extension;
1220 MSIFEATURE *feature;
1222 if (!ext->Component)
1223 continue;
1225 if (!ext->Component->Enabled)
1227 TRACE("component is disabled\n");
1228 continue;
1231 feature = ext->Feature;
1232 if (!feature)
1233 continue;
1236 * yes. MSDN says that these are based on _Feature_ not on
1237 * Component. So verify the feature is to be installed
1239 feature->Action = msi_get_feature_action( package, feature );
1240 if (feature->Action != INSTALLSTATE_LOCAL &&
1241 !(install_on_demand && feature->Action == INSTALLSTATE_ADVERTISED))
1243 TRACE("feature %s not scheduled for installation, skipping registration of extension %s\n",
1244 debugstr_w(feature->Feature), debugstr_w(ext->Extension));
1245 continue;
1247 TRACE("Registering extension %s (%p)\n", debugstr_w(ext->Extension), ext);
1249 ext->action = INSTALLSTATE_LOCAL;
1251 extension = msi_alloc( (lstrlenW( ext->Extension ) + 2) * sizeof(WCHAR) );
1252 if (extension)
1254 extension[0] = '.';
1255 lstrcpyW( extension + 1, ext->Extension );
1256 res = RegCreateKeyW( HKEY_CLASSES_ROOT, extension, &hkey );
1257 msi_free( extension );
1258 if (res != ERROR_SUCCESS)
1259 WARN("Failed to create extension key %d\n", res);
1262 if (ext->Mime)
1263 msi_reg_set_val_str( hkey, L"Content Type", ext->Mime->ContentType );
1265 if (ext->ProgID || ext->ProgIDText)
1267 HKEY hkey2;
1268 LPWSTR newkey;
1269 LPCWSTR progid;
1270 MSIVERB *verb;
1271 INT Sequence = MSI_NULL_INTEGER;
1273 if (ext->ProgID)
1274 progid = ext->ProgID->ProgID;
1275 else
1276 progid = ext->ProgIDText;
1278 msi_reg_set_val_str( hkey, NULL, progid );
1280 newkey = msi_alloc( (lstrlenW(progid) + lstrlenW(L"\\ShellNew") + 1) * sizeof(WCHAR));
1282 lstrcpyW(newkey, progid);
1283 lstrcatW(newkey, L"\\ShellNew");
1284 RegCreateKeyW(hkey, newkey, &hkey2);
1285 RegCloseKey(hkey2);
1287 msi_free(newkey);
1289 /* do all the verbs */
1290 LIST_FOR_EACH_ENTRY( verb, &ext->verbs, MSIVERB, entry )
1292 register_verb( package, progid, ext->Component,
1293 ext, verb, &Sequence);
1297 RegCloseKey(hkey);
1299 uirow = MSI_CreateRecord(1);
1300 MSI_RecordSetStringW( uirow, 1, ext->Extension );
1301 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
1302 msiobj_release(&uirow->hdr);
1304 return ERROR_SUCCESS;
1307 UINT ACTION_UnregisterExtensionInfo( MSIPACKAGE *package )
1309 MSIEXTENSION *ext;
1310 MSIRECORD *uirow;
1311 LONG res;
1312 UINT r;
1314 if (package->script == SCRIPT_NONE)
1315 return msi_schedule_action( package, SCRIPT_INSTALL, L"UnregisterExtensionInfo" );
1317 r = load_classes_and_such( package );
1318 if (r != ERROR_SUCCESS)
1319 return r;
1321 LIST_FOR_EACH_ENTRY( ext, &package->extensions, MSIEXTENSION, entry )
1323 LPWSTR extension;
1324 MSIFEATURE *feature;
1326 if (!ext->Component)
1327 continue;
1329 if (!ext->Component->Enabled)
1331 TRACE("component is disabled\n");
1332 continue;
1335 feature = ext->Feature;
1336 if (!feature)
1337 continue;
1339 feature->Action = msi_get_feature_action( package, feature );
1340 if (feature->Action != INSTALLSTATE_ABSENT)
1342 TRACE("feature %s not scheduled for removal, skipping unregistration of extension %s\n",
1343 debugstr_w(feature->Feature), debugstr_w(ext->Extension));
1344 continue;
1346 TRACE("Unregistering extension %s\n", debugstr_w(ext->Extension));
1348 ext->action = INSTALLSTATE_ABSENT;
1350 extension = msi_alloc( (lstrlenW( ext->Extension ) + 2) * sizeof(WCHAR) );
1351 if (extension)
1353 extension[0] = '.';
1354 lstrcpyW( extension + 1, ext->Extension );
1355 res = RegDeleteTreeW( HKEY_CLASSES_ROOT, extension );
1356 msi_free( extension );
1357 if (res != ERROR_SUCCESS)
1358 WARN("Failed to delete extension key %d\n", res);
1361 if (ext->ProgID || ext->ProgIDText)
1363 LPCWSTR progid;
1364 LPWSTR progid_shell;
1366 if (ext->ProgID)
1367 progid = ext->ProgID->ProgID;
1368 else
1369 progid = ext->ProgIDText;
1371 progid_shell = msi_alloc( (lstrlenW( progid ) + lstrlenW( L"\\shell" ) + 1) * sizeof(WCHAR) );
1372 if (progid_shell)
1374 lstrcpyW( progid_shell, progid );
1375 lstrcatW( progid_shell, L"\\shell" );
1376 res = RegDeleteTreeW( HKEY_CLASSES_ROOT, progid_shell );
1377 msi_free( progid_shell );
1378 if (res != ERROR_SUCCESS)
1379 WARN("Failed to delete shell key %d\n", res);
1380 RegDeleteKeyW( HKEY_CLASSES_ROOT, progid );
1384 uirow = MSI_CreateRecord( 1 );
1385 MSI_RecordSetStringW( uirow, 1, ext->Extension );
1386 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
1387 msiobj_release( &uirow->hdr );
1389 return ERROR_SUCCESS;
1392 UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package)
1394 MSIRECORD *uirow;
1395 MSIMIME *mt;
1396 UINT r;
1398 if (package->script == SCRIPT_NONE)
1399 return msi_schedule_action( package, SCRIPT_INSTALL, L"RegisterMIMEInfo" );
1401 r = load_classes_and_such( package );
1402 if (r != ERROR_SUCCESS)
1403 return r;
1405 LIST_FOR_EACH_ENTRY( mt, &package->mimes, MSIMIME, entry )
1407 LPWSTR extension = NULL, key;
1410 * check if the MIME is to be installed. Either as requested by an
1411 * extension or Class
1413 if ((!mt->Class || mt->Class->action != INSTALLSTATE_LOCAL) &&
1414 (!mt->Extension || mt->Extension->action != INSTALLSTATE_LOCAL))
1416 TRACE("MIME %s not scheduled to be installed\n", debugstr_w(mt->ContentType));
1417 continue;
1420 TRACE("Registering MIME type %s\n", debugstr_w(mt->ContentType));
1422 if (mt->Extension) extension = msi_alloc( (lstrlenW( mt->Extension->Extension ) + 2) * sizeof(WCHAR) );
1423 key = msi_alloc( (lstrlenW( mt->ContentType ) +
1424 lstrlenW( L"MIME\\Database\\Content Type\\" ) + 1) * sizeof(WCHAR) );
1426 if (extension && key)
1428 extension[0] = '.';
1429 lstrcpyW( extension + 1, mt->Extension->Extension );
1431 lstrcpyW( key, L"MIME\\Database\\Content Type\\" );
1432 lstrcatW( key, mt->ContentType );
1433 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, key, L"Extension", extension );
1435 if (mt->clsid)
1436 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, key, L"CLSID", mt->clsid );
1438 msi_free( extension );
1439 msi_free( key );
1441 uirow = MSI_CreateRecord( 2 );
1442 MSI_RecordSetStringW( uirow, 1, mt->ContentType );
1443 MSI_RecordSetStringW( uirow, 2, mt->suffix );
1444 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
1445 msiobj_release( &uirow->hdr );
1447 return ERROR_SUCCESS;
1450 UINT ACTION_UnregisterMIMEInfo( MSIPACKAGE *package )
1452 MSIRECORD *uirow;
1453 MSIMIME *mime;
1454 UINT r;
1456 if (package->script == SCRIPT_NONE)
1457 return msi_schedule_action( package, SCRIPT_INSTALL, L"UnregisterMIMEInfo" );
1459 r = load_classes_and_such( package );
1460 if (r != ERROR_SUCCESS)
1461 return r;
1463 LIST_FOR_EACH_ENTRY( mime, &package->mimes, MSIMIME, entry )
1465 LONG res;
1466 LPWSTR mime_key;
1468 if ((!mime->Class || mime->Class->action != INSTALLSTATE_ABSENT) &&
1469 (!mime->Extension || mime->Extension->action != INSTALLSTATE_ABSENT))
1471 TRACE("MIME %s not scheduled to be removed\n", debugstr_w(mime->ContentType));
1472 continue;
1475 TRACE("Unregistering MIME type %s\n", debugstr_w(mime->ContentType));
1477 mime_key = msi_alloc( (lstrlenW( L"MIME\\Database\\Content Type\\" ) +
1478 lstrlenW( mime->ContentType ) + 1) * sizeof(WCHAR) );
1479 if (mime_key)
1481 lstrcpyW( mime_key, L"MIME\\Database\\Content Type\\" );
1482 lstrcatW( mime_key, mime->ContentType );
1483 res = RegDeleteKeyW( HKEY_CLASSES_ROOT, mime_key );
1484 if (res != ERROR_SUCCESS)
1485 WARN("Failed to delete MIME key %d\n", res);
1486 msi_free( mime_key );
1489 uirow = MSI_CreateRecord( 2 );
1490 MSI_RecordSetStringW( uirow, 1, mime->ContentType );
1491 MSI_RecordSetStringW( uirow, 2, mime->suffix );
1492 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
1493 msiobj_release( &uirow->hdr );
1495 return ERROR_SUCCESS;