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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /* actions handled in this module
24 * RegisterExtensionInfo
26 * UnRegisterClassInfo (TODO)
27 * UnRegisterProgIdInfo (TODO)
28 * UnRegisterExtensionInfo (TODO)
29 * UnRegisterMIMEInfo (TODO)
38 #include "wine/debug.h"
41 #include "wine/unicode.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
47 extern const WCHAR szRegisterClassInfo
[];
48 extern const WCHAR szRegisterProgIdInfo
[];
49 extern const WCHAR szRegisterExtensionInfo
[];
50 extern const WCHAR szRegisterMIMEInfo
[];
52 extern const WCHAR szUnregisterClassInfo
[];
53 extern const WCHAR szUnregisterExtensionInfo
[];
54 extern const WCHAR szUnregisterMIMEInfo
[];
55 extern const WCHAR szUnregisterProgIdInfo
[];
57 static MSIAPPID
*load_appid( MSIPACKAGE
* package
, MSIRECORD
*row
)
62 /* fill in the data */
64 appid
= msi_alloc_zero( sizeof(MSIAPPID
) );
68 appid
->AppID
= load_dynamic_stringW( row
, 1 );
69 TRACE("loading appid %s\n", debugstr_w( appid
->AppID
));
71 buffer
= MSI_RecordGetString(row
,2);
72 deformat_string( package
, buffer
, &appid
->RemoteServerName
);
74 appid
->LocalServer
= load_dynamic_stringW(row
,3);
75 appid
->ServiceParameters
= load_dynamic_stringW(row
,4);
76 appid
->DllSurrogate
= load_dynamic_stringW(row
,5);
78 appid
->ActivateAtStorage
= !MSI_RecordIsNull(row
,6);
79 appid
->RunAsInteractiveUser
= !MSI_RecordIsNull(row
,7);
81 list_add_tail( &package
->appids
, &appid
->entry
);
86 static MSIAPPID
*load_given_appid( MSIPACKAGE
*package
, LPCWSTR name
)
90 static const WCHAR ExecSeqQuery
[] =
91 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
92 '`','A','p','p','I','d','`',' ','W','H','E','R','E',' ',
93 '`','A','p','p','I','d','`',' ','=',' ','\'','%','s','\'',0};
98 /* check for appids already loaded */
99 LIST_FOR_EACH_ENTRY( appid
, &package
->appids
, MSIAPPID
, entry
)
101 if (lstrcmpiW( appid
->AppID
, name
)==0)
103 TRACE("found appid %s %p\n", debugstr_w(name
), appid
);
108 row
= MSI_QueryGetRecord(package
->db
, ExecSeqQuery
, name
);
112 appid
= load_appid(package
, row
);
113 msiobj_release(&row
->hdr
);
118 static MSIPROGID
*load_given_progid(MSIPACKAGE
*package
, LPCWSTR progid
);
119 static MSICLASS
*load_given_class( MSIPACKAGE
*package
, LPCWSTR classid
);
121 static MSIPROGID
*load_progid( MSIPACKAGE
* package
, MSIRECORD
*row
)
126 /* fill in the data */
128 progid
= msi_alloc_zero( sizeof(MSIPROGID
) );
132 list_add_tail( &package
->progids
, &progid
->entry
);
134 progid
->ProgID
= load_dynamic_stringW(row
,1);
135 TRACE("loading progid %s\n",debugstr_w(progid
->ProgID
));
137 buffer
= MSI_RecordGetString(row
,2);
138 progid
->Parent
= load_given_progid(package
,buffer
);
139 if (progid
->Parent
== NULL
&& buffer
)
140 FIXME("Unknown parent ProgID %s\n",debugstr_w(buffer
));
142 buffer
= MSI_RecordGetString(row
,3);
143 progid
->Class
= load_given_class(package
,buffer
);
144 if (progid
->Class
== NULL
&& buffer
)
145 FIXME("Unknown class %s\n",debugstr_w(buffer
));
147 progid
->Description
= load_dynamic_stringW(row
,4);
149 if (!MSI_RecordIsNull(row
,6))
151 INT icon_index
= MSI_RecordGetInteger(row
,6);
152 LPWSTR FileName
= load_dynamic_stringW(row
,5);
154 static const WCHAR fmt
[] = {'%','s',',','%','i',0};
156 FilePath
= build_icon_path(package
,FileName
);
158 progid
->IconPath
= msi_alloc( (strlenW(FilePath
)+10)* sizeof(WCHAR
) );
160 sprintfW(progid
->IconPath
,fmt
,FilePath
,icon_index
);
167 buffer
= MSI_RecordGetString(row
,5);
169 progid
->IconPath
= build_icon_path(package
,buffer
);
172 progid
->CurVer
= NULL
;
173 progid
->VersionInd
= NULL
;
175 /* if we have a parent then we may be that parents CurVer */
176 if (progid
->Parent
&& progid
->Parent
!= progid
)
178 MSIPROGID
*parent
= progid
->Parent
;
180 while (parent
->Parent
&& parent
->Parent
!= parent
)
181 parent
= parent
->Parent
;
183 FIXME("need to determing if we are really the CurVer\n");
185 progid
->CurVer
= parent
;
186 parent
->VersionInd
= progid
;
192 static MSIPROGID
*load_given_progid(MSIPACKAGE
*package
, LPCWSTR name
)
196 static const WCHAR ExecSeqQuery
[] =
197 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
198 '`','P','r','o','g','I','d','`',' ','W','H','E','R','E',' ',
199 '`','P','r','o','g','I','d','`',' ','=',' ','\'','%','s','\'',0};
204 /* check for progids already loaded */
205 LIST_FOR_EACH_ENTRY( progid
, &package
->progids
, MSIPROGID
, entry
)
207 if (strcmpiW( progid
->ProgID
,name
)==0)
209 TRACE("found progid %s (%p)\n",debugstr_w(name
), progid
);
214 row
= MSI_QueryGetRecord( package
->db
, ExecSeqQuery
, name
);
218 progid
= load_progid(package
, row
);
219 msiobj_release(&row
->hdr
);
224 static MSICLASS
*load_class( MSIPACKAGE
* package
, MSIRECORD
*row
)
230 /* fill in the data */
232 cls
= msi_alloc_zero( sizeof(MSICLASS
) );
236 list_add_tail( &package
->classes
, &cls
->entry
);
238 cls
->clsid
= load_dynamic_stringW( row
, 1 );
239 TRACE("loading class %s\n",debugstr_w(cls
->clsid
));
240 cls
->Context
= load_dynamic_stringW( row
, 2 );
241 buffer
= MSI_RecordGetString(row
,3);
242 cls
->Component
= get_loaded_component(package
, buffer
);
244 cls
->ProgIDText
= load_dynamic_stringW(row
,4);
245 cls
->ProgID
= load_given_progid(package
, cls
->ProgIDText
);
247 cls
->Description
= load_dynamic_stringW(row
,5);
249 buffer
= MSI_RecordGetString(row
,6);
251 cls
->AppID
= load_given_appid(package
, buffer
);
253 cls
->FileTypeMask
= load_dynamic_stringW(row
,7);
255 if (!MSI_RecordIsNull(row
,9))
258 INT icon_index
= MSI_RecordGetInteger(row
,9);
259 LPWSTR FileName
= load_dynamic_stringW(row
,8);
261 static const WCHAR fmt
[] = {'%','s',',','%','i',0};
263 FilePath
= build_icon_path(package
,FileName
);
265 cls
->IconPath
= msi_alloc( (strlenW(FilePath
)+5)* sizeof(WCHAR
) );
267 sprintfW(cls
->IconPath
,fmt
,FilePath
,icon_index
);
274 buffer
= MSI_RecordGetString(row
,8);
276 cls
->IconPath
= build_icon_path(package
,buffer
);
279 if (!MSI_RecordIsNull(row
,10))
281 i
= MSI_RecordGetInteger(row
,10);
282 if (i
!= MSI_NULL_INTEGER
&& i
> 0 && i
< 4)
284 static const WCHAR ole2
[] = {'o','l','e','2','.','d','l','l',0};
285 static const WCHAR ole32
[] = {'o','l','e','3','2','.','d','l','l',0};
290 cls
->DefInprocHandler
= strdupW(ole2
);
293 cls
->DefInprocHandler32
= strdupW(ole32
);
296 cls
->DefInprocHandler
= strdupW(ole2
);
297 cls
->DefInprocHandler32
= strdupW(ole32
);
303 cls
->DefInprocHandler32
= load_dynamic_stringW( row
, 10);
304 reduce_to_longfilename(cls
->DefInprocHandler32
);
307 buffer
= MSI_RecordGetString(row
,11);
308 deformat_string(package
,buffer
,&cls
->Argument
);
310 buffer
= MSI_RecordGetString(row
,12);
311 cls
->Feature
= get_loaded_feature(package
,buffer
);
313 cls
->Attributes
= MSI_RecordGetInteger(row
,13);
319 * the Class table has 3 primary keys. Generally it is only
320 * referenced through the first CLSID key. However when loading
321 * all of the classes we need to make sure we do not ignore rows
322 * with other Context and ComponentIndexs
324 static MSICLASS
*load_given_class(MSIPACKAGE
*package
, LPCWSTR classid
)
328 static const WCHAR ExecSeqQuery
[] =
329 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
330 '`','C','l','a','s','s','`',' ','W','H','E','R','E',' ',
331 '`','C','L','S','I','D','`',' ','=',' ','\'','%','s','\'',0};
336 /* check for classes already loaded */
337 LIST_FOR_EACH_ENTRY( cls
, &package
->classes
, MSICLASS
, entry
)
339 if (lstrcmpiW( cls
->clsid
, classid
)==0)
341 TRACE("found class %s (%p)\n",debugstr_w(classid
), cls
);
346 row
= MSI_QueryGetRecord(package
->db
, ExecSeqQuery
, classid
);
350 cls
= load_class(package
, row
);
351 msiobj_release(&row
->hdr
);
356 static MSIEXTENSION
*load_given_extension( MSIPACKAGE
*package
, LPCWSTR extension
);
358 static MSIMIME
*load_mime( MSIPACKAGE
* package
, MSIRECORD
*row
)
363 /* fill in the data */
365 mt
= msi_alloc_zero( sizeof(MSIMIME
) );
369 mt
->ContentType
= load_dynamic_stringW( row
, 1 );
370 TRACE("loading mime %s\n", debugstr_w(mt
->ContentType
));
372 buffer
= MSI_RecordGetString( row
, 2 );
373 mt
->Extension
= load_given_extension( package
, buffer
);
375 mt
->clsid
= load_dynamic_stringW( row
, 3 );
376 mt
->Class
= load_given_class( package
, mt
->clsid
);
378 list_add_tail( &package
->mimes
, &mt
->entry
);
383 static MSIMIME
*load_given_mime( MSIPACKAGE
*package
, LPCWSTR mime
)
386 static const WCHAR ExecSeqQuery
[] =
387 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
388 '`','M','I','M','E','`',' ','W','H','E','R','E',' ',
389 '`','C','o','n','t','e','n','t','T','y','p','e','`',' ','=',' ',
390 '\'','%','s','\'',0};
396 /* check for mime already loaded */
397 LIST_FOR_EACH_ENTRY( mt
, &package
->mimes
, MSIMIME
, entry
)
399 if (strcmpiW(mt
->ContentType
,mime
)==0)
401 TRACE("found mime %s (%p)\n",debugstr_w(mime
), mt
);
406 row
= MSI_QueryGetRecord(package
->db
, ExecSeqQuery
, mime
);
410 mt
= load_mime(package
, row
);
411 msiobj_release(&row
->hdr
);
416 static MSIEXTENSION
*load_extension( MSIPACKAGE
* package
, MSIRECORD
*row
)
421 /* fill in the data */
423 ext
= msi_alloc_zero( sizeof(MSIEXTENSION
) );
427 list_init( &ext
->verbs
);
429 list_add_tail( &package
->extensions
, &ext
->entry
);
431 ext
->Extension
= load_dynamic_stringW( row
, 1 );
432 TRACE("loading extension %s\n", debugstr_w(ext
->Extension
));
434 buffer
= MSI_RecordGetString( row
, 2 );
435 ext
->Component
= get_loaded_component( package
,buffer
);
437 ext
->ProgIDText
= load_dynamic_stringW( row
, 3 );
438 ext
->ProgID
= load_given_progid( package
, ext
->ProgIDText
);
440 buffer
= MSI_RecordGetString( row
, 4 );
441 ext
->Mime
= load_given_mime( package
, buffer
);
443 buffer
= MSI_RecordGetString(row
,5);
444 ext
->Feature
= get_loaded_feature( package
, buffer
);
450 * While the extension table has 2 primary keys, this function is only looking
451 * at the Extension key which is what is referenced as a forign key
453 static MSIEXTENSION
*load_given_extension( MSIPACKAGE
*package
, LPCWSTR name
)
457 static const WCHAR ExecSeqQuery
[] =
458 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
459 '`','E','x','t','e','n','s','i','o','n','`',' ',
460 'W','H','E','R','E',' ',
461 '`','E','x','t','e','n','s','i','o','n','`',' ','=',' ',
462 '\'','%','s','\'',0};
467 /* check for extensions already loaded */
468 LIST_FOR_EACH_ENTRY( ext
, &package
->extensions
, MSIEXTENSION
, entry
)
470 if (strcmpiW( ext
->Extension
, name
)==0)
472 TRACE("extension %s already loaded %p\n", debugstr_w(name
), ext
);
477 row
= MSI_QueryGetRecord( package
->db
, ExecSeqQuery
, name
);
481 ext
= load_extension(package
, row
);
482 msiobj_release(&row
->hdr
);
487 static UINT
iterate_load_verb(MSIRECORD
*row
, LPVOID param
)
489 MSIPACKAGE
* package
= (MSIPACKAGE
*)param
;
492 MSIEXTENSION
*extension
;
494 buffer
= MSI_RecordGetString(row
,1);
495 extension
= load_given_extension( package
, buffer
);
498 ERR("Verb unable to find loaded extension %s\n", debugstr_w(buffer
));
499 return ERROR_SUCCESS
;
502 /* fill in the data */
504 verb
= msi_alloc_zero( sizeof(MSIVERB
) );
506 return ERROR_OUTOFMEMORY
;
508 verb
->Verb
= load_dynamic_stringW(row
,2);
509 TRACE("loading verb %s\n",debugstr_w(verb
->Verb
));
510 verb
->Sequence
= MSI_RecordGetInteger(row
,3);
512 buffer
= MSI_RecordGetString(row
,4);
513 deformat_string(package
,buffer
,&verb
->Command
);
515 buffer
= MSI_RecordGetString(row
,5);
516 deformat_string(package
,buffer
,&verb
->Argument
);
518 /* assosiate the verb with the correct extension */
519 list_add_tail( &extension
->verbs
, &verb
->entry
);
521 return ERROR_SUCCESS
;
524 static UINT
iterate_all_classes(MSIRECORD
*rec
, LPVOID param
)
530 MSIPACKAGE
* package
=(MSIPACKAGE
*)param
;
534 clsid
= MSI_RecordGetString(rec
,1);
535 context
= MSI_RecordGetString(rec
,2);
536 buffer
= MSI_RecordGetString(rec
,3);
537 comp
= get_loaded_component(package
,buffer
);
539 LIST_FOR_EACH_ENTRY( cls
, &package
->classes
, MSICLASS
, entry
)
541 if (strcmpiW( clsid
, cls
->clsid
))
543 if (strcmpW( context
, cls
->Context
))
545 if (comp
== cls
->Component
)
553 load_class(package
, rec
);
555 return ERROR_SUCCESS
;
558 static VOID
load_all_classes(MSIPACKAGE
*package
)
560 UINT rc
= ERROR_SUCCESS
;
563 static const WCHAR ExecSeqQuery
[] =
564 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
565 '`','C','l','a','s','s','`',0};
567 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
568 if (rc
!= ERROR_SUCCESS
)
571 rc
= MSI_IterateRecords(view
, NULL
, iterate_all_classes
, package
);
572 msiobj_release(&view
->hdr
);
575 static UINT
iterate_all_extensions(MSIRECORD
*rec
, LPVOID param
)
580 MSIPACKAGE
* package
=(MSIPACKAGE
*)param
;
584 extension
= MSI_RecordGetString(rec
,1);
585 buffer
= MSI_RecordGetString(rec
,2);
586 comp
= get_loaded_component(package
,buffer
);
588 LIST_FOR_EACH_ENTRY( ext
, &package
->extensions
, MSIEXTENSION
, entry
)
590 if (strcmpiW(extension
,ext
->Extension
))
592 if (comp
== ext
->Component
)
600 load_extension(package
, rec
);
602 return ERROR_SUCCESS
;
605 static VOID
load_all_extensions(MSIPACKAGE
*package
)
607 UINT rc
= ERROR_SUCCESS
;
610 static const WCHAR ExecSeqQuery
[] =
611 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
612 '`','E','x','t','e','n','s','i','o','n','`',0};
614 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
615 if (rc
!= ERROR_SUCCESS
)
618 rc
= MSI_IterateRecords(view
, NULL
, iterate_all_extensions
, package
);
619 msiobj_release(&view
->hdr
);
622 static UINT
iterate_all_progids(MSIRECORD
*rec
, LPVOID param
)
625 MSIPACKAGE
* package
=(MSIPACKAGE
*)param
;
627 buffer
= MSI_RecordGetString(rec
,1);
628 load_given_progid(package
,buffer
);
629 return ERROR_SUCCESS
;
632 static VOID
load_all_progids(MSIPACKAGE
*package
)
634 UINT rc
= ERROR_SUCCESS
;
637 static const WCHAR ExecSeqQuery
[] =
638 {'S','E','L','E','C','T',' ','`','P','r','o','g','I','d','`',' ',
639 'F','R','O','M',' ', '`','P','r','o','g','I','d','`',0};
641 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
642 if (rc
!= ERROR_SUCCESS
)
645 rc
= MSI_IterateRecords(view
, NULL
, iterate_all_progids
, package
);
646 msiobj_release(&view
->hdr
);
649 static VOID
load_all_verbs(MSIPACKAGE
*package
)
651 UINT rc
= ERROR_SUCCESS
;
654 static const WCHAR ExecSeqQuery
[] =
655 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
656 '`','V','e','r','b','`',0};
658 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
659 if (rc
!= ERROR_SUCCESS
)
662 rc
= MSI_IterateRecords(view
, NULL
, iterate_load_verb
, package
);
663 msiobj_release(&view
->hdr
);
666 static UINT
iterate_all_mimes(MSIRECORD
*rec
, LPVOID param
)
669 MSIPACKAGE
* package
=(MSIPACKAGE
*)param
;
671 buffer
= MSI_RecordGetString(rec
,1);
672 load_given_mime(package
,buffer
);
673 return ERROR_SUCCESS
;
676 static VOID
load_all_mimes(MSIPACKAGE
*package
)
678 UINT rc
= ERROR_SUCCESS
;
681 static const WCHAR ExecSeqQuery
[] =
682 {'S','E','L','E','C','T',' ',
683 '`','C','o','n','t','e','n','t','T','y','p','e','`',
684 ' ','F','R','O','M',' ',
685 '`','M','I','M','E','`',0};
687 rc
= MSI_DatabaseOpenViewW(package
->db
, ExecSeqQuery
, &view
);
688 if (rc
!= ERROR_SUCCESS
)
691 rc
= MSI_IterateRecords(view
, NULL
, iterate_all_mimes
, package
);
692 msiobj_release(&view
->hdr
);
695 static void load_classes_and_such(MSIPACKAGE
*package
)
697 TRACE("Loading all the class info and related tables\n");
699 /* check if already loaded */
700 if (!list_empty( &package
->classes
) ||
701 !list_empty( &package
->mimes
) ||
702 !list_empty( &package
->extensions
) ||
703 !list_empty( &package
->progids
) )
706 load_all_classes(package
);
707 load_all_extensions(package
);
708 load_all_progids(package
);
709 /* these loads must come after the other loads */
710 load_all_verbs(package
);
711 load_all_mimes(package
);
714 static void mark_progid_for_install( MSIPACKAGE
* package
, MSIPROGID
*progid
)
721 if (progid
->InstallMe
== TRUE
)
724 progid
->InstallMe
= TRUE
;
726 /* all children if this is a parent also install */
727 LIST_FOR_EACH_ENTRY( child
, &package
->progids
, MSIPROGID
, entry
)
729 if (child
->Parent
== progid
)
730 mark_progid_for_install( package
, child
);
734 static void mark_mime_for_install( MSIMIME
*mime
)
738 mime
->InstallMe
= TRUE
;
741 LONG
msi_reg_set_val_str( HKEY hkey
, LPCWSTR name
, LPCWSTR value
)
743 DWORD len
= value
? (lstrlenW(value
) + 1) * sizeof (WCHAR
) : 0;
744 return RegSetValueExW( hkey
, name
, 0, REG_SZ
, (LPBYTE
)value
, len
);
747 LONG
msi_reg_set_val_multi_str( HKEY hkey
, LPCWSTR name
, LPCWSTR value
)
750 while (*p
) p
+= lstrlenW(p
) + 1;
751 return RegSetValueExW( hkey
, name
, 0, REG_MULTI_SZ
,
752 (LPBYTE
)value
, (p
+ 1 - value
) * sizeof(WCHAR
) );
755 LONG
msi_reg_set_val_dword( HKEY hkey
, LPCWSTR name
, DWORD val
)
757 return RegSetValueExW( hkey
, name
, 0, REG_DWORD
, (LPBYTE
)&val
, sizeof (DWORD
) );
760 LONG
msi_reg_set_subkey_val( HKEY hkey
, LPCWSTR path
, LPCWSTR name
, LPCWSTR val
)
765 r
= RegCreateKeyW( hkey
, path
, &hsubkey
);
766 if (r
!= ERROR_SUCCESS
)
768 r
= msi_reg_set_val_str( hsubkey
, name
, val
);
769 RegCloseKey( hsubkey
);
773 static UINT
register_appid(MSIAPPID
*appid
, LPCWSTR app
)
775 static const WCHAR szAppID
[] = { 'A','p','p','I','D',0 };
776 static const WCHAR szRemoteServerName
[] =
777 {'R','e','m','o','t','e','S','e','r','v','e','r','N','a','m','e',0};
778 static const WCHAR szLocalService
[] =
779 {'L','o','c','a','l','S','e','r','v','i','c','e',0};
780 static const WCHAR szService
[] =
781 {'S','e','r','v','i','c','e','P','a','r','a','m','e','t','e','r','s',0};
782 static const WCHAR szDLL
[] =
783 {'D','l','l','S','u','r','r','o','g','a','t','e',0};
784 static const WCHAR szActivate
[] =
785 {'A','c','t','i','v','a','t','e','A','s','S','t','o','r','a','g','e',0};
786 static const WCHAR szY
[] = {'Y',0};
787 static const WCHAR szRunAs
[] = {'R','u','n','A','s',0};
788 static const WCHAR szUser
[] =
789 {'I','n','t','e','r','a','c','t','i','v','e',' ','U','s','e','r',0};
793 RegCreateKeyW(HKEY_CLASSES_ROOT
,szAppID
,&hkey2
);
794 RegCreateKeyW( hkey2
, appid
->AppID
, &hkey3
);
796 msi_reg_set_val_str( hkey3
, NULL
, app
);
798 if (appid
->RemoteServerName
)
799 msi_reg_set_val_str( hkey3
, szRemoteServerName
, appid
->RemoteServerName
);
801 if (appid
->LocalServer
)
802 msi_reg_set_val_str( hkey3
, szLocalService
, appid
->LocalServer
);
804 if (appid
->ServiceParameters
)
805 msi_reg_set_val_str( hkey3
, szService
, appid
->ServiceParameters
);
807 if (appid
->DllSurrogate
)
808 msi_reg_set_val_str( hkey3
, szDLL
, appid
->DllSurrogate
);
810 if (appid
->ActivateAtStorage
)
811 msi_reg_set_val_str( hkey3
, szActivate
, szY
);
813 if (appid
->RunAsInteractiveUser
)
814 msi_reg_set_val_str( hkey3
, szRunAs
, szUser
);
817 return ERROR_SUCCESS
;
820 UINT
ACTION_RegisterClassInfo(MSIPACKAGE
*package
)
823 * Again I am assuming the words, "Whose key file represents" when referring
824 * to a Component as to meaning that Components KeyPath file
829 static const WCHAR szCLSID
[] = { 'C','L','S','I','D',0 };
830 static const WCHAR szProgID
[] = { 'P','r','o','g','I','D',0 };
831 static const WCHAR szVIProgID
[] = { 'V','e','r','s','i','o','n','I','n','d','e','p','e','n','d','e','n','t','P','r','o','g','I','D',0 };
832 static const WCHAR szAppID
[] = { 'A','p','p','I','D',0 };
833 static const WCHAR szSpace
[] = {' ',0};
834 static const WCHAR szInprocServer32
[] = {'I','n','p','r','o','c','S','e','r','v','e','r','3','2',0};
835 static const WCHAR szFileType_fmt
[] = {'F','i','l','e','T','y','p','e','\\','%','s','\\','%','i',0};
836 HKEY hkey
,hkey2
,hkey3
;
837 BOOL install_on_demand
= FALSE
;
841 return ERROR_INVALID_HANDLE
;
843 load_classes_and_such(package
);
844 rc
= RegCreateKeyW(HKEY_CLASSES_ROOT
,szCLSID
,&hkey
);
845 if (rc
!= ERROR_SUCCESS
)
846 return ERROR_FUNCTION_FAILED
;
848 /* install_on_demand should be set if OLE supports install on demand OLE
849 * servers. For now i am defaulting to FALSE because i do not know how to
850 * check, and i am told our builtin OLE does not support it
853 LIST_FOR_EACH_ENTRY( cls
, &package
->classes
, MSICLASS
, entry
)
861 comp
= cls
->Component
;
865 feature
= cls
->Feature
;
868 * yes. MSDN says that these are based on _Feature_ not on
869 * Component. So verify the feature is to be installed
871 if ((!ACTION_VerifyFeatureForAction( feature
, INSTALLSTATE_LOCAL
)) &&
872 !(install_on_demand
&&
873 ACTION_VerifyFeatureForAction( feature
, INSTALLSTATE_ADVERTISED
)))
875 TRACE("Skipping class %s reg due to disabled feature %s\n",
876 debugstr_w(cls
->clsid
),
877 debugstr_w(feature
->Feature
));
882 TRACE("Registering class %s (%p)\n", debugstr_w(cls
->clsid
), cls
);
884 cls
->Installed
= TRUE
;
885 mark_progid_for_install( package
, cls
->ProgID
);
887 RegCreateKeyW( hkey
, cls
->clsid
, &hkey2
);
889 if (cls
->Description
)
890 msi_reg_set_val_str( hkey2
, NULL
, cls
->Description
);
892 RegCreateKeyW( hkey2
, cls
->Context
, &hkey3
);
893 file
= get_loaded_file( package
, comp
->KeyPath
);
896 /* the context server is a short path name
897 * except for if it is InprocServer32...
899 if (strcmpiW( cls
->Context
, szInprocServer32
)!=0)
901 sz
= GetShortPathNameW( file
->TargetPath
, NULL
, 0 );
904 ERR("Unable to find short path for CLSID COM Server\n");
909 size
= sz
* sizeof(WCHAR
);
913 size
+= strlenW(cls
->Argument
) * sizeof(WCHAR
);
914 size
+= sizeof(WCHAR
);
917 argument
= msi_alloc( size
+ sizeof(WCHAR
));
918 GetShortPathNameW( file
->TargetPath
, argument
, sz
);
922 strcatW(argument
,szSpace
);
923 strcatW( argument
, cls
->Argument
);
929 size
= lstrlenW( file
->TargetPath
) * sizeof(WCHAR
);
933 size
+= strlenW(cls
->Argument
) * sizeof(WCHAR
);
934 size
+= sizeof(WCHAR
);
937 argument
= msi_alloc( size
+ sizeof(WCHAR
));
938 strcpyW( argument
, file
->TargetPath
);
942 strcatW(argument
,szSpace
);
943 strcatW( argument
, cls
->Argument
);
949 msi_reg_set_val_str( hkey3
, NULL
, argument
);
955 if (cls
->ProgID
|| cls
->ProgIDText
)
960 progid
= cls
->ProgID
->ProgID
;
962 progid
= cls
->ProgIDText
;
964 msi_reg_set_subkey_val( hkey2
, szProgID
, NULL
, progid
);
966 if (cls
->ProgID
&& cls
->ProgID
->VersionInd
)
968 msi_reg_set_subkey_val( hkey2
, szVIProgID
, NULL
,
969 cls
->ProgID
->VersionInd
->ProgID
);
975 MSIAPPID
*appid
= cls
->AppID
;
977 msi_reg_set_val_str( hkey2
, szAppID
, appid
->AppID
);
979 register_appid( appid
, cls
->Description
);
984 static const WCHAR szDefaultIcon
[] =
985 {'D','e','f','a','u','l','t','I','c','o','n',0};
987 msi_reg_set_subkey_val( hkey2
, szDefaultIcon
, NULL
, cls
->IconPath
);
990 if (cls
->DefInprocHandler
)
992 static const WCHAR szInproc
[] =
993 {'I','n','p','r','o','c','H','a','n','d','l','e','r',0};
995 msi_reg_set_subkey_val( hkey2
, szInproc
, NULL
, cls
->DefInprocHandler
);
998 if (cls
->DefInprocHandler32
)
1000 static const WCHAR szInproc32
[] =
1001 {'I','n','p','r','o','c','H','a','n','d','l','e','r','3','2',0};
1003 msi_reg_set_subkey_val( hkey2
, szInproc32
, NULL
, cls
->DefInprocHandler32
);
1008 /* if there is a FileTypeMask, register the FileType */
1009 if (cls
->FileTypeMask
)
1014 ptr
= cls
->FileTypeMask
;
1017 ptr2
= strchrW(ptr
,';');
1020 keyname
= msi_alloc( (strlenW(szFileType_fmt
) + strlenW(cls
->clsid
) + 4) * sizeof(WCHAR
));
1021 sprintfW( keyname
, szFileType_fmt
, cls
->clsid
, index
);
1023 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT
, keyname
, NULL
, ptr
);
1035 uirow
= MSI_CreateRecord(1);
1037 MSI_RecordSetStringW( uirow
, 1, cls
->clsid
);
1038 ui_actiondata(package
,szRegisterClassInfo
,uirow
);
1039 msiobj_release(&uirow
->hdr
);
1046 static UINT
register_progid_base(MSIPACKAGE
* package
, MSIPROGID
* progid
,
1049 static const WCHAR szCLSID
[] = { 'C','L','S','I','D',0 };
1050 static const WCHAR szDefaultIcon
[] =
1051 {'D','e','f','a','u','l','t','I','c','o','n',0};
1054 RegCreateKeyW(HKEY_CLASSES_ROOT
,progid
->ProgID
,&hkey
);
1056 if (progid
->Description
)
1057 msi_reg_set_val_str( hkey
, NULL
, progid
->Description
);
1061 msi_reg_set_subkey_val( hkey
, szCLSID
, NULL
, progid
->Class
->clsid
);
1063 strcpyW( clsid
, progid
->Class
->clsid
);
1067 FIXME("progid (%s) with null classid\n", debugstr_w(progid
->ProgID
));
1070 if (progid
->IconPath
)
1071 msi_reg_set_subkey_val( hkey
, szDefaultIcon
, NULL
, progid
->IconPath
);
1073 return ERROR_SUCCESS
;
1076 static UINT
register_progid(MSIPACKAGE
*package
, MSIPROGID
* progid
,
1079 UINT rc
= ERROR_SUCCESS
;
1081 if (progid
->Parent
== NULL
)
1082 rc
= register_progid_base(package
, progid
, clsid
);
1087 static const WCHAR szCLSID
[] = { 'C','L','S','I','D',0 };
1088 static const WCHAR szDefaultIcon
[] =
1089 {'D','e','f','a','u','l','t','I','c','o','n',0};
1090 static const WCHAR szCurVer
[] =
1091 {'C','u','r','V','e','r',0};
1093 /* check if already registered */
1094 RegCreateKeyExW(HKEY_CLASSES_ROOT
, progid
->ProgID
, 0, NULL
, 0,
1095 KEY_ALL_ACCESS
, NULL
, &hkey
, &disp
);
1096 if (disp
== REG_OPENED_EXISTING_KEY
)
1098 TRACE("Key already registered\n");
1103 TRACE("Registering Parent %s\n", debugstr_w(progid
->Parent
->ProgID
) );
1104 rc
= register_progid( package
, progid
->Parent
, clsid
);
1106 /* clsid is same as parent */
1107 msi_reg_set_subkey_val( hkey
, szCLSID
, NULL
, clsid
);
1109 if (progid
->Description
)
1110 msi_reg_set_val_str( hkey
, NULL
, progid
->Description
);
1112 if (progid
->IconPath
)
1113 msi_reg_set_subkey_val( hkey
, szDefaultIcon
, NULL
, progid
->IconPath
);
1115 /* write out the current version */
1117 msi_reg_set_subkey_val( hkey
, szCurVer
, NULL
, progid
->CurVer
->ProgID
);
1124 UINT
ACTION_RegisterProgIdInfo(MSIPACKAGE
*package
)
1130 return ERROR_INVALID_HANDLE
;
1132 load_classes_and_such(package
);
1134 LIST_FOR_EACH_ENTRY( progid
, &package
->progids
, MSIPROGID
, entry
)
1136 WCHAR clsid
[0x1000];
1138 /* check if this progid is to be installed */
1139 if (progid
->Class
&& progid
->Class
->Installed
)
1140 progid
->InstallMe
= TRUE
;
1142 if (!progid
->InstallMe
)
1144 TRACE("progid %s not scheduled to be installed\n",
1145 debugstr_w(progid
->ProgID
));
1149 TRACE("Registering progid %s\n", debugstr_w(progid
->ProgID
));
1151 register_progid( package
, progid
, clsid
);
1153 uirow
= MSI_CreateRecord(1);
1154 MSI_RecordSetStringW( uirow
, 1, progid
->ProgID
);
1155 ui_actiondata( package
, szRegisterProgIdInfo
, uirow
);
1156 msiobj_release( &uirow
->hdr
);
1159 return ERROR_SUCCESS
;
1162 static UINT
register_verb(MSIPACKAGE
*package
, LPCWSTR progid
,
1163 MSICOMPONENT
* component
, MSIEXTENSION
* extension
,
1164 MSIVERB
* verb
, INT
* Sequence
)
1168 static const WCHAR szShell
[] = {'s','h','e','l','l',0};
1169 static const WCHAR szCommand
[] = {'c','o','m','m','a','n','d',0};
1170 static const WCHAR fmt
[] = {'\"','%','s','\"',' ','%','s',0};
1171 static const WCHAR fmt2
[] = {'\"','%','s','\"',0};
1176 keyname
= build_directory_name(4, progid
, szShell
, verb
->Verb
, szCommand
);
1178 TRACE("Making Key %s\n",debugstr_w(keyname
));
1179 RegCreateKeyW(HKEY_CLASSES_ROOT
, keyname
, &key
);
1180 size
= strlenW(component
->FullKeypath
);
1182 size
+= strlenW(verb
->Argument
);
1185 command
= msi_alloc(size
* sizeof (WCHAR
));
1187 sprintfW(command
, fmt
, component
->FullKeypath
, verb
->Argument
);
1189 sprintfW(command
, fmt2
, component
->FullKeypath
);
1191 msi_reg_set_val_str( key
, NULL
, command
);
1194 advertise
= create_component_advertise_string(package
, component
,
1195 extension
->Feature
->Feature
);
1197 size
= strlenW(advertise
);
1200 size
+= strlenW(verb
->Argument
);
1203 command
= msi_alloc(size
* sizeof (WCHAR
));
1204 memset(command
,0,size
*sizeof(WCHAR
));
1206 strcpyW(command
,advertise
);
1209 static const WCHAR szSpace
[] = {' ',0};
1210 strcatW(command
,szSpace
);
1211 strcatW(command
,verb
->Argument
);
1214 msi_reg_set_val_multi_str( key
, szCommand
, command
);
1218 msi_free(advertise
);
1223 keyname
= build_directory_name(3, progid
, szShell
, verb
->Verb
);
1224 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT
, keyname
, NULL
, verb
->Command
);
1228 if (verb
->Sequence
!= MSI_NULL_INTEGER
)
1230 if (*Sequence
== MSI_NULL_INTEGER
|| verb
->Sequence
< *Sequence
)
1232 *Sequence
= verb
->Sequence
;
1233 keyname
= build_directory_name(2, progid
, szShell
);
1234 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT
, keyname
, NULL
, verb
->Verb
);
1238 return ERROR_SUCCESS
;
1241 UINT
ACTION_RegisterExtensionInfo(MSIPACKAGE
*package
)
1243 static const WCHAR szContentType
[] =
1244 {'C','o','n','t','e','n','t',' ','T','y','p','e',0 };
1248 BOOL install_on_demand
= TRUE
;
1251 return ERROR_INVALID_HANDLE
;
1253 load_classes_and_such(package
);
1255 /* We need to set install_on_demand based on if the shell handles advertised
1256 * shortcuts and the like. Because Mike McCormack is working on this i am
1257 * going to default to TRUE
1260 LIST_FOR_EACH_ENTRY( ext
, &package
->extensions
, MSIEXTENSION
, entry
)
1263 MSIFEATURE
*feature
;
1265 if (!ext
->Component
)
1268 feature
= ext
->Feature
;
1271 * yes. MSDN says that these are based on _Feature_ not on
1272 * Component. So verify the feature is to be installed
1274 if ((!ACTION_VerifyFeatureForAction( feature
, INSTALLSTATE_LOCAL
)) &&
1275 !(install_on_demand
&&
1276 ACTION_VerifyFeatureForAction( feature
, INSTALLSTATE_ADVERTISED
)))
1278 TRACE("Skipping extension %s reg due to disabled feature %s\n",
1279 debugstr_w(ext
->Extension
), debugstr_w(feature
->Feature
));
1284 TRACE("Registering extension %s (%p)\n", debugstr_w(ext
->Extension
), ext
);
1286 ext
->Installed
= TRUE
;
1288 /* this is only registered if the extension has at least 1 verb
1291 if (ext
->ProgID
&& !list_empty( &ext
->verbs
) )
1292 mark_progid_for_install( package
, ext
->ProgID
);
1294 mark_mime_for_install(ext
->Mime
);
1296 extension
= msi_alloc( (lstrlenW( ext
->Extension
) + 2)*sizeof(WCHAR
) );
1298 lstrcpyW(extension
+1,ext
->Extension
);
1300 RegCreateKeyW(HKEY_CLASSES_ROOT
,extension
,&hkey
);
1301 msi_free( extension
);
1304 msi_reg_set_val_str( hkey
, szContentType
, ext
->Mime
->ContentType
);
1306 if (ext
->ProgID
|| ext
->ProgIDText
)
1308 static const WCHAR szSN
[] =
1309 {'\\','S','h','e','l','l','N','e','w',0};
1314 INT Sequence
= MSI_NULL_INTEGER
;
1317 progid
= ext
->ProgID
->ProgID
;
1319 progid
= ext
->ProgIDText
;
1321 msi_reg_set_val_str( hkey
, NULL
, progid
);
1323 newkey
= msi_alloc( (strlenW(progid
)+strlenW(szSN
)+1) * sizeof(WCHAR
));
1325 strcpyW(newkey
,progid
);
1326 strcatW(newkey
,szSN
);
1327 RegCreateKeyW(hkey
,newkey
,&hkey2
);
1332 /* do all the verbs */
1333 LIST_FOR_EACH_ENTRY( verb
, &ext
->verbs
, MSIVERB
, entry
)
1335 register_verb( package
, progid
, ext
->Component
,
1336 ext
, verb
, &Sequence
);
1342 uirow
= MSI_CreateRecord(1);
1343 MSI_RecordSetStringW( uirow
, 1, ext
->Extension
);
1344 ui_actiondata(package
,szRegisterExtensionInfo
,uirow
);
1345 msiobj_release(&uirow
->hdr
);
1348 return ERROR_SUCCESS
;
1351 UINT
ACTION_RegisterMIMEInfo(MSIPACKAGE
*package
)
1353 static const WCHAR szExten
[] =
1354 {'E','x','t','e','n','s','i','o','n',0 };
1359 return ERROR_INVALID_HANDLE
;
1361 load_classes_and_such(package
);
1363 LIST_FOR_EACH_ENTRY( mt
, &package
->mimes
, MSIMIME
, entry
)
1368 static const WCHAR fmt
[] =
1369 {'M','I','M','E','\\','D','a','t','a','b','a','s','e','\\',
1370 'C','o','n','t','e','n','t',' ','T','y','p','e','\\', '%','s',0};
1374 * check if the MIME is to be installed. Either as requesed by an
1375 * extension or Class
1377 mt
->InstallMe
= (mt
->InstallMe
||
1378 (mt
->Class
&& mt
->Class
->Installed
) ||
1379 (mt
->Extension
&& mt
->Extension
->Installed
));
1383 TRACE("MIME %s not scheduled to be installed\n",
1384 debugstr_w(mt
->ContentType
));
1388 mime
= mt
->ContentType
;
1389 exten
= mt
->Extension
->Extension
;
1391 extension
= msi_alloc( (lstrlenW( exten
) + 2)*sizeof(WCHAR
) );
1393 lstrcpyW(extension
+1,exten
);
1395 key
= msi_alloc( (strlenW(mime
)+strlenW(fmt
)+1) * sizeof(WCHAR
) );
1396 sprintfW(key
,fmt
,mime
);
1397 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT
, key
, szExten
, extension
);
1399 msi_free(extension
);
1403 FIXME("Handle non null for field 3\n");
1405 uirow
= MSI_CreateRecord(2);
1406 MSI_RecordSetStringW(uirow
,1,mt
->ContentType
);
1407 MSI_RecordSetStringW(uirow
,2,exten
);
1408 ui_actiondata(package
,szRegisterMIMEInfo
,uirow
);
1409 msiobj_release(&uirow
->hdr
);
1412 return ERROR_SUCCESS
;