Release 1.3.7.
[wine/gsoc-2012-control.git] / dlls / msi / classes.c
blob9305e043ea9ca470fa4321c808b41ccbcb43d293
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"
42 #include "wine/unicode.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(msi);
46 static MSIAPPID *load_appid( MSIPACKAGE* package, MSIRECORD *row )
48 LPCWSTR buffer;
49 MSIAPPID *appid;
51 /* fill in the data */
53 appid = msi_alloc_zero( sizeof(MSIAPPID) );
54 if (!appid)
55 return NULL;
57 appid->AppID = msi_dup_record_field( row, 1 );
58 TRACE("loading appid %s\n", debugstr_w( appid->AppID ));
60 buffer = MSI_RecordGetString(row,2);
61 deformat_string( package, buffer, &appid->RemoteServerName );
63 appid->LocalServer = msi_dup_record_field(row,3);
64 appid->ServiceParameters = msi_dup_record_field(row,4);
65 appid->DllSurrogate = msi_dup_record_field(row,5);
67 appid->ActivateAtStorage = !MSI_RecordIsNull(row,6);
68 appid->RunAsInteractiveUser = !MSI_RecordIsNull(row,7);
70 list_add_tail( &package->appids, &appid->entry );
72 return appid;
75 static MSIAPPID *load_given_appid( MSIPACKAGE *package, LPCWSTR name )
77 MSIRECORD *row;
78 MSIAPPID *appid;
79 static const WCHAR ExecSeqQuery[] =
80 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
81 '`','A','p','p','I','d','`',' ','W','H','E','R','E',' ',
82 '`','A','p','p','I','d','`',' ','=',' ','\'','%','s','\'',0};
84 if (!name)
85 return NULL;
87 /* check for appids already loaded */
88 LIST_FOR_EACH_ENTRY( appid, &package->appids, MSIAPPID, entry )
90 if (!strcmpiW( appid->AppID, name ))
92 TRACE("found appid %s %p\n", debugstr_w(name), appid);
93 return appid;
97 row = MSI_QueryGetRecord(package->db, ExecSeqQuery, name);
98 if (!row)
99 return NULL;
101 appid = load_appid(package, row);
102 msiobj_release(&row->hdr);
104 return appid;
107 static MSIPROGID *load_given_progid(MSIPACKAGE *package, LPCWSTR progid);
108 static MSICLASS *load_given_class( MSIPACKAGE *package, LPCWSTR classid );
110 static MSIPROGID *load_progid( MSIPACKAGE* package, MSIRECORD *row )
112 MSIPROGID *progid;
113 LPCWSTR buffer;
115 /* fill in the data */
117 progid = msi_alloc_zero( sizeof(MSIPROGID) );
118 if (!progid)
119 return NULL;
121 list_add_tail( &package->progids, &progid->entry );
123 progid->ProgID = msi_dup_record_field(row,1);
124 TRACE("loading progid %s\n",debugstr_w(progid->ProgID));
126 buffer = MSI_RecordGetString(row,2);
127 progid->Parent = load_given_progid(package,buffer);
128 if (progid->Parent == NULL && buffer)
129 FIXME("Unknown parent ProgID %s\n",debugstr_w(buffer));
131 buffer = MSI_RecordGetString(row,3);
132 progid->Class = load_given_class(package,buffer);
133 if (progid->Class == NULL && buffer)
134 FIXME("Unknown class %s\n",debugstr_w(buffer));
136 progid->Description = msi_dup_record_field(row,4);
138 if (!MSI_RecordIsNull(row,6))
140 INT icon_index = MSI_RecordGetInteger(row,6);
141 LPCWSTR FileName = MSI_RecordGetString(row,5);
142 LPWSTR FilePath;
143 static const WCHAR fmt[] = {'%','s',',','%','i',0};
145 FilePath = build_icon_path(package,FileName);
147 progid->IconPath = msi_alloc( (strlenW(FilePath)+10)* sizeof(WCHAR) );
149 sprintfW(progid->IconPath,fmt,FilePath,icon_index);
151 msi_free(FilePath);
153 else
155 buffer = MSI_RecordGetString(row,5);
156 if (buffer)
157 progid->IconPath = build_icon_path(package,buffer);
160 progid->CurVer = NULL;
161 progid->VersionInd = NULL;
163 /* if we have a parent then we may be that parents CurVer */
164 if (progid->Parent && progid->Parent != progid)
166 MSIPROGID *parent = progid->Parent;
168 while (parent->Parent && parent->Parent != parent)
169 parent = parent->Parent;
171 /* FIXME: need to determine if we are really the CurVer */
173 progid->CurVer = parent;
174 parent->VersionInd = progid;
177 return progid;
180 static MSIPROGID *load_given_progid(MSIPACKAGE *package, LPCWSTR name)
182 MSIPROGID *progid;
183 MSIRECORD *row;
184 static const WCHAR ExecSeqQuery[] =
185 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
186 '`','P','r','o','g','I','d','`',' ','W','H','E','R','E',' ',
187 '`','P','r','o','g','I','d','`',' ','=',' ','\'','%','s','\'',0};
189 if (!name)
190 return NULL;
192 /* check for progids already loaded */
193 LIST_FOR_EACH_ENTRY( progid, &package->progids, MSIPROGID, entry )
195 if (!strcmpiW( progid->ProgID, name ))
197 TRACE("found progid %s (%p)\n",debugstr_w(name), progid );
198 return progid;
202 row = MSI_QueryGetRecord( package->db, ExecSeqQuery, name );
203 if (!row)
204 return NULL;
206 progid = load_progid(package, row);
207 msiobj_release(&row->hdr);
209 return progid;
212 static MSICLASS *load_class( MSIPACKAGE* package, MSIRECORD *row )
214 MSICLASS *cls;
215 DWORD i;
216 LPCWSTR buffer;
218 /* fill in the data */
220 cls = msi_alloc_zero( sizeof(MSICLASS) );
221 if (!cls)
222 return NULL;
224 list_add_tail( &package->classes, &cls->entry );
226 cls->clsid = msi_dup_record_field( row, 1 );
227 TRACE("loading class %s\n",debugstr_w(cls->clsid));
228 cls->Context = msi_dup_record_field( row, 2 );
229 buffer = MSI_RecordGetString(row,3);
230 cls->Component = get_loaded_component(package, buffer);
232 cls->ProgIDText = msi_dup_record_field(row,4);
233 cls->ProgID = load_given_progid(package, cls->ProgIDText);
235 cls->Description = msi_dup_record_field(row,5);
237 buffer = MSI_RecordGetString(row,6);
238 if (buffer)
239 cls->AppID = load_given_appid(package, buffer);
241 cls->FileTypeMask = msi_dup_record_field(row,7);
243 if (!MSI_RecordIsNull(row,9))
246 INT icon_index = MSI_RecordGetInteger(row,9);
247 LPCWSTR FileName = MSI_RecordGetString(row,8);
248 LPWSTR FilePath;
249 static const WCHAR fmt[] = {'%','s',',','%','i',0};
251 FilePath = build_icon_path(package,FileName);
253 cls->IconPath = msi_alloc( (strlenW(FilePath)+5)* sizeof(WCHAR) );
255 sprintfW(cls->IconPath,fmt,FilePath,icon_index);
257 msi_free(FilePath);
259 else
261 buffer = MSI_RecordGetString(row,8);
262 if (buffer)
263 cls->IconPath = build_icon_path(package,buffer);
266 if (!MSI_RecordIsNull(row,10))
268 i = MSI_RecordGetInteger(row,10);
269 if (i != MSI_NULL_INTEGER && i > 0 && i < 4)
271 static const WCHAR ole2[] = {'o','l','e','2','.','d','l','l',0};
272 static const WCHAR ole32[] = {'o','l','e','3','2','.','d','l','l',0};
274 switch(i)
276 case 1:
277 cls->DefInprocHandler = strdupW(ole2);
278 break;
279 case 2:
280 cls->DefInprocHandler32 = strdupW(ole32);
281 break;
282 case 3:
283 cls->DefInprocHandler = strdupW(ole2);
284 cls->DefInprocHandler32 = strdupW(ole32);
285 break;
288 else
290 cls->DefInprocHandler32 = msi_dup_record_field( row, 10);
291 reduce_to_longfilename(cls->DefInprocHandler32);
294 buffer = MSI_RecordGetString(row,11);
295 deformat_string(package,buffer,&cls->Argument);
297 buffer = MSI_RecordGetString(row,12);
298 cls->Feature = get_loaded_feature(package,buffer);
300 cls->Attributes = MSI_RecordGetInteger(row,13);
302 return cls;
306 * the Class table has 3 primary keys. Generally it is only
307 * referenced through the first CLSID key. However when loading
308 * all of the classes we need to make sure we do not ignore rows
309 * with other Context and ComponentIndexs
311 static MSICLASS *load_given_class(MSIPACKAGE *package, LPCWSTR classid)
313 MSICLASS *cls;
314 MSIRECORD *row;
315 static const WCHAR ExecSeqQuery[] =
316 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
317 '`','C','l','a','s','s','`',' ','W','H','E','R','E',' ',
318 '`','C','L','S','I','D','`',' ','=',' ','\'','%','s','\'',0};
320 if (!classid)
321 return NULL;
323 /* check for classes already loaded */
324 LIST_FOR_EACH_ENTRY( cls, &package->classes, MSICLASS, entry )
326 if (!strcmpiW( cls->clsid, classid ))
328 TRACE("found class %s (%p)\n",debugstr_w(classid), cls);
329 return cls;
333 row = MSI_QueryGetRecord(package->db, ExecSeqQuery, classid);
334 if (!row)
335 return NULL;
337 cls = load_class(package, row);
338 msiobj_release(&row->hdr);
340 return cls;
343 static MSIEXTENSION *load_given_extension( MSIPACKAGE *package, LPCWSTR extension );
345 static MSIMIME *load_mime( MSIPACKAGE* package, MSIRECORD *row )
347 LPCWSTR extension;
348 MSIMIME *mt;
350 /* fill in the data */
352 mt = msi_alloc_zero( sizeof(MSIMIME) );
353 if (!mt)
354 return mt;
356 mt->ContentType = msi_dup_record_field( row, 1 );
357 TRACE("loading mime %s\n", debugstr_w(mt->ContentType));
359 extension = MSI_RecordGetString( row, 2 );
360 mt->Extension = load_given_extension( package, extension );
361 mt->suffix = strdupW( extension );
363 mt->clsid = msi_dup_record_field( row, 3 );
364 mt->Class = load_given_class( package, mt->clsid );
366 list_add_tail( &package->mimes, &mt->entry );
368 return mt;
371 static MSIMIME *load_given_mime( MSIPACKAGE *package, LPCWSTR mime )
373 MSIRECORD *row;
374 static const WCHAR ExecSeqQuery[] =
375 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
376 '`','M','I','M','E','`',' ','W','H','E','R','E',' ',
377 '`','C','o','n','t','e','n','t','T','y','p','e','`',' ','=',' ',
378 '\'','%','s','\'',0};
379 MSIMIME *mt;
381 if (!mime)
382 return NULL;
384 /* check for mime already loaded */
385 LIST_FOR_EACH_ENTRY( mt, &package->mimes, MSIMIME, entry )
387 if (!strcmpiW( mt->ContentType, mime ))
389 TRACE("found mime %s (%p)\n",debugstr_w(mime), mt);
390 return mt;
394 row = MSI_QueryGetRecord(package->db, ExecSeqQuery, mime);
395 if (!row)
396 return NULL;
398 mt = load_mime(package, row);
399 msiobj_release(&row->hdr);
401 return mt;
404 static MSIEXTENSION *load_extension( MSIPACKAGE* package, MSIRECORD *row )
406 MSIEXTENSION *ext;
407 LPCWSTR buffer;
409 /* fill in the data */
411 ext = msi_alloc_zero( sizeof(MSIEXTENSION) );
412 if (!ext)
413 return NULL;
415 list_init( &ext->verbs );
417 list_add_tail( &package->extensions, &ext->entry );
419 ext->Extension = msi_dup_record_field( row, 1 );
420 TRACE("loading extension %s\n", debugstr_w(ext->Extension));
422 buffer = MSI_RecordGetString( row, 2 );
423 ext->Component = get_loaded_component( package,buffer );
425 ext->ProgIDText = msi_dup_record_field( row, 3 );
426 ext->ProgID = load_given_progid( package, ext->ProgIDText );
428 buffer = MSI_RecordGetString( row, 4 );
429 ext->Mime = load_given_mime( package, buffer );
431 buffer = MSI_RecordGetString(row,5);
432 ext->Feature = get_loaded_feature( package, buffer );
434 return ext;
438 * While the extension table has 2 primary keys, this function is only looking
439 * at the Extension key which is what is referenced as a foreign key
441 static MSIEXTENSION *load_given_extension( MSIPACKAGE *package, LPCWSTR name )
443 MSIRECORD *row;
444 MSIEXTENSION *ext;
445 static const WCHAR ExecSeqQuery[] =
446 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
447 '`','E','x','t','e','n','s','i','o','n','`',' ',
448 'W','H','E','R','E',' ',
449 '`','E','x','t','e','n','s','i','o','n','`',' ','=',' ',
450 '\'','%','s','\'',0};
452 if (!name)
453 return NULL;
455 if (name[0] == '.')
456 name++;
458 /* check for extensions already loaded */
459 LIST_FOR_EACH_ENTRY( ext, &package->extensions, MSIEXTENSION, entry )
461 if (!strcmpiW( ext->Extension, name ))
463 TRACE("extension %s already loaded %p\n", debugstr_w(name), ext);
464 return ext;
468 row = MSI_QueryGetRecord( package->db, ExecSeqQuery, name );
469 if (!row)
470 return NULL;
472 ext = load_extension(package, row);
473 msiobj_release(&row->hdr);
475 return ext;
478 static UINT iterate_load_verb(MSIRECORD *row, LPVOID param)
480 MSIPACKAGE* package = param;
481 MSIVERB *verb;
482 LPCWSTR buffer;
483 MSIEXTENSION *extension;
485 buffer = MSI_RecordGetString(row,1);
486 extension = load_given_extension( package, buffer );
487 if (!extension)
489 ERR("Verb unable to find loaded extension %s\n", debugstr_w(buffer));
490 return ERROR_SUCCESS;
493 /* fill in the data */
495 verb = msi_alloc_zero( sizeof(MSIVERB) );
496 if (!verb)
497 return ERROR_OUTOFMEMORY;
499 verb->Verb = msi_dup_record_field(row,2);
500 TRACE("loading verb %s\n",debugstr_w(verb->Verb));
501 verb->Sequence = MSI_RecordGetInteger(row,3);
503 buffer = MSI_RecordGetString(row,4);
504 deformat_string(package,buffer,&verb->Command);
506 buffer = MSI_RecordGetString(row,5);
507 deformat_string(package,buffer,&verb->Argument);
509 /* associate the verb with the correct extension */
510 list_add_tail( &extension->verbs, &verb->entry );
512 return ERROR_SUCCESS;
515 static UINT iterate_all_classes(MSIRECORD *rec, LPVOID param)
517 MSICOMPONENT *comp;
518 LPCWSTR clsid;
519 LPCWSTR context;
520 LPCWSTR buffer;
521 MSIPACKAGE* package = param;
522 MSICLASS *cls;
523 BOOL match = FALSE;
525 clsid = MSI_RecordGetString(rec,1);
526 context = MSI_RecordGetString(rec,2);
527 buffer = MSI_RecordGetString(rec,3);
528 comp = get_loaded_component(package,buffer);
530 LIST_FOR_EACH_ENTRY( cls, &package->classes, MSICLASS, entry )
532 if (strcmpiW( clsid, cls->clsid ))
533 continue;
534 if (strcmpW( context, cls->Context ))
535 continue;
536 if (comp == cls->Component)
538 match = TRUE;
539 break;
543 if (!match)
544 load_class(package, rec);
546 return ERROR_SUCCESS;
549 static VOID load_all_classes(MSIPACKAGE *package)
551 UINT rc = ERROR_SUCCESS;
552 MSIQUERY *view;
554 static const WCHAR ExecSeqQuery[] =
555 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
556 '`','C','l','a','s','s','`',0};
558 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
559 if (rc != ERROR_SUCCESS)
560 return;
562 rc = MSI_IterateRecords(view, NULL, iterate_all_classes, package);
563 msiobj_release(&view->hdr);
566 static UINT iterate_all_extensions(MSIRECORD *rec, LPVOID param)
568 MSICOMPONENT *comp;
569 LPCWSTR buffer;
570 LPCWSTR extension;
571 MSIPACKAGE* package = param;
572 BOOL match = FALSE;
573 MSIEXTENSION *ext;
575 extension = MSI_RecordGetString(rec,1);
576 buffer = MSI_RecordGetString(rec,2);
577 comp = get_loaded_component(package,buffer);
579 LIST_FOR_EACH_ENTRY( ext, &package->extensions, MSIEXTENSION, entry )
581 if (strcmpiW(extension, ext->Extension))
582 continue;
583 if (comp == ext->Component)
585 match = TRUE;
586 break;
590 if (!match)
591 load_extension(package, rec);
593 return ERROR_SUCCESS;
596 static VOID load_all_extensions(MSIPACKAGE *package)
598 UINT rc = ERROR_SUCCESS;
599 MSIQUERY *view;
601 static const WCHAR ExecSeqQuery[] =
602 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
603 '`','E','x','t','e','n','s','i','o','n','`',0};
605 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
606 if (rc != ERROR_SUCCESS)
607 return;
609 rc = MSI_IterateRecords(view, NULL, iterate_all_extensions, package);
610 msiobj_release(&view->hdr);
613 static UINT iterate_all_progids(MSIRECORD *rec, LPVOID param)
615 LPCWSTR buffer;
616 MSIPACKAGE* package = param;
618 buffer = MSI_RecordGetString(rec,1);
619 load_given_progid(package,buffer);
620 return ERROR_SUCCESS;
623 static VOID load_all_progids(MSIPACKAGE *package)
625 UINT rc = ERROR_SUCCESS;
626 MSIQUERY *view;
628 static const WCHAR ExecSeqQuery[] =
629 {'S','E','L','E','C','T',' ','`','P','r','o','g','I','d','`',' ',
630 'F','R','O','M',' ', '`','P','r','o','g','I','d','`',0};
632 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
633 if (rc != ERROR_SUCCESS)
634 return;
636 rc = MSI_IterateRecords(view, NULL, iterate_all_progids, package);
637 msiobj_release(&view->hdr);
640 static VOID load_all_verbs(MSIPACKAGE *package)
642 UINT rc = ERROR_SUCCESS;
643 MSIQUERY *view;
645 static const WCHAR ExecSeqQuery[] =
646 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
647 '`','V','e','r','b','`',0};
649 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
650 if (rc != ERROR_SUCCESS)
651 return;
653 rc = MSI_IterateRecords(view, NULL, iterate_load_verb, package);
654 msiobj_release(&view->hdr);
657 static UINT iterate_all_mimes(MSIRECORD *rec, LPVOID param)
659 LPCWSTR buffer;
660 MSIPACKAGE* package = param;
662 buffer = MSI_RecordGetString(rec,1);
663 load_given_mime(package,buffer);
664 return ERROR_SUCCESS;
667 static VOID load_all_mimes(MSIPACKAGE *package)
669 UINT rc = ERROR_SUCCESS;
670 MSIQUERY *view;
672 static const WCHAR ExecSeqQuery[] =
673 {'S','E','L','E','C','T',' ',
674 '`','C','o','n','t','e','n','t','T','y','p','e','`',
675 ' ','F','R','O','M',' ',
676 '`','M','I','M','E','`',0};
678 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
679 if (rc != ERROR_SUCCESS)
680 return;
682 rc = MSI_IterateRecords(view, NULL, iterate_all_mimes, package);
683 msiobj_release(&view->hdr);
686 static void load_classes_and_such(MSIPACKAGE *package)
688 TRACE("Loading all the class info and related tables\n");
690 /* check if already loaded */
691 if (!list_empty( &package->classes ) ||
692 !list_empty( &package->mimes ) ||
693 !list_empty( &package->extensions ) ||
694 !list_empty( &package->progids ) )
695 return;
697 load_all_classes(package);
698 load_all_extensions(package);
699 load_all_progids(package);
700 /* these loads must come after the other loads */
701 load_all_verbs(package);
702 load_all_mimes(package);
705 static void mark_progid_for_install( MSIPACKAGE* package, MSIPROGID *progid )
707 MSIPROGID *child;
709 if (!progid)
710 return;
712 if (progid->InstallMe)
713 return;
715 progid->InstallMe = TRUE;
717 /* all children if this is a parent also install */
718 LIST_FOR_EACH_ENTRY( child, &package->progids, MSIPROGID, entry )
720 if (child->Parent == progid)
721 mark_progid_for_install( package, child );
725 static void mark_progid_for_uninstall( MSIPACKAGE *package, MSIPROGID *progid )
727 MSIPROGID *child;
729 if (!progid)
730 return;
732 if (!progid->InstallMe)
733 return;
735 progid->InstallMe = FALSE;
737 LIST_FOR_EACH_ENTRY( child, &package->progids, MSIPROGID, entry )
739 if (child->Parent == progid)
740 mark_progid_for_uninstall( package, child );
744 static void mark_mime_for_install( MSIMIME *mime )
746 if (!mime)
747 return;
748 mime->InstallMe = TRUE;
751 static void mark_mime_for_uninstall( MSIMIME *mime )
753 if (!mime)
754 return;
755 mime->InstallMe = FALSE;
758 static UINT register_appid(const MSIAPPID *appid, LPCWSTR app )
760 static const WCHAR szRemoteServerName[] =
761 {'R','e','m','o','t','e','S','e','r','v','e','r','N','a','m','e',0};
762 static const WCHAR szLocalService[] =
763 {'L','o','c','a','l','S','e','r','v','i','c','e',0};
764 static const WCHAR szService[] =
765 {'S','e','r','v','i','c','e','P','a','r','a','m','e','t','e','r','s',0};
766 static const WCHAR szDLL[] =
767 {'D','l','l','S','u','r','r','o','g','a','t','e',0};
768 static const WCHAR szActivate[] =
769 {'A','c','t','i','v','a','t','e','A','s','S','t','o','r','a','g','e',0};
770 static const WCHAR szY[] = {'Y',0};
771 static const WCHAR szRunAs[] = {'R','u','n','A','s',0};
772 static const WCHAR szUser[] =
773 {'I','n','t','e','r','a','c','t','i','v','e',' ','U','s','e','r',0};
775 HKEY hkey2,hkey3;
777 RegCreateKeyW(HKEY_CLASSES_ROOT,szAppID,&hkey2);
778 RegCreateKeyW( hkey2, appid->AppID, &hkey3 );
779 RegCloseKey(hkey2);
780 msi_reg_set_val_str( hkey3, NULL, app );
782 if (appid->RemoteServerName)
783 msi_reg_set_val_str( hkey3, szRemoteServerName, appid->RemoteServerName );
785 if (appid->LocalServer)
786 msi_reg_set_val_str( hkey3, szLocalService, appid->LocalServer );
788 if (appid->ServiceParameters)
789 msi_reg_set_val_str( hkey3, szService, appid->ServiceParameters );
791 if (appid->DllSurrogate)
792 msi_reg_set_val_str( hkey3, szDLL, appid->DllSurrogate );
794 if (appid->ActivateAtStorage)
795 msi_reg_set_val_str( hkey3, szActivate, szY );
797 if (appid->RunAsInteractiveUser)
798 msi_reg_set_val_str( hkey3, szRunAs, szUser );
800 RegCloseKey(hkey3);
801 return ERROR_SUCCESS;
804 UINT ACTION_RegisterClassInfo(MSIPACKAGE *package)
806 static const WCHAR szFileType_fmt[] = {'F','i','l','e','T','y','p','e','\\','%','s','\\','%','i',0};
807 const WCHAR *keypath;
808 MSIRECORD *uirow;
809 HKEY hkey,hkey2,hkey3;
810 MSICLASS *cls;
812 load_classes_and_such(package);
814 if (is_64bit && package->platform == PLATFORM_INTEL)
815 keypath = szWow6432NodeCLSID;
816 else
817 keypath = szCLSID;
819 if (RegCreateKeyW(HKEY_CLASSES_ROOT, keypath, &hkey) != ERROR_SUCCESS)
820 return ERROR_FUNCTION_FAILED;
822 LIST_FOR_EACH_ENTRY( cls, &package->classes, MSICLASS, entry )
824 MSICOMPONENT *comp;
825 MSIFILE *file;
826 DWORD size;
827 LPWSTR argument;
828 MSIFEATURE *feature;
830 comp = cls->Component;
831 if ( !comp )
832 continue;
834 if (!comp->Enabled)
836 TRACE("component is disabled\n");
837 continue;
840 feature = cls->Feature;
841 if (!feature)
842 continue;
844 if (feature->ActionRequest != INSTALLSTATE_LOCAL &&
845 feature->ActionRequest != INSTALLSTATE_ADVERTISED )
847 TRACE("Feature %s not scheduled for installation, skipping registration of class %s\n",
848 debugstr_w(feature->Feature), debugstr_w(cls->clsid));
849 continue;
851 feature->Action = feature->ActionRequest;
853 file = get_loaded_file( package, comp->KeyPath );
854 if (!file)
856 TRACE("COM server not provided, skipping class %s\n", debugstr_w(cls->clsid));
857 continue;
860 TRACE("Registering class %s (%p)\n", debugstr_w(cls->clsid), cls);
862 cls->Installed = TRUE;
863 mark_progid_for_install( package, cls->ProgID );
865 RegCreateKeyW( hkey, cls->clsid, &hkey2 );
867 if (cls->Description)
868 msi_reg_set_val_str( hkey2, NULL, cls->Description );
870 RegCreateKeyW( hkey2, cls->Context, &hkey3 );
873 * FIXME: Implement install on demand (advertised components).
875 * ole32.dll should call msi.MsiProvideComponentFromDescriptor()
876 * when it needs an InProcServer that doesn't exist.
877 * The component advertise string should be in the "InProcServer" value.
879 size = lstrlenW( file->TargetPath )+1;
880 if (cls->Argument)
881 size += lstrlenW(cls->Argument)+1;
883 argument = msi_alloc( size * sizeof(WCHAR) );
884 lstrcpyW( argument, file->TargetPath );
886 if (cls->Argument)
888 lstrcatW( argument, szSpace );
889 lstrcatW( argument, cls->Argument );
892 msi_reg_set_val_str( hkey3, NULL, argument );
893 msi_free(argument);
895 RegCloseKey(hkey3);
897 if (cls->ProgID || cls->ProgIDText)
899 LPCWSTR progid;
901 if (cls->ProgID)
902 progid = cls->ProgID->ProgID;
903 else
904 progid = cls->ProgIDText;
906 msi_reg_set_subkey_val( hkey2, szProgID, NULL, progid );
908 if (cls->ProgID && cls->ProgID->VersionInd)
910 msi_reg_set_subkey_val( hkey2, szVIProgID, NULL,
911 cls->ProgID->VersionInd->ProgID );
915 if (cls->AppID)
917 MSIAPPID *appid = cls->AppID;
918 msi_reg_set_val_str( hkey2, szAppID, appid->AppID );
919 register_appid( appid, cls->Description );
922 if (cls->IconPath)
923 msi_reg_set_subkey_val( hkey2, szDefaultIcon, NULL, cls->IconPath );
925 if (cls->DefInprocHandler)
926 msi_reg_set_subkey_val( hkey2, szInprocHandler, NULL, cls->DefInprocHandler );
928 if (cls->DefInprocHandler32)
929 msi_reg_set_subkey_val( hkey2, szInprocHandler32, NULL, cls->DefInprocHandler32 );
931 RegCloseKey(hkey2);
933 /* if there is a FileTypeMask, register the FileType */
934 if (cls->FileTypeMask)
936 LPWSTR ptr, ptr2;
937 LPWSTR keyname;
938 INT index = 0;
939 ptr = cls->FileTypeMask;
940 while (ptr && *ptr)
942 ptr2 = strchrW(ptr,';');
943 if (ptr2)
944 *ptr2 = 0;
945 keyname = msi_alloc( (strlenW(szFileType_fmt) + strlenW(cls->clsid) + 4) * sizeof(WCHAR));
946 sprintfW( keyname, szFileType_fmt, cls->clsid, index );
948 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, keyname, NULL, ptr );
949 msi_free(keyname);
951 if (ptr2)
952 ptr = ptr2+1;
953 else
954 ptr = NULL;
956 index ++;
960 uirow = MSI_CreateRecord(1);
961 MSI_RecordSetStringW( uirow, 1, cls->clsid );
962 ui_actiondata(package,szRegisterClassInfo,uirow);
963 msiobj_release(&uirow->hdr);
966 RegCloseKey(hkey);
967 return ERROR_SUCCESS;
970 UINT ACTION_UnregisterClassInfo( MSIPACKAGE *package )
972 static const WCHAR szFileType[] = {'F','i','l','e','T','y','p','e','\\',0};
973 const WCHAR *keypath;
974 MSIRECORD *uirow;
975 MSICLASS *cls;
976 HKEY hkey, hkey2;
978 load_classes_and_such( package );
980 if (is_64bit && package->platform == PLATFORM_INTEL)
981 keypath = szWow6432NodeCLSID;
982 else
983 keypath = szCLSID;
985 if (RegOpenKeyW( HKEY_CLASSES_ROOT, keypath, &hkey ) != ERROR_SUCCESS)
986 return ERROR_SUCCESS;
988 LIST_FOR_EACH_ENTRY( cls, &package->classes, MSICLASS, entry )
990 MSIFEATURE *feature;
991 MSICOMPONENT *comp;
992 LPWSTR filetype;
993 LONG res;
995 comp = cls->Component;
996 if (!comp)
997 continue;
999 if (!comp->Enabled)
1001 TRACE("component is disabled\n");
1002 continue;
1005 feature = cls->Feature;
1006 if (!feature)
1007 continue;
1009 if (feature->ActionRequest != INSTALLSTATE_ABSENT)
1011 TRACE("Feature %s not scheduled for removal, skipping unregistration of class %s\n",
1012 debugstr_w(feature->Feature), debugstr_w(cls->clsid));
1013 continue;
1015 feature->Action = feature->ActionRequest;
1017 TRACE("Unregistering class %s (%p)\n", debugstr_w(cls->clsid), cls);
1019 cls->Installed = FALSE;
1020 mark_progid_for_uninstall( package, cls->ProgID );
1022 res = RegDeleteTreeW( hkey, cls->clsid );
1023 if (res != ERROR_SUCCESS)
1024 WARN("Failed to delete class key %d\n", res);
1026 if (cls->AppID)
1028 res = RegOpenKeyW( HKEY_CLASSES_ROOT, szAppID, &hkey2 );
1029 if (res == ERROR_SUCCESS)
1031 res = RegDeleteKeyW( hkey2, cls->AppID->AppID );
1032 if (res != ERROR_SUCCESS)
1033 WARN("Failed to delete appid key %d\n", res);
1034 RegCloseKey( hkey2 );
1037 if (cls->FileTypeMask)
1039 filetype = msi_alloc( (strlenW( szFileType ) + strlenW( cls->clsid ) + 1) * sizeof(WCHAR) );
1040 if (filetype)
1042 strcpyW( filetype, szFileType );
1043 strcatW( filetype, cls->clsid );
1044 res = RegDeleteTreeW( HKEY_CLASSES_ROOT, filetype );
1045 msi_free( filetype );
1047 if (res != ERROR_SUCCESS)
1048 WARN("Failed to delete file type %d\n", res);
1052 uirow = MSI_CreateRecord( 1 );
1053 MSI_RecordSetStringW( uirow, 1, cls->clsid );
1054 ui_actiondata( package, szUnregisterClassInfo, uirow );
1055 msiobj_release( &uirow->hdr );
1058 RegCloseKey( hkey );
1059 return ERROR_SUCCESS;
1062 static LPCWSTR get_clsid_of_progid( const MSIPROGID *progid )
1064 while (progid)
1066 if (progid->Class)
1067 return progid->Class->clsid;
1068 if (progid->Parent == progid)
1069 break;
1070 progid = progid->Parent;
1072 return NULL;
1075 static UINT register_progid( const MSIPROGID* progid )
1077 static const WCHAR szCurVer[] = {'C','u','r','V','e','r',0};
1078 HKEY hkey = 0;
1079 UINT rc;
1081 rc = RegCreateKeyW( HKEY_CLASSES_ROOT, progid->ProgID, &hkey );
1082 if (rc == ERROR_SUCCESS)
1084 LPCWSTR clsid = get_clsid_of_progid( progid );
1086 if (clsid)
1087 msi_reg_set_subkey_val( hkey, szCLSID, NULL, clsid );
1088 else
1089 TRACE("%s has no class\n", debugstr_w( progid->ProgID ) );
1091 if (progid->Description)
1092 msi_reg_set_val_str( hkey, NULL, progid->Description );
1094 if (progid->IconPath)
1095 msi_reg_set_subkey_val( hkey, szDefaultIcon, NULL, progid->IconPath );
1097 /* write out the current version */
1098 if (progid->CurVer)
1099 msi_reg_set_subkey_val( hkey, szCurVer, NULL, progid->CurVer->ProgID );
1101 RegCloseKey(hkey);
1103 else
1104 ERR("failed to create key %s\n", debugstr_w( progid->ProgID ) );
1106 return rc;
1109 UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package)
1111 MSIPROGID *progid;
1112 MSIRECORD *uirow;
1114 load_classes_and_such(package);
1116 LIST_FOR_EACH_ENTRY( progid, &package->progids, MSIPROGID, entry )
1118 /* check if this progid is to be installed */
1119 if (progid->Class && progid->Class->Installed)
1120 progid->InstallMe = TRUE;
1122 if (!progid->InstallMe)
1124 TRACE("progid %s not scheduled to be installed\n",
1125 debugstr_w(progid->ProgID));
1126 continue;
1129 TRACE("Registering progid %s\n", debugstr_w(progid->ProgID));
1131 register_progid( progid );
1133 uirow = MSI_CreateRecord( 1 );
1134 MSI_RecordSetStringW( uirow, 1, progid->ProgID );
1135 ui_actiondata( package, szRegisterProgIdInfo, uirow );
1136 msiobj_release( &uirow->hdr );
1139 return ERROR_SUCCESS;
1142 UINT ACTION_UnregisterProgIdInfo( MSIPACKAGE *package )
1144 MSIPROGID *progid;
1145 MSIRECORD *uirow;
1146 LONG res;
1148 load_classes_and_such( package );
1150 LIST_FOR_EACH_ENTRY( progid, &package->progids, MSIPROGID, entry )
1152 /* check if this progid is to be removed */
1153 if (progid->Class && !progid->Class->Installed)
1154 progid->InstallMe = FALSE;
1156 if (progid->InstallMe)
1158 TRACE("progid %s not scheduled to be removed\n", debugstr_w(progid->ProgID));
1159 continue;
1162 TRACE("Unregistering progid %s\n", debugstr_w(progid->ProgID));
1164 res = RegDeleteTreeW( HKEY_CLASSES_ROOT, progid->ProgID );
1165 if (res != ERROR_SUCCESS)
1166 TRACE("Failed to delete progid key %d\n", res);
1168 uirow = MSI_CreateRecord( 1 );
1169 MSI_RecordSetStringW( uirow, 1, progid->ProgID );
1170 ui_actiondata( package, szUnregisterProgIdInfo, uirow );
1171 msiobj_release( &uirow->hdr );
1174 return ERROR_SUCCESS;
1177 static UINT register_verb(MSIPACKAGE *package, LPCWSTR progid,
1178 MSICOMPONENT* component, const MSIEXTENSION* extension,
1179 MSIVERB* verb, INT* Sequence )
1181 LPWSTR keyname;
1182 HKEY key;
1183 static const WCHAR szShell[] = {'s','h','e','l','l',0};
1184 static const WCHAR szCommand[] = {'c','o','m','m','a','n','d',0};
1185 static const WCHAR fmt[] = {'\"','%','s','\"',' ','%','s',0};
1186 static const WCHAR fmt2[] = {'\"','%','s','\"',0};
1187 LPWSTR command;
1188 DWORD size;
1189 LPWSTR advertise;
1191 keyname = build_directory_name(4, progid, szShell, verb->Verb, szCommand);
1193 TRACE("Making Key %s\n",debugstr_w(keyname));
1194 RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key);
1195 size = strlenW(component->FullKeypath);
1196 if (verb->Argument)
1197 size += strlenW(verb->Argument);
1198 size += 4;
1200 command = msi_alloc(size * sizeof (WCHAR));
1201 if (verb->Argument)
1202 sprintfW(command, fmt, component->FullKeypath, verb->Argument);
1203 else
1204 sprintfW(command, fmt2, component->FullKeypath);
1206 msi_reg_set_val_str( key, NULL, command );
1207 msi_free(command);
1209 advertise = create_component_advertise_string(package, component,
1210 extension->Feature->Feature);
1212 size = strlenW(advertise);
1214 if (verb->Argument)
1215 size += strlenW(verb->Argument);
1216 size += 4;
1218 command = msi_alloc_zero(size * sizeof (WCHAR));
1220 strcpyW(command,advertise);
1221 if (verb->Argument)
1223 strcatW(command,szSpace);
1224 strcatW(command,verb->Argument);
1227 msi_reg_set_val_multi_str( key, szCommand, command );
1229 RegCloseKey(key);
1230 msi_free(keyname);
1231 msi_free(advertise);
1232 msi_free(command);
1234 if (verb->Command)
1236 keyname = build_directory_name(3, progid, szShell, verb->Verb);
1237 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, keyname, NULL, verb->Command );
1238 msi_free(keyname);
1241 if (verb->Sequence != MSI_NULL_INTEGER)
1243 if (*Sequence == MSI_NULL_INTEGER || verb->Sequence < *Sequence)
1245 *Sequence = verb->Sequence;
1246 keyname = build_directory_name(2, progid, szShell);
1247 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, keyname, NULL, verb->Verb );
1248 msi_free(keyname);
1251 return ERROR_SUCCESS;
1254 UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package)
1256 static const WCHAR szContentType[] =
1257 {'C','o','n','t','e','n','t',' ','T','y','p','e',0 };
1258 HKEY hkey = NULL;
1259 MSIEXTENSION *ext;
1260 MSIRECORD *uirow;
1261 BOOL install_on_demand = TRUE;
1262 LONG res;
1264 load_classes_and_such(package);
1266 /* We need to set install_on_demand based on if the shell handles advertised
1267 * shortcuts and the like. Because Mike McCormack is working on this i am
1268 * going to default to TRUE
1271 LIST_FOR_EACH_ENTRY( ext, &package->extensions, MSIEXTENSION, entry )
1273 LPWSTR extension;
1274 MSIFEATURE *feature;
1276 if (!ext->Component)
1277 continue;
1279 if (!ext->Component->Enabled)
1281 TRACE("component is disabled\n");
1282 continue;
1285 feature = ext->Feature;
1286 if (!feature)
1287 continue;
1290 * yes. MSDN says that these are based on _Feature_ not on
1291 * Component. So verify the feature is to be installed
1293 if (feature->ActionRequest != INSTALLSTATE_LOCAL &&
1294 !(install_on_demand && feature->ActionRequest == INSTALLSTATE_ADVERTISED))
1296 TRACE("Feature %s not scheduled for installation, skipping registration of extension %s\n",
1297 debugstr_w(feature->Feature), debugstr_w(ext->Extension));
1298 continue;
1300 feature->Action = feature->ActionRequest;
1302 TRACE("Registering extension %s (%p)\n", debugstr_w(ext->Extension), ext);
1304 ext->Installed = TRUE;
1306 /* this is only registered if the extension has at least 1 verb
1307 * according to MSDN
1309 if (ext->ProgID && !list_empty( &ext->verbs ) )
1310 mark_progid_for_install( package, ext->ProgID );
1312 mark_mime_for_install(ext->Mime);
1314 extension = msi_alloc( (strlenW( ext->Extension ) + 2) * sizeof(WCHAR) );
1315 if (extension)
1317 extension[0] = '.';
1318 strcpyW( extension + 1, ext->Extension );
1319 res = RegCreateKeyW( HKEY_CLASSES_ROOT, extension, &hkey );
1320 msi_free( extension );
1321 if (res != ERROR_SUCCESS)
1322 WARN("Failed to create extension key %d\n", res);
1325 if (ext->Mime)
1326 msi_reg_set_val_str( hkey, szContentType, ext->Mime->ContentType );
1328 if (ext->ProgID || ext->ProgIDText)
1330 static const WCHAR szSN[] =
1331 {'\\','S','h','e','l','l','N','e','w',0};
1332 HKEY hkey2;
1333 LPWSTR newkey;
1334 LPCWSTR progid;
1335 MSIVERB *verb;
1336 INT Sequence = MSI_NULL_INTEGER;
1338 if (ext->ProgID)
1339 progid = ext->ProgID->ProgID;
1340 else
1341 progid = ext->ProgIDText;
1343 msi_reg_set_val_str( hkey, NULL, progid );
1345 newkey = msi_alloc( (strlenW(progid)+strlenW(szSN)+1) * sizeof(WCHAR));
1347 strcpyW(newkey,progid);
1348 strcatW(newkey,szSN);
1349 RegCreateKeyW(hkey,newkey,&hkey2);
1350 RegCloseKey(hkey2);
1352 msi_free(newkey);
1354 /* do all the verbs */
1355 LIST_FOR_EACH_ENTRY( verb, &ext->verbs, MSIVERB, entry )
1357 register_verb( package, progid, ext->Component,
1358 ext, verb, &Sequence);
1362 RegCloseKey(hkey);
1364 uirow = MSI_CreateRecord(1);
1365 MSI_RecordSetStringW( uirow, 1, ext->Extension );
1366 ui_actiondata(package,szRegisterExtensionInfo,uirow);
1367 msiobj_release(&uirow->hdr);
1370 return ERROR_SUCCESS;
1373 UINT ACTION_UnregisterExtensionInfo( MSIPACKAGE *package )
1375 MSIEXTENSION *ext;
1376 MSIRECORD *uirow;
1377 LONG res;
1379 load_classes_and_such( package );
1381 LIST_FOR_EACH_ENTRY( ext, &package->extensions, MSIEXTENSION, entry )
1383 LPWSTR extension;
1384 MSIFEATURE *feature;
1386 if (!ext->Component)
1387 continue;
1389 if (!ext->Component->Enabled)
1391 TRACE("component is disabled\n");
1392 continue;
1395 feature = ext->Feature;
1396 if (!feature)
1397 continue;
1399 if (feature->ActionRequest != INSTALLSTATE_ABSENT)
1401 TRACE("Feature %s not scheduled for removal, skipping unregistration of extension %s\n",
1402 debugstr_w(feature->Feature), debugstr_w(ext->Extension));
1403 continue;
1406 TRACE("Unregistering extension %s\n", debugstr_w(ext->Extension));
1408 ext->Installed = FALSE;
1410 if (ext->ProgID && !list_empty( &ext->verbs ))
1411 mark_progid_for_uninstall( package, ext->ProgID );
1413 mark_mime_for_uninstall( ext->Mime );
1415 extension = msi_alloc( (strlenW( ext->Extension ) + 2) * sizeof(WCHAR) );
1416 if (extension)
1418 extension[0] = '.';
1419 strcpyW( extension + 1, ext->Extension );
1420 res = RegDeleteTreeW( HKEY_CLASSES_ROOT, extension );
1421 msi_free( extension );
1422 if (res != ERROR_SUCCESS)
1423 WARN("Failed to delete extension key %d\n", res);
1426 if (ext->ProgID || ext->ProgIDText)
1428 static const WCHAR shellW[] = {'\\','s','h','e','l','l',0};
1429 LPCWSTR progid;
1430 LPWSTR progid_shell;
1432 if (ext->ProgID)
1433 progid = ext->ProgID->ProgID;
1434 else
1435 progid = ext->ProgIDText;
1437 progid_shell = msi_alloc( (strlenW( progid ) + strlenW( shellW ) + 1) * sizeof(WCHAR) );
1438 if (progid_shell)
1440 strcpyW( progid_shell, progid );
1441 strcatW( progid_shell, shellW );
1442 res = RegDeleteTreeW( HKEY_CLASSES_ROOT, progid_shell );
1443 msi_free( progid_shell );
1444 if (res != ERROR_SUCCESS)
1445 WARN("Failed to delete shell key %d\n", res);
1446 RegDeleteKeyW( HKEY_CLASSES_ROOT, progid );
1450 uirow = MSI_CreateRecord( 1 );
1451 MSI_RecordSetStringW( uirow, 1, ext->Extension );
1452 ui_actiondata( package, szUnregisterExtensionInfo, uirow );
1453 msiobj_release( &uirow->hdr );
1456 return ERROR_SUCCESS;
1459 UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package)
1461 static const WCHAR szExten[] =
1462 {'E','x','t','e','n','s','i','o','n',0 };
1463 MSIRECORD *uirow;
1464 MSIMIME *mt;
1466 load_classes_and_such(package);
1468 LIST_FOR_EACH_ENTRY( mt, &package->mimes, MSIMIME, entry )
1470 LPWSTR extension;
1471 LPWSTR key;
1474 * check if the MIME is to be installed. Either as requested by an
1475 * extension or Class
1477 mt->InstallMe = (mt->InstallMe ||
1478 (mt->Class && mt->Class->Installed) ||
1479 (mt->Extension && mt->Extension->Installed));
1481 if (!mt->InstallMe)
1483 TRACE("MIME %s not scheduled to be installed\n", debugstr_w(mt->ContentType));
1484 continue;
1487 TRACE("Registering MIME type %s\n", debugstr_w(mt->ContentType));
1489 extension = msi_alloc( (strlenW( mt->Extension->Extension ) + 2) * sizeof(WCHAR) );
1490 key = msi_alloc( (strlenW( mt->ContentType ) + strlenW( szMIMEDatabase ) + 1) * sizeof(WCHAR) );
1492 if (extension && key)
1494 extension[0] = '.';
1495 strcpyW( extension + 1, mt->Extension->Extension );
1497 strcpyW( key, szMIMEDatabase );
1498 strcatW( key, mt->ContentType );
1499 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, key, szExten, extension );
1501 if (mt->clsid)
1502 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, key, szCLSID, mt->clsid );
1504 msi_free( extension );
1505 msi_free( key );
1507 uirow = MSI_CreateRecord( 2 );
1508 MSI_RecordSetStringW( uirow, 1, mt->ContentType );
1509 MSI_RecordSetStringW( uirow, 2, mt->suffix );
1510 ui_actiondata( package, szRegisterMIMEInfo, uirow );
1511 msiobj_release( &uirow->hdr );
1514 return ERROR_SUCCESS;
1517 UINT ACTION_UnregisterMIMEInfo( MSIPACKAGE *package )
1519 MSIRECORD *uirow;
1520 MSIMIME *mime;
1522 load_classes_and_such( package );
1524 LIST_FOR_EACH_ENTRY( mime, &package->mimes, MSIMIME, entry )
1526 LONG res;
1527 LPWSTR mime_key;
1529 mime->InstallMe = (mime->InstallMe ||
1530 (mime->Class && mime->Class->Installed) ||
1531 (mime->Extension && mime->Extension->Installed));
1533 if (mime->InstallMe)
1535 TRACE("MIME %s not scheduled to be removed\n", debugstr_w(mime->ContentType));
1536 continue;
1539 TRACE("Unregistering MIME type %s\n", debugstr_w(mime->ContentType));
1541 mime_key = msi_alloc( (strlenW( szMIMEDatabase ) + strlenW( mime->ContentType ) + 1) * sizeof(WCHAR) );
1542 if (mime_key)
1544 strcpyW( mime_key, szMIMEDatabase );
1545 strcatW( mime_key, mime->ContentType );
1546 res = RegDeleteKeyW( HKEY_CLASSES_ROOT, mime_key );
1547 if (res != ERROR_SUCCESS)
1548 WARN("Failed to delete MIME key %d\n", res);
1549 msi_free( mime_key );
1552 uirow = MSI_CreateRecord( 2 );
1553 MSI_RecordSetStringW( uirow, 1, mime->ContentType );
1554 MSI_RecordSetStringW( uirow, 2, mime->suffix );
1555 ui_actiondata( package, szUnregisterMIMEInfo, uirow );
1556 msiobj_release( &uirow->hdr );
1559 return ERROR_SUCCESS;