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
22 * Here are helper functions formally in action.c that are used by a variety of
23 * actions and functions.
29 #include "wine/debug.h"
32 #include "wine/unicode.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(msi);
37 static const WCHAR cszTargetDir[] = {'T','A','R','G','E','T','D','I','R',0};
38 static const WCHAR cszDatabase[]={'D','A','T','A','B','A','S','E',0};
40 const WCHAR cszSourceDir[] = {'S','o','u','r','c','e','D','i','r',0};
41 const WCHAR cszSOURCEDIR[] = {'S','O','U','R','C','E','D','I','R',0};
42 const WCHAR cszRootDrive[] = {'R','O','O','T','D','R','I','V','E',0};
43 const WCHAR cszbs[]={'\\',0};
45 LPWSTR build_icon_path(MSIPACKAGE *package, LPCWSTR icon_name )
47 LPWSTR SystemFolder, dest, FilePath;
49 static const WCHAR szInstaller[] =
50 {'M','i','c','r','o','s','o','f','t','\\',
51 'I','n','s','t','a','l','l','e','r','\\',0};
52 static const WCHAR szFolder[] =
53 {'A','p','p','D','a','t','a','F','o','l','d','e','r',0};
55 SystemFolder = msi_dup_property( package, szFolder );
57 dest = build_directory_name(3, SystemFolder, szInstaller, package->ProductCode);
59 create_full_pathW(dest);
61 FilePath = build_directory_name(2, dest, icon_name);
63 msi_free(SystemFolder);
68 LPWSTR msi_dup_record_field( MSIRECORD *rec, INT field )
74 if (MSI_RecordIsNull( rec, field ))
77 r = MSI_RecordGetStringW( rec, field, NULL, &sz );
78 if (r != ERROR_SUCCESS)
82 str = msi_alloc( sz * sizeof (WCHAR) );
86 r = MSI_RecordGetStringW( rec, field, str, &sz );
87 if (r != ERROR_SUCCESS)
89 ERR("failed to get string!\n");
96 MSICOMPONENT* get_loaded_component( MSIPACKAGE* package, LPCWSTR Component )
100 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
102 if (lstrcmpW(Component,comp->Component)==0)
108 MSIFEATURE* get_loaded_feature(MSIPACKAGE* package, LPCWSTR Feature )
112 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
114 if (lstrcmpW( Feature, feature->Feature )==0)
120 MSIFILE* get_loaded_file( MSIPACKAGE* package, LPCWSTR key )
124 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
126 if (lstrcmpW( key, file->File )==0)
132 int track_tempfile( MSIPACKAGE *package, LPCWSTR path )
136 TRACE("%s\n", debugstr_w(path));
138 LIST_FOR_EACH_ENTRY( temp, &package->tempfiles, MSITEMPFILE, entry )
139 if (!lstrcmpW( path, temp->Path ))
142 temp = msi_alloc_zero( sizeof (MSITEMPFILE) );
146 list_add_head( &package->tempfiles, &temp->entry );
147 temp->Path = strdupW( path );
152 MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir )
156 LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry )
158 if (lstrcmpW( dir, folder->Directory )==0)
164 void msi_reset_folders( MSIPACKAGE *package, BOOL source )
168 LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry )
172 msi_free( folder->ResolvedSource );
173 folder->ResolvedSource = NULL;
177 msi_free( folder->ResolvedTarget );
178 folder->ResolvedTarget = NULL;
183 static LPWSTR get_source_root( MSIPACKAGE *package )
187 path = msi_dup_property( package, cszSourceDir );
191 path = msi_dup_property( package, cszDatabase );
194 p = strrchrW(path,'\\');
202 * clean_spaces_from_path()
204 * removes spaces from the beginning and end of path segments
205 * removes multiple \\ characters
207 static void clean_spaces_from_path( LPWSTR p )
214 /* copy until the end of the string or a space */
215 while (*p != ' ' && (*q = *p))
218 /* reduce many backslashes to one */
219 if (*p != '\\' || *q != '\\')
223 /* quit at the end of the string */
227 /* count the number of spaces */
232 /* if it's leading or trailing space, skip it */
233 if ( len == 0 || p[-1] == '\\' || p[n] == '\\' )
235 else /* copy n spaces */
236 while (n && (*q++ = *p++)) n--;
240 LPWSTR resolve_file_source(MSIPACKAGE *package, MSIFILE *file)
244 TRACE("Working to resolve source of file %s\n", debugstr_w(file->File));
246 if (file->IsCompressed)
249 p = resolve_folder(package, file->Component->Directory,
250 TRUE, FALSE, TRUE, NULL);
251 path = build_directory_name(2, p, file->ShortName);
253 if (file->LongName &&
254 GetFileAttributesW(path) == INVALID_FILE_ATTRIBUTES)
257 path = build_directory_name(2, p, file->LongName);
262 TRACE("file %s source resolves to %s\n", debugstr_w(file->File),
268 LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
269 BOOL set_prop, BOOL load_prop, MSIFOLDER **folder)
272 LPWSTR p, path = NULL, parent;
274 TRACE("Working to resolve %s\n",debugstr_w(name));
279 if (!lstrcmpW(name,cszSourceDir))
282 f = get_loaded_folder( package, name );
286 /* special resolving for Target and Source root dir */
287 if (!strcmpW(name,cszTargetDir))
289 if (!f->ResolvedTarget && !f->Property)
292 check_path = msi_dup_property( package, cszTargetDir );
295 check_path = msi_dup_property( package, cszRootDrive );
297 MSI_SetPropertyW(package,cszTargetDir,check_path);
300 /* correct misbuilt target dir */
301 path = build_directory_name(2, check_path, NULL);
302 clean_spaces_from_path( path );
303 if (strcmpiW(path,check_path)!=0)
304 MSI_SetPropertyW(package,cszTargetDir,path);
305 msi_free(check_path);
307 f->ResolvedTarget = path;
310 if (!f->ResolvedSource)
311 f->ResolvedSource = get_source_root( package );
317 if (!source && f->ResolvedTarget)
319 path = strdupW( f->ResolvedTarget );
320 TRACE(" already resolved to %s\n",debugstr_w(path));
324 if (source && f->ResolvedSource)
326 path = strdupW( f->ResolvedSource );
327 TRACE(" (source)already resolved to %s\n",debugstr_w(path));
331 if (!source && f->Property)
333 path = build_directory_name( 2, f->Property, NULL );
335 TRACE(" internally set to %s\n",debugstr_w(path));
337 MSI_SetPropertyW( package, name, path );
341 if (!source && load_prop && (path = msi_dup_property( package, name )))
343 f->ResolvedTarget = strdupW( path );
344 TRACE(" property set to %s\n", debugstr_w(path));
353 TRACE(" ! Parent is %s\n", debugstr_w(parent));
355 p = resolve_folder(package, parent, source, set_prop, load_prop, NULL);
358 TRACE(" TargetDefault = %s\n", debugstr_w(f->TargetDefault));
360 path = build_directory_name( 3, p, f->TargetDefault, NULL );
361 clean_spaces_from_path( path );
362 f->ResolvedTarget = strdupW( path );
363 TRACE("target -> %s\n", debugstr_w(path));
365 MSI_SetPropertyW(package,name,path);
371 if (package->WordCount & msidbSumInfoSourceTypeCompressed)
372 path = get_source_root( package );
373 else if (package->WordCount & msidbSumInfoSourceTypeSFN)
374 path = build_directory_name( 3, p, f->SourceShortPath, NULL );
376 path = build_directory_name( 3, p, f->SourceLongPath, NULL );
378 TRACE("source -> %s\n", debugstr_w(path));
379 f->ResolvedSource = strdupW( path );
386 /* wrapper to resist a need for a full rewrite right now */
387 DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data )
391 MSIRECORD *rec = MSI_CreateRecord(1);
394 MSI_RecordSetStringW(rec,0,ptr);
395 MSI_FormatRecordW(package,rec,NULL,&size);
398 *data = msi_alloc(size*sizeof(WCHAR));
400 MSI_FormatRecordW(package,rec,*data,&size);
404 msiobj_release( &rec->hdr );
405 return sizeof(WCHAR)*size;
412 UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action)
415 LPWSTR *newbuf = NULL;
416 if (script >= TOTAL_SCRIPTS)
418 FIXME("Unknown script requested %i\n",script);
419 return ERROR_FUNCTION_FAILED;
421 TRACE("Scheduling Action %s in script %i\n",debugstr_w(action), script);
423 count = package->script->ActionCount[script];
424 package->script->ActionCount[script]++;
426 newbuf = msi_realloc( package->script->Actions[script],
427 package->script->ActionCount[script]* sizeof(LPWSTR));
429 newbuf = msi_alloc( sizeof(LPWSTR));
431 newbuf[count] = strdupW(action);
432 package->script->Actions[script] = newbuf;
434 return ERROR_SUCCESS;
437 void msi_free_action_script(MSIPACKAGE *package, UINT script)
440 for (i = 0; i < package->script->ActionCount[script]; i++)
441 msi_free(package->script->Actions[script][i]);
443 msi_free(package->script->Actions[script]);
444 package->script->Actions[script] = NULL;
445 package->script->ActionCount[script] = 0;
448 static void remove_tracked_tempfiles(MSIPACKAGE* package)
450 struct list *item, *cursor;
452 LIST_FOR_EACH_SAFE( item, cursor, &package->tempfiles )
454 MSITEMPFILE *temp = LIST_ENTRY( item, MSITEMPFILE, entry );
456 list_remove( &temp->entry );
457 TRACE("deleting temp file %s\n", debugstr_w( temp->Path ));
458 if (!DeleteFileW( temp->Path ))
459 ERR("failed to delete %s\n", debugstr_w( temp->Path ));
460 msi_free( temp->Path );
465 static void free_feature( MSIFEATURE *feature )
467 struct list *item, *cursor;
469 LIST_FOR_EACH_SAFE( item, cursor, &feature->Children )
471 FeatureList *fl = LIST_ENTRY( item, FeatureList, entry );
472 list_remove( &fl->entry );
476 LIST_FOR_EACH_SAFE( item, cursor, &feature->Components )
478 ComponentList *cl = LIST_ENTRY( item, ComponentList, entry );
479 list_remove( &cl->entry );
482 msi_free( feature->Feature );
483 msi_free( feature->Feature_Parent );
484 msi_free( feature->Directory );
485 msi_free( feature->Description );
486 msi_free( feature->Title );
490 static void free_extension( MSIEXTENSION *ext )
492 struct list *item, *cursor;
494 LIST_FOR_EACH_SAFE( item, cursor, &ext->verbs )
496 MSIVERB *verb = LIST_ENTRY( item, MSIVERB, entry );
498 list_remove( &verb->entry );
499 msi_free( verb->Verb );
500 msi_free( verb->Command );
501 msi_free( verb->Argument );
505 msi_free( ext->Extension );
506 msi_free( ext->ProgIDText );
510 /* Called when the package is being closed */
511 void ACTION_free_package_structures( MSIPACKAGE* package)
514 struct list *item, *cursor;
516 TRACE("Freeing package action data\n");
518 remove_tracked_tempfiles(package);
520 LIST_FOR_EACH_SAFE( item, cursor, &package->features )
522 MSIFEATURE *feature = LIST_ENTRY( item, MSIFEATURE, entry );
523 list_remove( &feature->entry );
524 free_feature( feature );
527 LIST_FOR_EACH_SAFE( item, cursor, &package->folders )
529 MSIFOLDER *folder = LIST_ENTRY( item, MSIFOLDER, entry );
531 list_remove( &folder->entry );
532 msi_free( folder->Parent );
533 msi_free( folder->Directory );
534 msi_free( folder->TargetDefault );
535 msi_free( folder->SourceLongPath );
536 msi_free( folder->SourceShortPath );
537 msi_free( folder->ResolvedTarget );
538 msi_free( folder->ResolvedSource );
539 msi_free( folder->Property );
543 LIST_FOR_EACH_SAFE( item, cursor, &package->components )
545 MSICOMPONENT *comp = LIST_ENTRY( item, MSICOMPONENT, entry );
547 list_remove( &comp->entry );
548 msi_free( comp->Component );
549 msi_free( comp->ComponentId );
550 msi_free( comp->Directory );
551 msi_free( comp->Condition );
552 msi_free( comp->KeyPath );
553 msi_free( comp->FullKeypath );
557 LIST_FOR_EACH_SAFE( item, cursor, &package->files )
559 MSIFILE *file = LIST_ENTRY( item, MSIFILE, entry );
561 list_remove( &file->entry );
562 msi_free( file->File );
563 msi_free( file->FileName );
564 msi_free( file->ShortName );
565 msi_free( file->LongName );
566 msi_free( file->Version );
567 msi_free( file->Language );
568 msi_free( file->TargetPath );
572 /* clean up extension, progid, class and verb structures */
573 LIST_FOR_EACH_SAFE( item, cursor, &package->classes )
575 MSICLASS *cls = LIST_ENTRY( item, MSICLASS, entry );
577 list_remove( &cls->entry );
578 msi_free( cls->clsid );
579 msi_free( cls->Context );
580 msi_free( cls->Description );
581 msi_free( cls->FileTypeMask );
582 msi_free( cls->IconPath );
583 msi_free( cls->DefInprocHandler );
584 msi_free( cls->DefInprocHandler32 );
585 msi_free( cls->Argument );
586 msi_free( cls->ProgIDText );
590 LIST_FOR_EACH_SAFE( item, cursor, &package->extensions )
592 MSIEXTENSION *ext = LIST_ENTRY( item, MSIEXTENSION, entry );
594 list_remove( &ext->entry );
595 free_extension( ext );
598 LIST_FOR_EACH_SAFE( item, cursor, &package->progids )
600 MSIPROGID *progid = LIST_ENTRY( item, MSIPROGID, entry );
602 list_remove( &progid->entry );
603 msi_free( progid->ProgID );
604 msi_free( progid->Description );
605 msi_free( progid->IconPath );
609 LIST_FOR_EACH_SAFE( item, cursor, &package->mimes )
611 MSIMIME *mt = LIST_ENTRY( item, MSIMIME, entry );
613 list_remove( &mt->entry );
614 msi_free( mt->clsid );
615 msi_free( mt->ContentType );
619 LIST_FOR_EACH_SAFE( item, cursor, &package->appids )
621 MSIAPPID *appid = LIST_ENTRY( item, MSIAPPID, entry );
623 list_remove( &appid->entry );
624 msi_free( appid->AppID );
625 msi_free( appid->RemoteServerName );
626 msi_free( appid->LocalServer );
627 msi_free( appid->ServiceParameters );
628 msi_free( appid->DllSurrogate );
632 LIST_FOR_EACH_SAFE( item, cursor, &package->sourcelist_info )
634 MSISOURCELISTINFO *info = LIST_ENTRY( item, MSISOURCELISTINFO, entry );
636 list_remove( &info->entry );
637 msi_free( info->value );
641 LIST_FOR_EACH_SAFE( item, cursor, &package->sourcelist_media )
643 MSIMEDIADISK *info = LIST_ENTRY( item, MSIMEDIADISK, entry );
645 list_remove( &info->entry );
646 msi_free( info->volume_label );
647 msi_free( info->disk_prompt );
653 for (i = 0; i < TOTAL_SCRIPTS; i++)
654 msi_free_action_script(package, i);
656 for (i = 0; i < package->script->UniqueActionsCount; i++)
657 msi_free(package->script->UniqueActions[i]);
659 msi_free(package->script->UniqueActions);
660 msi_free(package->script);
663 msi_free(package->BaseURL);
664 msi_free(package->PackagePath);
665 msi_free(package->ProductCode);
666 msi_free(package->ActionFormat);
667 msi_free(package->LastAction);
669 /* cleanup control event subscriptions */
670 ControlEvent_CleanupSubscriptions(package);
674 * build_directory_name()
676 * This function is to save messing round with directory names
677 * It handles adding backslashes between path segments,
678 * and can add \ at the end of the directory name if told to.
680 * It takes a variable number of arguments.
681 * It always allocates a new string for the result, so make sure
682 * to free the return value when finished with it.
684 * The first arg is the number of path segments that follow.
685 * The arguments following count are a list of path segments.
686 * A path segment may be NULL.
688 * Path segments will be added with a \ separating them.
689 * A \ will not be added after the last segment, however if the
690 * last segment is NULL, then the last character will be a \
693 LPWSTR build_directory_name(DWORD count, ...)
700 for(i=0; i<count; i++)
702 LPCWSTR str = va_arg(va,LPCWSTR);
704 sz += strlenW(str) + 1;
708 dir = msi_alloc(sz*sizeof(WCHAR));
712 for(i=0; i<count; i++)
714 LPCWSTR str = va_arg(va,LPCWSTR);
718 if( ((i+1)!=count) && dir[strlenW(dir)-1]!='\\')
724 /***********************************************************************
727 * Recursively create all directories in the path.
729 * shamelessly stolen from setupapi/queue.c
731 BOOL create_full_pathW(const WCHAR *path)
737 new_path = msi_alloc( (strlenW(path) + 1) * sizeof(WCHAR));
739 strcpyW(new_path, path);
741 while((len = strlenW(new_path)) && new_path[len - 1] == '\\')
742 new_path[len - 1] = 0;
744 while(!CreateDirectoryW(new_path, NULL))
747 DWORD last_error = GetLastError();
748 if(last_error == ERROR_ALREADY_EXISTS)
751 if(last_error != ERROR_PATH_NOT_FOUND)
757 if(!(slash = strrchrW(new_path, '\\')))
763 len = slash - new_path;
765 if(!create_full_pathW(new_path))
770 new_path[len] = '\\';
777 void ui_progress(MSIPACKAGE *package, int a, int b, int c, int d )
781 row = MSI_CreateRecord(4);
782 MSI_RecordSetInteger(row,1,a);
783 MSI_RecordSetInteger(row,2,b);
784 MSI_RecordSetInteger(row,3,c);
785 MSI_RecordSetInteger(row,4,d);
786 MSI_ProcessMessage(package, INSTALLMESSAGE_PROGRESS, row);
787 msiobj_release(&row->hdr);
789 msi_dialog_check_messages(NULL);
792 void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * record)
794 static const WCHAR Query_t[] =
795 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
796 '`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
797 'W','H','E','R','E',' ', '`','A','c','t','i','o','n','`',' ','=',
798 ' ','\'','%','s','\'',0};
803 if (!package->LastAction || strcmpW(package->LastAction,action))
805 row = MSI_QueryGetRecord(package->db, Query_t, action);
809 if (MSI_RecordIsNull(row,3))
811 msiobj_release(&row->hdr);
815 /* update the cached actionformat */
816 msi_free(package->ActionFormat);
817 package->ActionFormat = msi_dup_record_field(row,3);
819 msi_free(package->LastAction);
820 package->LastAction = strdupW(action);
822 msiobj_release(&row->hdr);
825 MSI_RecordSetStringW(record,0,package->ActionFormat);
827 MSI_FormatRecordW(package,record,message,&size);
829 row = MSI_CreateRecord(1);
830 MSI_RecordSetStringW(row,1,message);
832 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, row);
834 msiobj_release(&row->hdr);
837 BOOL ACTION_VerifyComponentForAction( const MSICOMPONENT* comp, INSTALLSTATE check )
842 if (comp->ActionRequest == check)
848 BOOL ACTION_VerifyFeatureForAction( const MSIFEATURE* feature, INSTALLSTATE check )
853 if (feature->ActionRequest == check)
859 void reduce_to_longfilename(WCHAR* filename)
861 LPWSTR p = strchrW(filename,'|');
863 memmove(filename, p+1, (strlenW(p+1)+1)*sizeof(WCHAR));
866 void reduce_to_shortfilename(WCHAR* filename)
868 LPWSTR p = strchrW(filename,'|');
873 LPWSTR create_component_advertise_string(MSIPACKAGE* package,
874 MSICOMPONENT* component, LPCWSTR feature)
876 static const WCHAR fmt[] = {'%','s','%','s','%','c','%','s',0};
877 WCHAR productid_85[21], component_85[21];
878 LPWSTR output = NULL;
882 /* > is used if there is a component GUID and < if not. */
887 CLSIDFromString(package->ProductCode, &clsid);
888 encode_base85_guid(&clsid, productid_85);
892 CLSIDFromString(component->ComponentId, &clsid);
893 encode_base85_guid(&clsid, component_85);
896 TRACE("prod=%s feat=%s comp=%s\n", debugstr_w(productid_85),
897 debugstr_w(feature), debugstr_w(component_85));
899 sz = 20 + lstrlenW(feature) + 20 + 3;
901 output = msi_alloc_zero(sz*sizeof(WCHAR));
903 sprintfW(output, fmt, productid_85, feature,
904 component?'>':'<', component_85);
909 /* update component state based on a feature change */
910 void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature)
912 INSTALLSTATE newstate;
916 feature = get_loaded_feature(package,szFeature);
920 newstate = feature->ActionRequest;
922 if (newstate == INSTALLSTATE_ABSENT)
923 newstate = INSTALLSTATE_UNKNOWN;
925 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
927 MSICOMPONENT* component = cl->component;
929 TRACE("MODIFYING(%i): Component %s (Installed %i, Action %i, Request %i)\n",
930 newstate, debugstr_w(component->Component), component->Installed,
931 component->Action, component->ActionRequest);
933 if (!component->Enabled)
936 if (newstate == INSTALLSTATE_LOCAL)
937 msi_component_set_state(package, component, INSTALLSTATE_LOCAL);
940 ComponentList *clist;
943 component->hasLocalFeature = FALSE;
945 msi_component_set_state(package, component, newstate);
947 /*if any other feature wants is local we need to set it local*/
948 LIST_FOR_EACH_ENTRY( f, &package->features, MSIFEATURE, entry )
950 if ( f->ActionRequest != INSTALLSTATE_LOCAL &&
951 f->ActionRequest != INSTALLSTATE_SOURCE )
956 LIST_FOR_EACH_ENTRY( clist, &f->Components, ComponentList, entry )
958 if ( clist->component == component &&
959 (f->ActionRequest == INSTALLSTATE_LOCAL ||
960 f->ActionRequest == INSTALLSTATE_SOURCE) )
962 TRACE("Saved by %s\n", debugstr_w(f->Feature));
963 component->hasLocalFeature = TRUE;
965 if (component->Attributes & msidbComponentAttributesOptional)
967 if (f->Attributes & msidbFeatureAttributesFavorSource)
968 msi_component_set_state(package, component, INSTALLSTATE_SOURCE);
970 msi_component_set_state(package, component, INSTALLSTATE_LOCAL);
972 else if (component->Attributes & msidbComponentAttributesSourceOnly)
973 msi_component_set_state(package, component, INSTALLSTATE_SOURCE);
975 msi_component_set_state(package, component, INSTALLSTATE_LOCAL);
980 TRACE("Result (%i): Component %s (Installed %i, Action %i, Request %i)\n",
981 newstate, debugstr_w(component->Component), component->Installed,
982 component->Action, component->ActionRequest);
986 UINT register_unique_action(MSIPACKAGE *package, LPCWSTR action)
989 LPWSTR *newbuf = NULL;
991 if (!package->script)
994 TRACE("Registering Action %s as having fun\n",debugstr_w(action));
996 count = package->script->UniqueActionsCount;
997 package->script->UniqueActionsCount++;
999 newbuf = msi_realloc( package->script->UniqueActions,
1000 package->script->UniqueActionsCount* sizeof(LPWSTR));
1002 newbuf = msi_alloc( sizeof(LPWSTR));
1004 newbuf[count] = strdupW(action);
1005 package->script->UniqueActions = newbuf;
1007 return ERROR_SUCCESS;
1010 BOOL check_unique_action(const MSIPACKAGE *package, LPCWSTR action)
1014 if (!package->script)
1017 for (i = 0; i < package->script->UniqueActionsCount; i++)
1018 if (!strcmpW(package->script->UniqueActions[i],action))
1024 WCHAR* generate_error_string(MSIPACKAGE *package, UINT error, DWORD count, ... )
1026 static const WCHAR query[] = {'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ','F','R','O','M',' ','`','E','r','r','o','r','`',' ','W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ','%','i',0};
1036 row = MSI_QueryGetRecord(package->db, query, error);
1040 rec = MSI_CreateRecord(count+2);
1042 str = MSI_RecordGetString(row,1);
1043 MSI_RecordSetStringW(rec,0,str);
1044 msiobj_release( &row->hdr );
1045 MSI_RecordSetInteger(rec,1,error);
1048 for (i = 0; i < count; i++)
1050 str = va_arg(va,LPCWSTR);
1051 MSI_RecordSetStringW(rec,(i+2),str);
1055 MSI_FormatRecordW(package,rec,NULL,&size);
1058 data = msi_alloc(size*sizeof(WCHAR));
1060 MSI_FormatRecordW(package,rec,data,&size);
1063 msiobj_release( &rec->hdr );
1067 void msi_ui_error( DWORD msg_id, DWORD type )
1071 static const WCHAR title[] = {
1072 'W','i','n','d','o','w','s',' ','I','n','s','t','a','l','l','e','r',0
1075 if (!MsiLoadStringW( -1, msg_id, text, sizeof(text) / sizeof(text[0]),
1076 MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ))
1079 MessageBoxW( NULL, text, title, type );